Merge from vscode 8a997f7321ae6612fc0e6eb3eac4f358a6233bfb

This commit is contained in:
ADS Merger
2020-02-11 07:08:19 +00:00
parent 0f934081e1
commit 085752f111
217 changed files with 2561 additions and 2063 deletions

View File

@@ -21,6 +21,8 @@ export class SharedProcess implements ISharedProcess {
private window: BrowserWindow | null = null;
private readonly _whenReady: Promise<void>;
constructor(
private readonly machineId: string,
private userEnv: NodeJS.ProcessEnv,
@@ -28,10 +30,13 @@ export class SharedProcess implements ISharedProcess {
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
@ILogService private readonly logService: ILogService,
@IThemeMainService private readonly themeMainService: IThemeMainService
) { }
) {
// overall ready promise when shared process signals initialization is done
this._whenReady = new Promise<void>(c => ipcMain.once('shared-process->electron-main: init-done', () => c(undefined)));
}
@memoize
private get _whenReady(): Promise<void> {
private get _whenIpcReady(): Promise<void> {
this.window = new BrowserWindow({
show: false,
backgroundColor: this.themeMainService.getBackgroundColor(),
@@ -98,16 +103,19 @@ export class SharedProcess implements ISharedProcess {
});
return new Promise<void>(c => {
const onHello = Event.once(Event.fromNodeEventEmitter(ipcMain, 'handshake:hello', ({ sender }: { sender: WebContents }) => sender));
disposables.add(onHello(sender => {
sender.send('handshake:hey there', {
// send payload once shared process is ready to receive it
disposables.add(Event.once(Event.fromNodeEventEmitter(ipcMain, 'shared-process->electron-main: ready-for-payload', ({ sender }: { sender: WebContents }) => sender))(sender => {
sender.send('electron-main->shared-process: payload', {
sharedIPCHandle: this.environmentService.sharedIPCHandle,
args: this.environmentService.args,
logLevel: this.logService.getLevel()
});
disposables.add(toDisposable(() => sender.send('handshake:goodbye')));
ipcMain.once('handshake:im ready', () => c(undefined));
// signal exit to shared process when we get disposed
disposables.add(toDisposable(() => sender.send('electron-main->shared-process: exit')));
// complete IPC-ready promise when shared process signals this to us
ipcMain.once('shared-process->electron-main: ipc-ready', () => c(undefined));
}));
});
}
@@ -122,6 +130,11 @@ export class SharedProcess implements ISharedProcess {
await this._whenReady;
}
async whenIpcReady(): Promise<void> {
await this.barrier.wait();
await this._whenIpcReady;
}
toggle(): void {
if (!this.window || this.window.isVisible()) {
this.hide();