提交 55e10fd7 编写于 作者: B Benjamin Pasero

shared process - introduce a separate service for management

上级 c082930a
...@@ -68,7 +68,7 @@ import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsSer ...@@ -68,7 +68,7 @@ import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsSer
import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc'; import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc';
import { ElectronExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/electron-main/extensionHostDebugIpc'; import { ElectronExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/electron-main/extensionHostDebugIpc';
import { INativeHostMainService, NativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService'; import { INativeHostMainService, NativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService';
import { ISharedProcessMainService, SharedProcessMainService } from 'vs/platform/sharedProcess/electron-main/sharedProcessMainService'; import { ISharedProcessManagementMainService, SharedProcessManagementMainService } from 'vs/platform/sharedProcess/electron-main/sharedProcessManagementMainService';
import { IDialogMainService, DialogMainService } from 'vs/platform/dialogs/electron-main/dialogMainService'; import { IDialogMainService, DialogMainService } from 'vs/platform/dialogs/electron-main/dialogMainService';
import { withNullAsUndefined } from 'vs/base/common/types'; import { withNullAsUndefined } from 'vs/base/common/types';
import { mnemonicButtonLabel, getPathLabel } from 'vs/base/common/labels'; import { mnemonicButtonLabel, getPathLabel } from 'vs/base/common/labels';
...@@ -509,7 +509,7 @@ export class CodeApplication extends Disposable { ...@@ -509,7 +509,7 @@ export class CodeApplication extends Disposable {
services.set(IWindowsMainService, new SyncDescriptor(WindowsMainService, [machineId, this.userEnv])); services.set(IWindowsMainService, new SyncDescriptor(WindowsMainService, [machineId, this.userEnv]));
services.set(IDialogMainService, new SyncDescriptor(DialogMainService)); services.set(IDialogMainService, new SyncDescriptor(DialogMainService));
services.set(ISharedProcessMainService, new SyncDescriptor(SharedProcessMainService, [sharedProcess])); services.set(ISharedProcessManagementMainService, new SyncDescriptor(SharedProcessManagementMainService, [sharedProcess]));
services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService)); services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService));
services.set(IDiagnosticsService, createChannelSender(getDelayedChannel(sharedProcessReady.then(client => client.getChannel('diagnostics'))))); services.set(IDiagnosticsService, createChannelSender(getDelayedChannel(sharedProcessReady.then(client => client.getChannel('diagnostics')))));
...@@ -621,9 +621,9 @@ export class CodeApplication extends Disposable { ...@@ -621,9 +621,9 @@ export class CodeApplication extends Disposable {
electronIpcServer.registerChannel('nativeHost', nativeHostChannel); electronIpcServer.registerChannel('nativeHost', nativeHostChannel);
sharedProcessClient.then(client => client.registerChannel('nativeHost', nativeHostChannel)); sharedProcessClient.then(client => client.registerChannel('nativeHost', nativeHostChannel));
const sharedProcessMainService = accessor.get(ISharedProcessMainService); const sharedProcessMainManagementService = accessor.get(ISharedProcessManagementMainService);
const sharedProcessChannel = createChannelReceiver(sharedProcessMainService); const sharedProcessManagementChannel = createChannelReceiver(sharedProcessMainManagementService);
electronIpcServer.registerChannel('sharedProcess', sharedProcessChannel); electronIpcServer.registerChannel('sharedProcessManagement', sharedProcessManagementChannel);
const workspacesService = accessor.get(IWorkspacesService); const workspacesService = accessor.get(IWorkspacesService);
const workspacesChannel = createChannelReceiver(workspacesService); const workspacesChannel = createChannelReceiver(workspacesService);
......
...@@ -5,14 +5,13 @@ ...@@ -5,14 +5,13 @@
import { BrowserWindow, ipcMain, Event, MessagePortMain } from 'electron'; import { BrowserWindow, ipcMain, Event, MessagePortMain } from 'electron';
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
import { ISharedProcess } from 'vs/platform/sharedProcess/electron-main/sharedProcessMainService';
import { Barrier } from 'vs/base/common/async'; import { Barrier } from 'vs/base/common/async';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService'; import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService';
import { FileAccess } from 'vs/base/common/network'; import { FileAccess } from 'vs/base/common/network';
import { browserCodeLoadingCacheStrategy } from 'vs/base/common/platform'; import { browserCodeLoadingCacheStrategy } from 'vs/base/common/platform';
import { ISharedProcessConfiguration } from 'vs/platform/sharedProcess/node/sharedProcess'; import { ISharedProcess, ISharedProcessConfiguration } from 'vs/platform/sharedProcess/node/sharedProcess';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { connect as connectMessagePort } from 'vs/base/parts/ipc/electron-main/ipc.mp'; import { connect as connectMessagePort } from 'vs/base/parts/ipc/electron-main/ipc.mp';
import { assertIsDefined } from 'vs/base/common/types'; import { assertIsDefined } from 'vs/base/common/types';
......
/*---------------------------------------------------------------------------------------------
* 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>;
}
...@@ -4,24 +4,14 @@ ...@@ -4,24 +4,14 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; 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 ISharedProcessMainService = createDecorator<ISharedProcessMainService>('sharedProcessMainService'); export const ISharedProcessManagementMainService = createDecorator<ISharedProcessManagementMainService>('sharedProcessManagementMainService');
export interface ISharedProcessMainService { export interface ISharedProcessManagementMainService extends ISharedProcessManagementService { }
readonly _serviceBrand: undefined; export class SharedProcessManagementMainService implements ISharedProcessManagementMainService {
whenReady(): Promise<void>;
toggleWindow(): Promise<void>;
}
export interface ISharedProcess {
whenReady(): Promise<void>;
toggle(): void;
}
export class SharedProcessMainService implements ISharedProcessMainService {
declare readonly _serviceBrand: undefined; declare readonly _serviceBrand: undefined;
......
...@@ -6,6 +6,20 @@ ...@@ -6,6 +6,20 @@
import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
import { LogLevel } from 'vs/platform/log/common/log'; 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.
*/
toggle(): void;
}
export interface ISharedProcessConfiguration { export interface ISharedProcessConfiguration {
readonly machineId: string; readonly machineId: string;
readonly windowId: number; readonly windowId: number;
......
/*---------------------------------------------------------------------------------------------
* 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);
...@@ -8,7 +8,6 @@ import { IpcRendererEvent } from 'vs/base/parts/sandbox/electron-sandbox/electro ...@@ -8,7 +8,6 @@ import { IpcRendererEvent } from 'vs/base/parts/sandbox/electron-sandbox/electro
import { ipcRenderer } from 'vs/base/parts/sandbox/electron-sandbox/globals'; import { ipcRenderer } from 'vs/base/parts/sandbox/electron-sandbox/globals';
import { Client as MessagePortClient } from 'vs/base/parts/ipc/common/ipc.mp'; import { Client as MessagePortClient } from 'vs/base/parts/ipc/common/ipc.mp';
import { IChannel, IServerChannel, getDelayedChannel } from 'vs/base/parts/ipc/common/ipc'; import { IChannel, IServerChannel, getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService';
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService'; import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native'; import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
...@@ -16,16 +15,16 @@ import { generateUuid } from 'vs/base/common/uuid'; ...@@ -16,16 +15,16 @@ import { generateUuid } from 'vs/base/common/uuid';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { ISharedProcessManagementService } from 'vs/platform/sharedProcess/common/sharedProcessManagement';
export class SharedProcessService extends Disposable implements ISharedProcessService { export class SharedProcessService extends Disposable implements ISharedProcessService {
declare readonly _serviceBrand: undefined; declare readonly _serviceBrand: undefined;
private readonly sharedProcessMainChannel = this.mainProcessService.getChannel('sharedProcess');
private readonly withSharedProcessConnection: Promise<MessagePortClient>; private readonly withSharedProcessConnection: Promise<MessagePortClient>;
constructor( constructor(
@IMainProcessService private readonly mainProcessService: IMainProcessService, @ISharedProcessManagementService private readonly sharedProcessManagementService: ISharedProcessManagementService,
@INativeHostService private readonly nativeHostService: INativeHostService, @INativeHostService private readonly nativeHostService: INativeHostService,
@ILogService private readonly logService: ILogService, @ILogService private readonly logService: ILogService,
@ILifecycleService private readonly lifecycleService: ILifecycleService @ILifecycleService private readonly lifecycleService: ILifecycleService
...@@ -47,7 +46,7 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe ...@@ -47,7 +46,7 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe
this.logService.trace('Workbench->SharedProcess#connect'); this.logService.trace('Workbench->SharedProcess#connect');
// await the shared process to be ready // await the shared process to be ready
await this.sharedProcessMainChannel.call('whenReady'); await this.sharedProcessManagementService.whenReady();
// Ask to create message channel inside the window // Ask to create message channel inside the window
// and send over a UUID to correlate the response // and send over a UUID to correlate the response
...@@ -74,7 +73,7 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe ...@@ -74,7 +73,7 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe
} }
toggleWindow(): Promise<void> { toggleWindow(): Promise<void> {
return this.sharedProcessMainChannel.call('toggleWindow'); return this.sharedProcessManagementService.toggleWindow();
} }
} }
......
...@@ -78,6 +78,7 @@ import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncService' ...@@ -78,6 +78,7 @@ import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncService'
import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncAccountService'; import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncAccountService';
import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncStoreManagementService'; import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncStoreManagementService';
import 'vs/workbench/services/userDataSync/electron-browser/userDataAutoSyncService'; 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/sharedProcess/electron-browser/sharedProcessService';
import 'vs/workbench/services/localizations/electron-browser/localizationsService'; import 'vs/workbench/services/localizations/electron-browser/localizationsService';
import 'vs/workbench/services/diagnostics/electron-browser/diagnosticsService'; 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.
先完成此消息的编辑!
想要评论请 注册