shared process - introduce a separate service for management
This commit is contained in:
parent
c082930a43
commit
55e10fd785
8 changed files with 70 additions and 27 deletions
|
@ -68,7 +68,7 @@ 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 { 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 { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { mnemonicButtonLabel, getPathLabel } from 'vs/base/common/labels';
|
||||
|
@ -509,7 +509,7 @@ export class CodeApplication extends Disposable {
|
|||
|
||||
services.set(IWindowsMainService, new SyncDescriptor(WindowsMainService, [machineId, this.userEnv]));
|
||||
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(IDiagnosticsService, createChannelSender(getDelayedChannel(sharedProcessReady.then(client => client.getChannel('diagnostics')))));
|
||||
|
||||
|
@ -621,9 +621,9 @@ export class CodeApplication extends Disposable {
|
|||
electronIpcServer.registerChannel('nativeHost', nativeHostChannel);
|
||||
sharedProcessClient.then(client => client.registerChannel('nativeHost', nativeHostChannel));
|
||||
|
||||
const sharedProcessMainService = accessor.get(ISharedProcessMainService);
|
||||
const sharedProcessChannel = createChannelReceiver(sharedProcessMainService);
|
||||
electronIpcServer.registerChannel('sharedProcess', sharedProcessChannel);
|
||||
const sharedProcessMainManagementService = accessor.get(ISharedProcessManagementMainService);
|
||||
const sharedProcessManagementChannel = createChannelReceiver(sharedProcessMainManagementService);
|
||||
electronIpcServer.registerChannel('sharedProcessManagement', sharedProcessManagementChannel);
|
||||
|
||||
const workspacesService = accessor.get(IWorkspacesService);
|
||||
const workspacesChannel = createChannelReceiver(workspacesService);
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
|
||||
import { BrowserWindow, ipcMain, Event, MessagePortMain } from 'electron';
|
||||
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 { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
|
||||
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService';
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
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 { connect as connectMessagePort } from 'vs/base/parts/ipc/electron-main/ipc.mp';
|
||||
import { assertIsDefined } from 'vs/base/common/types';
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
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;
|
||||
|
||||
whenReady(): Promise<void>;
|
||||
|
||||
toggleWindow(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface ISharedProcess {
|
||||
whenReady(): Promise<void>;
|
||||
toggle(): void;
|
||||
}
|
||||
|
||||
export class SharedProcessMainService implements ISharedProcessMainService {
|
||||
export class SharedProcessManagementMainService implements ISharedProcessManagementMainService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
|
@ -6,6 +6,20 @@
|
|||
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
|
||||
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 {
|
||||
readonly machineId: string;
|
||||
readonly windowId: number;
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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
|
|||
import { ipcRenderer } from 'vs/base/parts/sandbox/electron-sandbox/globals';
|
||||
import { Client as MessagePortClient } from 'vs/base/parts/ipc/common/ipc.mp';
|
||||
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 { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
|
||||
|
@ -16,16 +15,16 @@ 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 {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly sharedProcessMainChannel = this.mainProcessService.getChannel('sharedProcess');
|
||||
private readonly withSharedProcessConnection: Promise<MessagePortClient>;
|
||||
|
||||
constructor(
|
||||
@IMainProcessService private readonly mainProcessService: IMainProcessService,
|
||||
@ISharedProcessManagementService private readonly sharedProcessManagementService: ISharedProcessManagementService,
|
||||
@INativeHostService private readonly nativeHostService: INativeHostService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@ILifecycleService private readonly lifecycleService: ILifecycleService
|
||||
|
@ -47,7 +46,7 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe
|
|||
this.logService.trace('Workbench->SharedProcess#connect');
|
||||
|
||||
// await the shared process to be ready
|
||||
await this.sharedProcessMainChannel.call('whenReady');
|
||||
await this.sharedProcessManagementService.whenReady();
|
||||
|
||||
// Ask to create message channel inside the window
|
||||
// and send over a UUID to correlate the response
|
||||
|
@ -74,7 +73,7 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe
|
|||
}
|
||||
|
||||
toggleWindow(): Promise<void> {
|
||||
return this.sharedProcessMainChannel.call('toggleWindow');
|
||||
return this.sharedProcessManagementService.toggleWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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/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';
|
||||
|
|
Loading…
Reference in a new issue