Profiler Keybindings (#1801)

* Added default new profiler keybinding. Exposed profiler.start and profiler.stop so they can be used with keybindings

* Changing where session state gets set

* Cleaning up unnecessary code
This commit is contained in:
Madeline MacDonald
2018-06-29 16:34:40 -07:00
committed by GitHub
parent 4f76f116ac
commit 1819036d7d
6 changed files with 72 additions and 10 deletions

View File

@@ -8,6 +8,7 @@ import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import * as sqlops from 'sqlops';
import { INewProfilerState } from '../editor/profilerState';
const PROFILER_SERVICE_ID = 'profilerService';
export const IProfilerService = createDecorator<IProfilerService>(PROFILER_SERVICE_ID);
@@ -29,6 +30,10 @@ export interface IProfilerSession {
* Called by the service when the session is closed unexpectedly
*/
onSessionStopped(events: sqlops.ProfilerSessionStoppedParams);
/**
* Called by the service when the session state is changed
*/
onSessionStateChanged(newState: INewProfilerState);
}
/**

View File

@@ -96,7 +96,10 @@ export class ProfilerService implements IProfilerService {
}
public startSession(id: ProfilerSessionID): Thenable<boolean> {
return this._runAction(id, provider => provider.startSession(this._idMap.get(id)));
return this._runAction(id, provider => provider.startSession(this._idMap.get(id))).then(() => {
this._sessionMap.get(this._idMap.reverseGet(id)).onSessionStateChanged({ isRunning: true, isStopped: false, isPaused: false });
return true;
});
}
public pauseSession(id: ProfilerSessionID): Thenable<boolean> {
@@ -104,7 +107,10 @@ export class ProfilerService implements IProfilerService {
}
public stopSession(id: ProfilerSessionID): Thenable<boolean> {
return this._runAction(id, provider => provider.stopSession(this._idMap.get(id)));
return this._runAction(id, provider => provider.stopSession(this._idMap.get(id))).then(() => {
this._sessionMap.get(this._idMap.reverseGet(id)).onSessionStateChanged({ isStopped: true, isPaused: false, isRunning: false });
return true;
});
}
private _runAction<T>(id: ProfilerSessionID, action: (handler: sqlops.ProfilerProvider) => Thenable<T>): Thenable<T> {