introduce and use LifecyclePhase.RunningForABit (for #38080)

This commit is contained in:
Benjamin Pasero
2017-11-13 19:51:50 +01:00
parent 8692ecf9fa
commit fa592ef424
4 changed files with 30 additions and 12 deletions

View File

@@ -49,7 +49,8 @@ export enum LifecyclePhase {
Starting = 1,
Restoring = 2,
Running = 3,
ShuttingDown = 4
RunningForABit = 4,
ShuttingDown = 5
}
/**

View File

@@ -72,7 +72,7 @@ export class WorkbenchContributionsRegistry implements IWorkbenchContributionsRe
this.instantiationService = instantiationService;
this.lifecycleService = lifecycleService;
[LifecyclePhase.Starting, LifecyclePhase.Restoring, LifecyclePhase.Running, LifecyclePhase.ShuttingDown].forEach(phase => {
[LifecyclePhase.Starting, LifecyclePhase.Restoring, LifecyclePhase.Running, LifecyclePhase.RunningForABit, LifecyclePhase.ShuttingDown].forEach(phase => {
this.instantiateByPhase(instantiationService, lifecycleService, phase);
});
}

View File

@@ -191,7 +191,32 @@ export class WorkbenchShell {
private onWorkbenchStarted(info: IWorkbenchStartedInfo, instantiationService: IInstantiationService): void {
// Telemetry: workspace info
// Startup Telemetry
this.logStartupTelemetry(info);
// Root Warning
if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) {
this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'."));
}
// Set lifecycle phase to `Runnning` so that other contributions can now do something
this.lifecycleService.phase = LifecyclePhase.Running;
// Set lifecycle phase to `Runnning For A Bit` after a short delay
let timeoutHandle = setTimeout(() => {
timeoutHandle = void 0;
this.lifecycleService.phase = LifecyclePhase.RunningForABit;
}, 3000);
this.toUnbind.push({
dispose: () => {
if (timeoutHandle) {
clearTimeout(timeoutHandle);
}
}
});
}
private logStartupTelemetry(info: IWorkbenchStartedInfo): void {
const { filesToOpen, filesToCreate, filesToDiff } = this.configuration;
/* __GDPR__
"workspaceLoad" : {
@@ -246,14 +271,6 @@ export class WorkbenchShell {
*/
this.telemetryService.publicLog('startupTime', this.timerService.startupMetrics);
});
// Root Warning
if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) {
this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'."));
}
// Set lifecycle phase to `Runnning` so that other contributions can now do something
this.lifecycleService.phase = LifecyclePhase.Running;
}
private initServiceCollection(container: HTMLElement): [IInstantiationService, ServiceCollection] {

View File

@@ -11,4 +11,4 @@ import { WorkspaceStats } from 'vs/workbench/parts/stats/node/workspaceStats';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
// Register Workspace Stats Contribution
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.Running);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.RunningForABit);