sandbox - more renaming services towards utility

This commit is contained in:
Benjamin Pasero
2023-02-14 11:06:03 +01:00
parent 458f6882b6
commit 5ae661dbfc
10 changed files with 123 additions and 111 deletions
@@ -89,7 +89,7 @@ import { ISharedTunnelsService } from 'vs/platform/tunnel/common/tunnel';
import { SharedTunnelsService } from 'vs/platform/tunnel/node/tunnelService';
import { ipcSharedProcessTunnelChannelName, ISharedProcessTunnelService } from 'vs/platform/remote/common/sharedProcessTunnelService';
import { SharedProcessTunnelService } from 'vs/platform/tunnel/node/sharedProcessTunnelService';
import { ipcSharedProcessWorkerChannelName, ISharedProcessWorkerConfiguration, ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { ipcUtilityProcessWorkerChannelName, ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { SharedProcessWorkerService } from 'vs/platform/sharedProcess/electron-browser/sharedProcessWorkerService';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService';
@@ -116,6 +116,7 @@ import { ExtensionsContributions } from 'vs/code/electron-browser/sharedProcess/
import { ExtensionsProfileScannerService } from 'vs/platform/extensionManagement/electron-sandbox/extensionsProfileScannerService';
import { localize } from 'vs/nls';
import { LogService } from 'vs/platform/log/common/logService';
import { IUtilityProcessWorkerConfiguration } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
class SharedProcessMain extends Disposable {
@@ -148,12 +149,12 @@ class SharedProcessMain extends Disposable {
// application is shutting down anyways.
//
const eventName = 'vscode:electron-main->shared-process=disposeWorker';
const onDisposeWorker = (event: unknown, configuration: ISharedProcessWorkerConfiguration) => { this.onDisposeWorker(configuration); };
const onDisposeWorker = (event: unknown, configuration: IUtilityProcessWorkerConfiguration) => { this.onDisposeWorker(configuration); };
ipcRenderer.on(eventName, onDisposeWorker);
this._register(toDisposable(() => ipcRenderer.removeListener(eventName, onDisposeWorker)));
}
private onDisposeWorker(configuration: ISharedProcessWorkerConfiguration): void {
private onDisposeWorker(configuration: IUtilityProcessWorkerConfiguration): void {
this.sharedProcessWorkerService?.disposeWorker(configuration);
}
@@ -446,7 +447,7 @@ class SharedProcessMain extends Disposable {
// Worker
const sharedProcessWorkerChannel = ProxyChannel.fromService(accessor.get(ISharedProcessWorkerService));
this.server.registerChannel(ipcSharedProcessWorkerChannelName, sharedProcessWorkerChannel);
this.server.registerChannel(ipcUtilityProcessWorkerChannelName, sharedProcessWorkerChannel);
// Remote Tunnel
const remoteTunnelChannel = ProxyChannel.fromService(accessor.get(IRemoteTunnelService));
+2 -2
View File
@@ -114,7 +114,7 @@ import { ILoggerMainService } from 'vs/platform/log/electron-main/loggerService'
import { IInitialProtocolUrls, IProtocolUrl } from 'vs/platform/url/electron-main/url';
import { massageMessageBoxOptions } from 'vs/platform/dialogs/common/dialogs';
import { IUtilityProcessWorkerMainService, UtilityProcessWorkerMainService } from 'vs/platform/utilityProcess/electron-main/utilityProcessWorkerMainService';
import { ipcSharedProcessWorkerChannelName } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { ipcUtilityProcessWorkerChannelName } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
/**
* The main VS Code application. There will only ever be one instance,
@@ -1076,7 +1076,7 @@ export class CodeApplication extends Disposable {
// Utility Process Worker
const utilityProcessWorkerChannel = ProxyChannel.fromService(accessor.get(IUtilityProcessWorkerMainService));
mainProcessElectronServer.registerChannel(ipcSharedProcessWorkerChannelName, utilityProcessWorkerChannel);
mainProcessElectronServer.registerChannel(ipcUtilityProcessWorkerChannelName, utilityProcessWorkerChannel);
}
private async openFirstWindow(accessor: ServicesAccessor, initialProtocolUrls: IInitialProtocolUrls | undefined): Promise<ICodeWindow[]> {
@@ -5,79 +5,14 @@
import { hash as hashObject } from 'vs/base/common/hash';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export interface ISharedProcessWorkerProcess {
/**
* The module to load as child process into the worker.
*/
moduleId: string;
/**
* The type of the process appears in the arguments of the
* forked process to identify it easier.
*/
type: string;
}
export interface IOnDidTerminateSharedProcessWorkerProcess {
/**
* More information around how the shared process worker
* process terminated. Will be `undefined` in case the
* worker process was terminated normally via APIs
* and will be defined in case the worker process
* terminated on its own, either unexpectedly or
* because it finished.
*/
reason?: ISharedProcessWorkerProcessExit;
}
export interface ISharedProcessWorkerProcessExit {
/**
* The shared process worker process exit code if known.
*/
code?: number;
/**
* The shared process worker process exit signal if known.
*/
signal?: string;
}
export interface ISharedProcessWorkerConfiguration {
/**
* Configuration specific to the process to fork.
*/
process: ISharedProcessWorkerProcess;
/**
* Configuration specific for how to respond with the
* communication message port to the receiver window.
*/
reply: {
windowId: number;
channel?: string;
nonce?: string;
};
}
export interface ISharedProcessWorkerCreateConfiguration extends ISharedProcessWorkerConfiguration {
reply: {
windowId: number;
channel: string;
nonce: string;
};
}
import { IOnDidTerminateUtilityrocessWorkerProcess, IUtilityProcessWorkerConfiguration, IUtilityProcessWorkerCreateConfiguration } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
/**
* Converts the process configuration into a hash to
* identify processes of the same kind by taking those
* components that make the process and reply unique.
*/
export function hash(configuration: ISharedProcessWorkerConfiguration): number {
export function hash(configuration: IUtilityProcessWorkerConfiguration): number {
return hashObject({
moduleId: configuration.process.moduleId,
windowId: configuration.reply.windowId
@@ -86,7 +21,7 @@ export function hash(configuration: ISharedProcessWorkerConfiguration): number {
export const ISharedProcessWorkerService = createDecorator<ISharedProcessWorkerService>('sharedProcessWorkerService');
export const ipcSharedProcessWorkerChannelName = 'sharedProcessWorker';
export const ipcUtilityProcessWorkerChannelName = 'sharedProcessWorker';
export interface ISharedProcessWorkerService {
@@ -116,10 +51,10 @@ export interface ISharedProcessWorkerService {
* about the termination that can be used to figure out if the termination was unexpected
* or not and whether the worker needs to be restarted.
*/
createWorker(configuration: ISharedProcessWorkerCreateConfiguration): Promise<IOnDidTerminateSharedProcessWorkerProcess>;
createWorker(configuration: IUtilityProcessWorkerCreateConfiguration): Promise<IOnDidTerminateUtilityrocessWorkerProcess>;
/**
* Terminates the process for the provided configuration if any.
*/
disposeWorker(configuration: ISharedProcessWorkerConfiguration): Promise<void>;
disposeWorker(configuration: IUtilityProcessWorkerConfiguration): Promise<void>;
}
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ISharedProcessWorkerConfiguration } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { IUtilityProcessWorkerConfiguration } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
export enum SharedProcessWorkerMessages {
@@ -37,11 +37,11 @@ interface IBaseMessage {
}
export interface ISharedProcessToWorkerMessage extends IBaseMessage {
configuration: ISharedProcessWorkerConfiguration;
configuration: IUtilityProcessWorkerConfiguration;
environment?: ISharedProcessWorkerEnvironment;
}
export interface IWorkerToSharedProcessMessage extends IBaseMessage {
configuration?: ISharedProcessWorkerConfiguration;
configuration?: IUtilityProcessWorkerConfiguration;
message?: string;
}
@@ -13,8 +13,9 @@ import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle'
import { deepClone } from 'vs/base/common/objects';
import { withNullAsUndefined } from 'vs/base/common/types';
import { removeDangerousEnvVariables } from 'vs/base/common/processes';
import { hash, ISharedProcessWorkerConfiguration, ISharedProcessWorkerProcessExit } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { hash } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { SharedProcessWorkerMessages, ISharedProcessToWorkerMessage, ISharedProcessWorkerEnvironment, IWorkerToSharedProcessMessage } from 'vs/platform/sharedProcess/electron-browser/sharedProcessWorker';
import { IUtilityProcessWorkerConfiguration, IUtilityProcessWorkerProcessExit } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
/**
* The `create` function needs to be there by convention because
@@ -65,7 +66,7 @@ class SharedProcessWorkerMain {
}
}
private spawn(port: MessagePort, configuration: ISharedProcessWorkerConfiguration, environment: ISharedProcessWorkerEnvironment): void {
private spawn(port: MessagePort, configuration: IUtilityProcessWorkerConfiguration, environment: ISharedProcessWorkerEnvironment): void {
try {
// Ensure to terminate any existing process for config
@@ -100,7 +101,7 @@ class SharedProcessWorkerMain {
}
}
private terminate(configuration: ISharedProcessWorkerConfiguration): void {
private terminate(configuration: IUtilityProcessWorkerConfiguration): void {
const processDisposable = this.processes.get(hash(configuration));
processDisposable?.dispose();
}
@@ -108,14 +109,14 @@ class SharedProcessWorkerMain {
class SharedProcessWorkerProcess extends Disposable {
private readonly _onDidProcessSelfTerminate = this._register(new Emitter<ISharedProcessWorkerProcessExit>());
private readonly _onDidProcessSelfTerminate = this._register(new Emitter<IUtilityProcessWorkerProcessExit>());
readonly onDidProcessSelfTerminate = this._onDidProcessSelfTerminate.event;
private child: ChildProcess | undefined = undefined;
constructor(
private readonly port: MessagePort,
private readonly configuration: ISharedProcessWorkerConfiguration,
private readonly configuration: IUtilityProcessWorkerConfiguration,
private readonly environment: ISharedProcessWorkerEnvironment
) {
super();
@@ -11,8 +11,9 @@ import { Disposable } from 'vs/base/common/lifecycle';
import { FileAccess } from 'vs/base/common/network';
import { generateUuid } from 'vs/base/common/uuid';
import { ILogService } from 'vs/platform/log/common/log';
import { hash, IOnDidTerminateSharedProcessWorkerProcess, ISharedProcessWorkerConfiguration, ISharedProcessWorkerCreateConfiguration, ISharedProcessWorkerProcessExit, ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { hash, ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { SharedProcessWorkerMessages, ISharedProcessToWorkerMessage, IWorkerToSharedProcessMessage } from 'vs/platform/sharedProcess/electron-browser/sharedProcessWorker';
import { IUtilityProcessWorkerProcessExit, IOnDidTerminateUtilityrocessWorkerProcess, IUtilityProcessWorkerCreateConfiguration, IUtilityProcessWorkerConfiguration } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
export class SharedProcessWorkerService implements ISharedProcessWorkerService {
@@ -20,15 +21,15 @@ export class SharedProcessWorkerService implements ISharedProcessWorkerService {
private readonly workers = new Map<string /* process module ID */, Promise<SharedProcessWebWorker>>();
private readonly processeDisposables = new Map<number /* process configuration hash */, (reason?: ISharedProcessWorkerProcessExit) => void>();
private readonly processResolvers = new Map<number /* process configuration hash */, (process: IOnDidTerminateSharedProcessWorkerProcess) => void>();
private readonly processeDisposables = new Map<number /* process configuration hash */, (reason?: IUtilityProcessWorkerProcessExit) => void>();
private readonly processResolvers = new Map<number /* process configuration hash */, (process: IOnDidTerminateUtilityrocessWorkerProcess) => void>();
constructor(
@ILogService private readonly logService: ILogService
) {
}
async createWorker(configuration: ISharedProcessWorkerCreateConfiguration): Promise<IOnDidTerminateSharedProcessWorkerProcess> {
async createWorker(configuration: IUtilityProcessWorkerCreateConfiguration): Promise<IOnDidTerminateUtilityrocessWorkerProcess> {
const workerLogId = `window: ${configuration.reply.windowId}, moduleId: ${configuration.process.moduleId}`;
this.logService.trace(`SharedProcess: createWorker (${workerLogId})`);
@@ -47,7 +48,7 @@ export class SharedProcessWorkerService implements ISharedProcessWorkerService {
let workerPort: MessagePort | undefined = undefined;
// Store as process for termination support
this.processeDisposables.set(configurationHash, (reason?: ISharedProcessWorkerProcessExit) => {
this.processeDisposables.set(configurationHash, (reason?: IUtilityProcessWorkerProcessExit) => {
// Signal to token
cts.dispose(true);
@@ -75,7 +76,7 @@ export class SharedProcessWorkerService implements ISharedProcessWorkerService {
// Keep a promise that will resolve in the future when the
// underlying process terminates.
const onDidTerminate = new Promise<IOnDidTerminateSharedProcessWorkerProcess>(resolve => {
const onDidTerminate = new Promise<IOnDidTerminateUtilityrocessWorkerProcess>(resolve => {
this.processResolvers.set(configurationHash, resolve);
});
@@ -106,7 +107,7 @@ export class SharedProcessWorkerService implements ISharedProcessWorkerService {
return onDidTerminate;
}
private getOrCreateWebWorker(configuration: ISharedProcessWorkerConfiguration): Promise<SharedProcessWebWorker> {
private getOrCreateWebWorker(configuration: IUtilityProcessWorkerConfiguration): Promise<SharedProcessWebWorker> {
// keep 1 web-worker per process module id to reduce
// the overall number of web workers while still
@@ -133,11 +134,11 @@ export class SharedProcessWorkerService implements ISharedProcessWorkerService {
return webWorkerPromise;
}
async disposeWorker(configuration: ISharedProcessWorkerConfiguration): Promise<void> {
async disposeWorker(configuration: IUtilityProcessWorkerConfiguration): Promise<void> {
return this.doDisposeWorker(configuration);
}
private doDisposeWorker(configuration: ISharedProcessWorkerConfiguration, reason?: ISharedProcessWorkerProcessExit): void {
private doDisposeWorker(configuration: IUtilityProcessWorkerConfiguration, reason?: IUtilityProcessWorkerProcessExit): void {
const processDisposable = this.processeDisposables.get(hash(configuration));
if (processDisposable) {
this.logService.trace(`SharedProcess: disposeWorker (window: ${configuration.reply.windowId}, moduleId: ${configuration.process.moduleId})`);
@@ -149,7 +150,7 @@ export class SharedProcessWorkerService implements ISharedProcessWorkerService {
class SharedProcessWebWorker extends Disposable {
private readonly _onDidProcessSelfTerminate = this._register(new Emitter<{ configuration: ISharedProcessWorkerConfiguration; reason: ISharedProcessWorkerProcessExit }>());
private readonly _onDidProcessSelfTerminate = this._register(new Emitter<{ configuration: IUtilityProcessWorkerConfiguration; reason: IUtilityProcessWorkerProcessExit }>());
readonly onDidProcessSelfTerminate = this._onDidProcessSelfTerminate.event;
private readonly workerReady: Promise<Worker> = this.doInit();
@@ -276,7 +277,7 @@ class SharedProcessWebWorker extends Disposable {
});
}
spawn(configuration: ISharedProcessWorkerConfiguration, port: MessagePort, token: CancellationToken): Promise<void> {
spawn(configuration: IUtilityProcessWorkerConfiguration, port: MessagePort, token: CancellationToken): Promise<void> {
const workerMessage: ISharedProcessToWorkerMessage = {
id: SharedProcessWorkerMessages.Spawn,
configuration,
@@ -288,7 +289,7 @@ class SharedProcessWebWorker extends Disposable {
return this.send(workerMessage, token, port);
}
terminate(configuration: ISharedProcessWorkerConfiguration, token: CancellationToken): Promise<void> {
terminate(configuration: IUtilityProcessWorkerConfiguration, token: CancellationToken): Promise<void> {
const workerMessage: ISharedProcessToWorkerMessage = {
id: SharedProcessWorkerMessages.Terminate,
configuration
@@ -18,7 +18,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import product from 'vs/platform/product/common/product';
import { IProtocolMainService } from 'vs/platform/protocol/electron-main/protocol';
import { ISharedProcess, ISharedProcessConfiguration } from 'vs/platform/sharedProcess/node/sharedProcess';
import { ISharedProcessWorkerConfiguration } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { IUtilityProcessWorkerConfiguration } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService';
import { WindowError } from 'vs/platform/window/electron-main/window';
import { toErrorMessage } from 'vs/base/common/errorMessage';
@@ -59,7 +59,7 @@ export class SharedProcess extends Disposable implements ISharedProcess {
validatedIpcMain.on('vscode:createSharedProcessMessageChannel', (e, nonce: string) => this.onWindowConnection(e, nonce));
// Shared process worker relay
validatedIpcMain.on('vscode:relaySharedProcessWorkerMessageChannel', (e, configuration: ISharedProcessWorkerConfiguration) => this.onWorkerConnection(e, configuration));
validatedIpcMain.on('vscode:relaySharedProcessWorkerMessageChannel', (e, configuration: IUtilityProcessWorkerConfiguration) => this.onWorkerConnection(e, configuration));
// Lifecycle
this._register(this.lifecycleMainService.onWillShutdown(() => this.onWillShutdown()));
@@ -93,7 +93,7 @@ export class SharedProcess extends Disposable implements ISharedProcess {
e.sender.postMessage('vscode:createSharedProcessMessageChannelResult', nonce, [port]);
}
private onWorkerConnection(e: IpcMainEvent, configuration: ISharedProcessWorkerConfiguration): void {
private onWorkerConnection(e: IpcMainEvent, configuration: IUtilityProcessWorkerConfiguration): void {
this.logService.trace('SharedProcess: onWorkerConnection', configuration);
const disposables = new DisposableStore();
@@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export interface IUtilityProcessWorkerProcess {
/**
* The module to load as child process into the worker.
*/
moduleId: string;
/**
* The type of the process appears in the arguments of the
* forked process to identify it easier.
*/
type: string;
}
export interface IOnDidTerminateUtilityrocessWorkerProcess {
/**
* More information around how the utility process worker
* process terminated. Will be `undefined` in case the
* worker process was terminated normally via APIs
* and will be defined in case the worker process
* terminated on its own, either unexpectedly or
* because it finished.
*/
reason?: IUtilityProcessWorkerProcessExit;
}
export interface IUtilityProcessWorkerProcessExit {
/**
* The utility process worker process exit code if known.
*/
code?: number;
/**
* The utility process worker process exit signal if known.
*/
signal?: string;
}
export interface IUtilityProcessWorkerConfiguration {
/**
* Configuration specific to the process to fork.
*/
process: IUtilityProcessWorkerProcess;
/**
* Configuration specific for how to respond with the
* communication message port to the receiver window.
*/
reply: {
windowId: number;
channel?: string;
nonce?: string;
};
}
export interface IUtilityProcessWorkerCreateConfiguration extends IUtilityProcessWorkerConfiguration {
reply: {
windowId: number;
channel: string;
nonce: string;
};
}
export const ipcUtilityProcessWorkerChannelName = 'sharedProcessWorker';
@@ -6,7 +6,8 @@
import { Disposable } from 'vs/base/common/lifecycle';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { IOnDidTerminateSharedProcessWorkerProcess, ISharedProcessWorkerConfiguration, ISharedProcessWorkerCreateConfiguration, ISharedProcessWorkerProcessExit, ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { IUtilityProcessWorkerCreateConfiguration, IOnDidTerminateUtilityrocessWorkerProcess, IUtilityProcessWorkerConfiguration, IUtilityProcessWorkerProcessExit } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
import { UtilityProcess } from 'vs/platform/utilityProcess/electron-main/utilityProcess';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@@ -38,7 +39,7 @@ export class UtilityProcessWorkerMainService extends Disposable implements IUtil
super();
}
async createWorker(configuration: ISharedProcessWorkerCreateConfiguration): Promise<IOnDidTerminateSharedProcessWorkerProcess> {
async createWorker(configuration: IUtilityProcessWorkerCreateConfiguration): Promise<IOnDidTerminateUtilityrocessWorkerProcess> {
const workerLogId = `window: ${configuration.reply.windowId}, moduleId: ${configuration.process.moduleId}`;
this.logService.trace(`[UtilityProcessWorker]: createWorker(${workerLogId})`);
@@ -58,7 +59,7 @@ export class UtilityProcessWorkerMainService extends Disposable implements IUtil
this.workers.set(workerId, worker);
const onDidTerminate = new DeferredPromise<IOnDidTerminateSharedProcessWorkerProcess>();
const onDidTerminate = new DeferredPromise<IOnDidTerminateUtilityrocessWorkerProcess>();
Event.once(worker.onDidTerminate)(e => {
this.workers.delete(workerId);
onDidTerminate.complete({ reason: e });
@@ -67,14 +68,14 @@ export class UtilityProcessWorkerMainService extends Disposable implements IUtil
return onDidTerminate.p;
}
private hash(configuration: ISharedProcessWorkerConfiguration): number {
private hash(configuration: IUtilityProcessWorkerConfiguration): number {
return hash({
...configuration.process,
windowId: configuration.reply.windowId
});
}
async disposeWorker(configuration: ISharedProcessWorkerConfiguration): Promise<void> {
async disposeWorker(configuration: IUtilityProcessWorkerConfiguration): Promise<void> {
const workerId = this.hash(configuration);
const worker = this.workers.get(workerId);
if (!worker) {
@@ -90,7 +91,7 @@ export class UtilityProcessWorkerMainService extends Disposable implements IUtil
class UtilityProcessWorker extends Disposable {
private readonly _onDidTerminate = this._register(new Emitter<ISharedProcessWorkerProcessExit>());
private readonly _onDidTerminate = this._register(new Emitter<IUtilityProcessWorkerProcessExit>());
readonly onDidTerminate = this._onDidTerminate.event;
private readonly utilityProcess = new UtilityProcess(this.logService, this.windowsMainService, this.telemetryService, this.lifecycleMainService);
@@ -100,7 +101,7 @@ class UtilityProcessWorker extends Disposable {
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
private readonly configuration: ISharedProcessWorkerCreateConfiguration
private readonly configuration: IUtilityProcessWorkerCreateConfiguration
) {
super();
@@ -8,10 +8,11 @@ import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/
import { IMainProcessService, ISharedProcessService } from 'vs/platform/ipc/electron-sandbox/services';
import { Client as MessagePortClient } from 'vs/base/parts/ipc/common/ipc.mp';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IOnDidTerminateSharedProcessWorkerProcess, ipcSharedProcessWorkerChannelName, ISharedProcessWorkerProcess, ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { ipcUtilityProcessWorkerChannelName, ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService';
import { IPCClient, ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
import { generateUuid } from 'vs/base/common/uuid';
import { acquirePort } from 'vs/base/parts/ipc/electron-sandbox/ipc.mp';
import { IOnDidTerminateUtilityrocessWorkerProcess, IUtilityProcessWorkerProcess } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
export const IUtilityProcessWorkerWorkbenchService = createDecorator<IUtilityProcessWorkerWorkbenchService>('utilityProcessWorkerWorkbenchService');
@@ -31,7 +32,7 @@ export interface IUtilityProcessWorker extends IDisposable {
* should be restarted in case of an unexpected
* termination.
*/
onDidTerminate: Promise<IOnDidTerminateSharedProcessWorkerProcess>;
onDidTerminate: Promise<IOnDidTerminateUtilityrocessWorkerProcess>;
}
export interface IUtilityProcessWorkerWorkbenchService {
@@ -60,7 +61,7 @@ export interface IUtilityProcessWorkerWorkbenchService {
* @returns the worker IPC client to communicate with. Provides a `dispose` method that
* allows to terminate the worker if needed.
*/
createWorker(process: ISharedProcessWorkerProcess): Promise<IUtilityProcessWorker>;
createWorker(process: IUtilityProcessWorkerProcess): Promise<IUtilityProcessWorker>;
}
export class UtilityProcessWorkerWorkbenchService extends Disposable implements IUtilityProcessWorkerWorkbenchService {
@@ -70,7 +71,7 @@ export class UtilityProcessWorkerWorkbenchService extends Disposable implements
private _utilityProcessWorkerService: ISharedProcessWorkerService | undefined = undefined;
private get utilityProcessWorkerService(): ISharedProcessWorkerService {
if (!this._utilityProcessWorkerService) {
const channel = this.useUtilityProcess ? this.mainProcessService.getChannel(ipcSharedProcessWorkerChannelName) : this.sharedProcessService.getChannel(ipcSharedProcessWorkerChannelName);
const channel = this.useUtilityProcess ? this.mainProcessService.getChannel(ipcUtilityProcessWorkerChannelName) : this.sharedProcessService.getChannel(ipcUtilityProcessWorkerChannelName);
this._utilityProcessWorkerService = ProxyChannel.toService<ISharedProcessWorkerService>(channel);
}
@@ -87,7 +88,7 @@ export class UtilityProcessWorkerWorkbenchService extends Disposable implements
super();
}
async createWorker(process: ISharedProcessWorkerProcess): Promise<IUtilityProcessWorker> {
async createWorker(process: IUtilityProcessWorkerProcess): Promise<IUtilityProcessWorker> {
this.logService.trace('Renderer->UtilityProcess#createWorker');
// Get ready to acquire the message port from the utility process worker