diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index d66e79001f6..6368fd90f03 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -68,7 +68,6 @@ import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsSer import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc'; import { ElectronExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/electron-main/extensionHostDebugIpc'; import { INativeHostMainService, NativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService'; -import { ISharedProcessManagementMainService, SharedProcessManagementMainService } from 'vs/platform/sharedProcess/electron-main/sharedProcessManagementMainService'; import { IDialogMainService, DialogMainService } from 'vs/platform/dialogs/electron-main/dialogMainService'; import { withNullAsUndefined } from 'vs/base/common/types'; import { mnemonicButtonLabel, getPathLabel } from 'vs/base/common/labels'; @@ -509,7 +508,6 @@ export class CodeApplication extends Disposable { services.set(IWindowsMainService, new SyncDescriptor(WindowsMainService, [machineId, this.userEnv])); services.set(IDialogMainService, new SyncDescriptor(DialogMainService)); - services.set(ISharedProcessManagementMainService, new SyncDescriptor(SharedProcessManagementMainService, [sharedProcess])); services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService)); services.set(IDiagnosticsService, createChannelSender(getDelayedChannel(sharedProcessReady.then(client => client.getChannel('diagnostics'))))); @@ -517,7 +515,7 @@ export class CodeApplication extends Disposable { services.set(IEncryptionMainService, new SyncDescriptor(EncryptionMainService, [machineId])); services.set(IKeyboardLayoutMainService, new SyncDescriptor(KeyboardLayoutMainService)); services.set(IDisplayMainService, new SyncDescriptor(DisplayMainService)); - services.set(INativeHostMainService, new SyncDescriptor(NativeHostMainService)); + services.set(INativeHostMainService, new SyncDescriptor(NativeHostMainService, [sharedProcess])); services.set(IWebviewManagerService, new SyncDescriptor(WebviewMainService)); services.set(IWorkspacesService, new SyncDescriptor(WorkspacesService)); services.set(IMenubarMainService, new SyncDescriptor(MenubarMainService)); @@ -621,10 +619,6 @@ export class CodeApplication extends Disposable { electronIpcServer.registerChannel('nativeHost', nativeHostChannel); sharedProcessClient.then(client => client.registerChannel('nativeHost', nativeHostChannel)); - const sharedProcessMainManagementService = accessor.get(ISharedProcessManagementMainService); - const sharedProcessManagementChannel = createChannelReceiver(sharedProcessMainManagementService); - electronIpcServer.registerChannel('sharedProcessManagement', sharedProcessManagementChannel); - const workspacesService = accessor.get(IWorkspacesService); const workspacesChannel = createChannelReceiver(workspacesService); electronIpcServer.registerChannel('workspaces', workspacesChannel); diff --git a/src/vs/code/electron-main/sharedProcess.ts b/src/vs/code/electron-main/sharedProcess.ts index 860659ba871..3e6ce1e6dda 100644 --- a/src/vs/code/electron-main/sharedProcess.ts +++ b/src/vs/code/electron-main/sharedProcess.ts @@ -41,10 +41,15 @@ export class SharedProcess extends Disposable implements ISharedProcess { // Lifecycle this._register(this.lifecycleMainService.onWillShutdown(() => this.onWillShutdown())); - // Shared process connections + // Shared process connections from workbench windows ipcMain.on('vscode:createSharedProcessMessageChannel', async (e, nonce: string) => { this.logService.trace('SharedProcess: on vscode:createSharedProcessMessageChannel'); + // await the shared process to be overall ready + // we do not just wait for IPC ready because the + // workbench window will communicate directly + await this.whenReady(); + const port = await this.connect(); e.sender.postMessage('vscode:createSharedProcessMessageChannelResult', nonce, [port]); diff --git a/src/vs/platform/native/common/native.ts b/src/vs/platform/native/common/native.ts index e51b3ac0e22..2c8414ba871 100644 --- a/src/vs/platform/native/common/native.ts +++ b/src/vs/platform/native/common/native.ts @@ -137,6 +137,7 @@ export interface ICommonNativeHostService { // Development openDevTools(options?: OpenDevToolsOptions): Promise; toggleDevTools(): Promise; + toggleSharedProcessWindow(): Promise; sendInputEvent(event: MouseInputEvent): Promise; // Connectivity diff --git a/src/vs/platform/native/electron-main/nativeHostMainService.ts b/src/vs/platform/native/electron-main/nativeHostMainService.ts index 58318253150..9869c2c8950 100644 --- a/src/vs/platform/native/electron-main/nativeHostMainService.ts +++ b/src/vs/platform/native/electron-main/nativeHostMainService.ts @@ -27,6 +27,7 @@ import { dirname, join } from 'vs/base/common/path'; import product from 'vs/platform/product/common/product'; import { memoize } from 'vs/base/common/decorators'; import { Disposable } from 'vs/base/common/lifecycle'; +import { ISharedProcess } from 'vs/platform/sharedProcess/node/sharedProcess'; export interface INativeHostMainService extends AddFirstParameterToFunctions /* only methods, not events */, number | undefined /* window ID */> { } @@ -42,6 +43,7 @@ export class NativeHostMainService extends Disposable implements INativeHostMain declare readonly _serviceBrand: undefined; constructor( + private sharedProcess: ISharedProcess, @IWindowsMainService private readonly windowsMainService: IWindowsMainService, @IDialogMainService private readonly dialogMainService: IDialogMainService, @ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService, @@ -628,6 +630,10 @@ export class NativeHostMainService extends Disposable implements INativeHostMain } } + async toggleSharedProcessWindow(): Promise { + return this.sharedProcess.toggle(); + } + //#endregion //#region Registry (windows) diff --git a/src/vs/platform/sharedProcess/common/sharedProcessManagement.ts b/src/vs/platform/sharedProcess/common/sharedProcessManagement.ts deleted file mode 100644 index 4a24d9ca0cb..00000000000 --- a/src/vs/platform/sharedProcess/common/sharedProcessManagement.ts +++ /dev/null @@ -1,17 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; - -export const ISharedProcessManagementService = createDecorator('sharedProcessManagement'); - -export interface ISharedProcessManagementService { - - readonly _serviceBrand: undefined; - - whenReady(): Promise; - - toggleWindow(): Promise; -} diff --git a/src/vs/platform/sharedProcess/electron-main/sharedProcessManagementMainService.ts b/src/vs/platform/sharedProcess/electron-main/sharedProcessManagementMainService.ts deleted file mode 100644 index 19cd18fd66d..00000000000 --- a/src/vs/platform/sharedProcess/electron-main/sharedProcessManagementMainService.ts +++ /dev/null @@ -1,27 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { ISharedProcess } from 'vs/platform/sharedProcess/node/sharedProcess'; -import { ISharedProcessManagementService } from 'vs/platform/sharedProcess/common/sharedProcessManagement'; - -export const ISharedProcessManagementMainService = createDecorator('sharedProcessManagementMainService'); - -export interface ISharedProcessManagementMainService extends ISharedProcessManagementService { } - -export class SharedProcessManagementMainService implements ISharedProcessManagementMainService { - - declare readonly _serviceBrand: undefined; - - constructor(private sharedProcess: ISharedProcess) { } - - whenReady(): Promise { - return this.sharedProcess.whenReady(); - } - - async toggleWindow(): Promise { - return this.sharedProcess.toggle(); - } -} diff --git a/src/vs/platform/sharedProcess/node/sharedProcess.ts b/src/vs/platform/sharedProcess/node/sharedProcess.ts index 94f992c15b5..f68bc60cb5f 100644 --- a/src/vs/platform/sharedProcess/node/sharedProcess.ts +++ b/src/vs/platform/sharedProcess/node/sharedProcess.ts @@ -8,11 +8,6 @@ import { LogLevel } from 'vs/platform/log/common/log'; export interface ISharedProcess { - /** - * Signals the shared process has finished initialization. - */ - whenReady(): Promise; - /** * Toggles the visibility of the otherwise hidden * shared process window. diff --git a/src/vs/workbench/electron-sandbox/actions/developerActions.ts b/src/vs/workbench/electron-sandbox/actions/developerActions.ts index 5b5a5c7b4a8..345e3490a08 100644 --- a/src/vs/workbench/electron-sandbox/actions/developerActions.ts +++ b/src/vs/workbench/electron-sandbox/actions/developerActions.ts @@ -9,7 +9,6 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic import { Action2, MenuId } from 'vs/platform/actions/common/actions'; import { CATEGORIES } from 'vs/workbench/common/actions'; import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; -import { ISharedProcessManagementService } from 'vs/platform/sharedProcess/common/sharedProcessManagement'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IsDevelopmentContext } from 'vs/platform/contextkey/common/contextkeys'; @@ -79,6 +78,6 @@ export class ToggleSharedProcessAction extends Action2 { } async run(accessor: ServicesAccessor): Promise { - return accessor.get(ISharedProcessManagementService).toggleWindow(); + return accessor.get(INativeHostService).toggleSharedProcessWindow(); } } diff --git a/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessManagementService.ts b/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessManagementService.ts deleted file mode 100644 index b4619d53ac3..00000000000 --- a/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessManagementService.ts +++ /dev/null @@ -1,23 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { createChannelSender } from 'vs/base/parts/ipc/common/ipc'; -import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService'; -import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; -import { ISharedProcessManagementService } from 'vs/platform/sharedProcess/common/sharedProcessManagement'; - -// @ts-ignore: interface is implemented via proxy -export class SharedProcessManagementService implements ISharedProcessManagementService { - - declare readonly _serviceBrand: undefined; - - constructor( - @IMainProcessService mainProcessService: IMainProcessService - ) { - return createChannelSender(mainProcessService.getChannel('sharedProcessManagement')); - } -} - -registerSingleton(ISharedProcessManagementService, SharedProcessManagementService, true); diff --git a/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts b/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts index a1962759d7f..924ca70d083 100644 --- a/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts +++ b/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts @@ -15,7 +15,6 @@ import { generateUuid } from 'vs/base/common/uuid'; import { ILogService } from 'vs/platform/log/common/log'; import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle'; -import { ISharedProcessManagementService } from 'vs/platform/sharedProcess/common/sharedProcessManagement'; export class SharedProcessService extends Disposable implements ISharedProcessService { @@ -24,7 +23,6 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe private readonly withSharedProcessConnection: Promise; constructor( - @ISharedProcessManagementService private readonly sharedProcessManagementService: ISharedProcessManagementService, @INativeHostService private readonly nativeHostService: INativeHostService, @ILogService private readonly logService: ILogService, @ILifecycleService private readonly lifecycleService: ILifecycleService @@ -45,9 +43,6 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe private async connect(): Promise { this.logService.trace('Workbench->SharedProcess#connect'); - // await the shared process to be ready - await this.sharedProcessManagementService.whenReady(); - // Ask to create message channel inside the window // and send over a UUID to correlate the response const nonce = generateUuid(); diff --git a/src/vs/workbench/test/electron-browser/workbenchTestServices.ts b/src/vs/workbench/test/electron-browser/workbenchTestServices.ts index 57946d6380b..ea7c53c0512 100644 --- a/src/vs/workbench/test/electron-browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/electron-browser/workbenchTestServices.ts @@ -222,6 +222,7 @@ export class TestNativeHostService implements INativeHostService { async exit(code: number): Promise { } async openDevTools(options?: Electron.OpenDevToolsOptions | undefined): Promise { } async toggleDevTools(): Promise { } + async toggleSharedProcessWindow(): Promise { } async resolveProxy(url: string): Promise { return undefined; } async readClipboardText(type?: 'selection' | 'clipboard' | undefined): Promise { return ''; } async writeClipboardText(text: string, type?: 'selection' | 'clipboard' | undefined): Promise { } diff --git a/src/vs/workbench/workbench.desktop.main.ts b/src/vs/workbench/workbench.desktop.main.ts index dfa931ce303..2daa6c23831 100644 --- a/src/vs/workbench/workbench.desktop.main.ts +++ b/src/vs/workbench/workbench.desktop.main.ts @@ -71,7 +71,6 @@ import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncService' import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncAccountService'; import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncStoreManagementService'; import 'vs/workbench/services/userDataSync/electron-browser/userDataAutoSyncService'; -import 'vs/workbench/services/sharedProcess/electron-browser/sharedProcessManagementService'; import 'vs/workbench/services/sharedProcess/electron-browser/sharedProcessService'; import 'vs/workbench/services/localizations/electron-browser/localizationsService'; import 'vs/workbench/services/diagnostics/electron-browser/diagnosticsService';