提交 0c8cf08b 编写于 作者: B Benjamin Pasero

shared process - drop management service

上级 1caaf1b2
......@@ -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);
......
......@@ -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]);
......
......@@ -137,6 +137,7 @@ export interface ICommonNativeHostService {
// Development
openDevTools(options?: OpenDevToolsOptions): Promise<void>;
toggleDevTools(): Promise<void>;
toggleSharedProcessWindow(): Promise<void>;
sendInputEvent(event: MouseInputEvent): Promise<void>;
// Connectivity
......
......@@ -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<ICommonNativeHostService, Promise<unknown> /* 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<void> {
return this.sharedProcess.toggle();
}
//#endregion
//#region Registry (windows)
......
/*---------------------------------------------------------------------------------------------
* 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<ISharedProcessManagementService>('sharedProcessManagement');
export interface ISharedProcessManagementService {
readonly _serviceBrand: undefined;
whenReady(): Promise<void>;
toggleWindow(): Promise<void>;
}
/*---------------------------------------------------------------------------------------------
* 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<ISharedProcessManagementMainService>('sharedProcessManagementMainService');
export interface ISharedProcessManagementMainService extends ISharedProcessManagementService { }
export class SharedProcessManagementMainService implements ISharedProcessManagementMainService {
declare readonly _serviceBrand: undefined;
constructor(private sharedProcess: ISharedProcess) { }
whenReady(): Promise<void> {
return this.sharedProcess.whenReady();
}
async toggleWindow(): Promise<void> {
return this.sharedProcess.toggle();
}
}
......@@ -8,11 +8,6 @@ import { LogLevel } from 'vs/platform/log/common/log';
export interface ISharedProcess {
/**
* Signals the shared process has finished initialization.
*/
whenReady(): Promise<void>;
/**
* Toggles the visibility of the otherwise hidden
* shared process window.
......
......@@ -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<void> {
return accessor.get(ISharedProcessManagementService).toggleWindow();
return accessor.get(INativeHostService).toggleSharedProcessWindow();
}
}
/*---------------------------------------------------------------------------------------------
* 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<ISharedProcessManagementService>(mainProcessService.getChannel('sharedProcessManagement'));
}
}
registerSingleton(ISharedProcessManagementService, SharedProcessManagementService, true);
......@@ -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<MessagePortClient>;
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<MessagePortClient> {
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();
......
......@@ -222,6 +222,7 @@ export class TestNativeHostService implements INativeHostService {
async exit(code: number): Promise<void> { }
async openDevTools(options?: Electron.OpenDevToolsOptions | undefined): Promise<void> { }
async toggleDevTools(): Promise<void> { }
async toggleSharedProcessWindow(): Promise<void> { }
async resolveProxy(url: string): Promise<string | undefined> { return undefined; }
async readClipboardText(type?: 'selection' | 'clipboard' | undefined): Promise<string> { return ''; }
async writeClipboardText(text: string, type?: 'selection' | 'clipboard' | undefined): Promise<void> { }
......
......@@ -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';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册