提交 01b5fe02 编写于 作者: B Benjamin Pasero

debt - remove windowId from window service

上级 42855090
......@@ -206,7 +206,7 @@ export class InstantiationService implements IInstantiationService {
} else if (this._parent) {
return this._parent._createServiceInstanceWithOwner(id, ctor, args, supportsDelayedInstantiation, _trace);
} else {
throw new Error('illegalState - creating UNKNOWN service instance');
throw new Error(`illegalState - creating UNKNOWN service instance ${ctor.name}`);
}
}
......
......@@ -4,12 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Client } from 'vs/base/parts/ipc/common/ipc.net';
import { connect } from 'vs/base/parts/ipc/node/ipc.net';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IChannel, IServerChannel, getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
export const ISharedProcessService = createDecorator<ISharedProcessService>('sharedProcessService');
......@@ -23,38 +18,3 @@ export interface ISharedProcessService {
whenSharedProcessReady(): Promise<void>;
toggleSharedProcessWindow(): Promise<void>;
}
export class SharedProcessService implements ISharedProcessService {
_serviceBrand: undefined;
private withSharedProcessConnection: Promise<Client<string>>;
private sharedProcessMainChannel: IChannel;
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IWindowService windowService: IWindowService,
@IEnvironmentService environmentService: IEnvironmentService
) {
this.sharedProcessMainChannel = mainProcessService.getChannel('sharedProcess');
this.withSharedProcessConnection = this.whenSharedProcessReady()
.then(() => connect(environmentService.sharedIPCHandle, `window:${windowService.windowId}`));
}
whenSharedProcessReady(): Promise<void> {
return this.sharedProcessMainChannel.call('whenSharedProcessReady');
}
getChannel(channelName: string): IChannel {
return getDelayedChannel(this.withSharedProcessConnection.then(connection => connection.getChannel(channelName)));
}
registerChannel(channelName: string, channel: IServerChannel<string>): void {
this.withSharedProcessConnection.then(connection => connection.registerChannel(channelName, channel));
}
toggleSharedProcessWindow(): Promise<void> {
return this.sharedProcessMainChannel.call('toggleSharedProcessWindow');
}
}
......@@ -97,8 +97,6 @@ export interface IWindowService {
_serviceBrand: undefined;
readonly windowId: number;
getRecentlyOpened(): Promise<IRecentlyOpened>;
addRecentlyOpened(recents: IRecent[]): Promise<void>;
removeFromRecentlyOpened(paths: URI[]): Promise<void>;
......
......@@ -25,7 +25,7 @@ import { IUpdateService, StateType } from 'vs/platform/update/common/update';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { MenuBar } from 'vs/base/browser/ui/menu/menubar';
import { SubmenuAction, Direction } from 'vs/base/browser/ui/menu/menu';
import { attachMenuStyler } from 'vs/platform/theme/common/styler';
......@@ -93,7 +93,7 @@ export abstract class MenubarControl extends Disposable {
protected readonly storageService: IStorageService,
protected readonly notificationService: INotificationService,
protected readonly preferencesService: IPreferencesService,
protected readonly environmentService: IEnvironmentService,
protected readonly environmentService: IWorkbenchEnvironmentService,
protected readonly accessibilityService: IAccessibilityService,
protected readonly hostService: IHostService
) {
......@@ -278,7 +278,7 @@ export class CustomMenubarControl extends MenubarControl {
@IStorageService storageService: IStorageService,
@INotificationService notificationService: INotificationService,
@IPreferencesService preferencesService: IPreferencesService,
@IEnvironmentService environmentService: IEnvironmentService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IAccessibilityService accessibilityService: IAccessibilityService,
@IThemeService private readonly themeService: IThemeService,
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
......@@ -434,7 +434,7 @@ export class CustomMenubarControl extends MenubarControl {
return null;
case StateType.Idle:
const windowId = this.windowService.windowId;
const windowId = this.environmentService.configuration.windowId;
return new Action('update.check', nls.localize({ key: 'checkForUpdates', comment: ['&& denotes a mnemonic'] }, "Check for &&Updates..."), undefined, true, () =>
this.updateService.checkForUpdates({ windowId }));
......@@ -643,8 +643,8 @@ export class CustomMenubarControl extends MenubarControl {
// Listen for maximize/unmaximize
if (!isWeb) {
this._register(Event.any(
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.windowService.windowId), _ => true),
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.windowService.windowId), _ => false)
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.environmentService.configuration.windowId), _ => true),
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.environmentService.configuration.windowId), _ => false)
)(e => this.updateMenubar()));
}
......
......@@ -8,7 +8,7 @@ import * as resources from 'vs/base/common/resources';
import { Part } from 'vs/workbench/browser/part';
import { ITitleService, ITitleProperties } from 'vs/workbench/services/title/common/titleService';
import { getZoomFactor } from 'vs/base/browser/browser';
import { IWindowService, MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { MenuBarVisibility, getTitleBarStyle, IWindowService } from 'vs/platform/windows/common/windows';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { IAction } from 'vs/base/common/actions';
......@@ -89,7 +89,6 @@ export class TitlebarPart extends Part implements ITitleService {
constructor(
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IWindowService private readonly windowService: IWindowService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IEditorService private readonly editorService: IEditorService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
......@@ -102,6 +101,7 @@ export class TitlebarPart extends Part implements ITitleService {
@IMenuService menuService: IMenuService,
@IContextKeyService contextKeyService: IContextKeyService,
@IHostService private readonly hostService: IHostService,
@IWindowService windowService: IWindowService,
@optional(IElectronService) private electronService: IElectronService
) {
super(Parts.TITLEBAR_PART, { hasTitle: false }, themeService, storageService, layoutService);
......@@ -434,8 +434,8 @@ export class TitlebarPart extends Part implements ITitleService {
this.onDidChangeMaximized(isMaximized);
this._register(Event.any(
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.windowService.windowId), _ => true),
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.windowService.windowId), _ => false)
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.environmentService.configuration.windowId), _ => true),
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.environmentService.configuration.windowId), _ => false)
)(e => this.onDidChangeMaximized(e)));
}
......
......@@ -20,8 +20,6 @@ export class SimpleWindowService extends Disposable implements IWindowService {
_serviceBrand: undefined;
readonly windowId = 0;
static readonly RECENTLY_OPENED_KEY = 'recently.opened';
constructor(
......
......@@ -18,12 +18,11 @@ import { DEFAULT_EDITOR_MIN_DIMENSIONS } from 'vs/workbench/browser/parts/editor
import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import * as themes from 'vs/workbench/common/theme';
import { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/layout/browser/layoutService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { URI } from 'vs/base/common/uri';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWindowService } from 'vs/platform/windows/common/windows';
import * as perf from 'vs/base/common/performance';
class PartsSplash {
......@@ -40,8 +39,7 @@ class PartsSplash {
@IThemeService private readonly _themeService: IThemeService,
@IWorkbenchLayoutService private readonly _layoutService: IWorkbenchLayoutService,
@ITextFileService private readonly _textFileService: ITextFileService,
@IEnvironmentService private readonly _envService: IEnvironmentService,
@IWindowService private readonly windowService: IWindowService,
@IWorkbenchEnvironmentService private readonly _envService: IWorkbenchEnvironmentService,
@ILifecycleService lifecycleService: ILifecycleService,
@IEditorGroupsService editorGroupsService: IEditorGroupsService,
@IConfigurationService configService: IConfigurationService,
......@@ -105,7 +103,7 @@ class PartsSplash {
// the color needs to be in hex
const backgroundColor = this._themeService.getTheme().getColor(editorBackground) || themes.WORKBENCH_BACKGROUND(this._themeService.getTheme());
const payload = JSON.stringify({ baseTheme, background: Color.Format.CSS.formatHex(backgroundColor) });
ipc.send('vscode:changeColorTheme', this.windowService.windowId, payload);
ipc.send('vscode:changeColorTheme', this._envService.configuration.windowId, payload);
}
}
......
......@@ -5,7 +5,7 @@
import { URI } from 'vs/base/common/uri';
import { Action } from 'vs/base/common/actions';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import * as nls from 'vs/nls';
import * as browser from 'vs/base/browser/browser';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
......@@ -167,7 +167,7 @@ export abstract class BaseSwitchWindow extends Action {
constructor(
id: string,
label: string,
private windowService: IWindowService,
private environmentService: IWorkbenchEnvironmentService,
private quickInputService: IQuickInputService,
private keybindingService: IKeybindingService,
private modelService: IModelService,
......@@ -180,7 +180,7 @@ export abstract class BaseSwitchWindow extends Action {
protected abstract isQuickNavigate(): boolean;
async run(): Promise<void> {
const currentWindowId = this.windowService.windowId;
const currentWindowId = this.environmentService.configuration.windowId;
const windows = await this.electronService.getWindows();
const placeHolder = nls.localize('switchWindowPlaceHolder', "Select a window to switch to");
......@@ -222,14 +222,14 @@ export class SwitchWindow extends BaseSwitchWindow {
constructor(
id: string,
label: string,
@IWindowService windowService: IWindowService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IQuickInputService quickInputService: IQuickInputService,
@IKeybindingService keybindingService: IKeybindingService,
@IModelService modelService: IModelService,
@IModeService modeService: IModeService,
@IElectronService electronService: IElectronService
) {
super(id, label, windowService, quickInputService, keybindingService, modelService, modeService, electronService);
super(id, label, environmentService, quickInputService, keybindingService, modelService, modeService, electronService);
}
protected isQuickNavigate(): boolean {
......@@ -245,14 +245,14 @@ export class QuickSwitchWindow extends BaseSwitchWindow {
constructor(
id: string,
label: string,
@IWindowService windowService: IWindowService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IQuickInputService quickInputService: IQuickInputService,
@IKeybindingService keybindingService: IKeybindingService,
@IModelService modelService: IModelService,
@IModeService modeService: IModeService,
@IElectronService electronService: IElectronService
) {
super(id, label, windowService, quickInputService, keybindingService, modelService, modeService, electronService);
super(id, label, environmentService, quickInputService, keybindingService, modelService, modeService, electronService);
}
protected isQuickNavigate(): boolean {
......
......@@ -33,7 +33,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { Disposable } from 'vs/base/common/lifecycle';
import { registerWindowDriver } from 'vs/platform/driver/electron-browser/driver';
import { registerWindowDriver } from 'vs/workbench/electron-browser/driver';
import { IMainProcessService, MainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { RemoteAuthorityResolverService } from 'vs/platform/remote/electron-browser/remoteAuthorityResolverService';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
......
......@@ -8,10 +8,10 @@ import { WindowDriverChannel, WindowDriverRegistryChannelClient } from 'vs/platf
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import * as electron from 'electron';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { timeout } from 'vs/base/common/async';
import { BaseWindowDriver } from 'vs/platform/driver/browser/baseDriver';
import { IElectronService } from 'vs/platform/electron/node/electron';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
class WindowDriver extends BaseWindowDriver {
......@@ -49,7 +49,7 @@ class WindowDriver extends BaseWindowDriver {
export async function registerWindowDriver(accessor: ServicesAccessor): Promise<IDisposable> {
const instantiationService = accessor.get(IInstantiationService);
const mainProcessService = accessor.get(IMainProcessService);
const windowService = accessor.get(IWindowService);
const environmentService = accessor.get(IWorkbenchEnvironmentService);
const windowDriver = instantiationService.createInstance(WindowDriver);
const windowDriverChannel = new WindowDriverChannel(windowDriver);
......@@ -58,12 +58,12 @@ export async function registerWindowDriver(accessor: ServicesAccessor): Promise<
const windowDriverRegistryChannel = mainProcessService.getChannel('windowDriverRegistry');
const windowDriverRegistry = new WindowDriverRegistryChannelClient(windowDriverRegistryChannel);
await windowDriverRegistry.registerWindowDriver(windowService.windowId);
await windowDriverRegistry.registerWindowDriver(environmentService.configuration.windowId);
// const options = await windowDriverRegistry.registerWindowDriver(windowId);
// if (options.verbose) {
// windowDriver.openDevTools();
// }
return toDisposable(() => windowDriverRegistry.reloadWindowDriver(windowService.windowId));
return toDisposable(() => windowDriverRegistry.reloadWindowDriver(environmentService.configuration.windowId));
}
......@@ -50,7 +50,6 @@ import { ILabelService } from 'vs/platform/label/common/label';
import { IUpdateService } from 'vs/platform/update/common/update';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IPreferencesService } from '../services/preferences/common/preferences';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IMenubarService, IMenubarData, IMenubarMenu, IMenubarKeybinding, IMenubarMenuItemSubmenu, IMenubarMenuItemAction, MenubarMenuItem } from 'vs/platform/menubar/node/menubar';
import { withNullAsUndefined } from 'vs/base/common/types';
import { IOpenerService, OpenOptions } from 'vs/platform/opener/common/opener';
......@@ -90,7 +89,6 @@ export class ElectronWindow extends Disposable {
constructor(
@IEditorService private readonly editorService: EditorServiceImpl,
@IWindowService private readonly windowService: IWindowService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@ITitleService private readonly titleService: ITitleService,
@IWorkbenchThemeService protected themeService: IWorkbenchThemeService,
......@@ -390,7 +388,7 @@ export class ElectronWindow extends Disposable {
this.setupOpenHandlers();
// Emit event when vscode is ready
this.lifecycleService.when(LifecyclePhase.Ready).then(() => ipc.send('vscode:workbenchReady', this.windowService.windowId));
this.lifecycleService.when(LifecyclePhase.Ready).then(() => ipc.send('vscode:workbenchReady', this.environmentService.configuration.windowId));
// Integrity warning
this.integrityService.isPure().then(res => this.titleService.updateProperties({ isPure: res.isPure }));
......@@ -690,7 +688,7 @@ class NativeMenubarControl extends MenubarControl {
@IStorageService storageService: IStorageService,
@INotificationService notificationService: INotificationService,
@IPreferencesService preferencesService: IPreferencesService,
@IEnvironmentService environmentService: IEnvironmentService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IAccessibilityService accessibilityService: IAccessibilityService,
@IMenubarService private readonly menubarService: IMenubarService,
@IHostService hostService: IHostService
......@@ -738,7 +736,7 @@ class NativeMenubarControl extends MenubarControl {
// Send menus to main process to be rendered by Electron
const menubarData = { menus: {}, keybindings: {} };
if (this.getMenubarMenus(menubarData)) {
this.menubarService.updateMenubar(this.windowService.windowId, menubarData);
this.menubarService.updateMenubar(this.environmentService.configuration.windowId, menubarData);
}
}
......
......@@ -6,7 +6,8 @@
import { IElectronService } from 'vs/platform/electron/node/electron';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { createChannelSender } from 'vs/platform/ipc/node/ipcChannelCreator';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
export class ElectronService {
......@@ -14,8 +15,10 @@ export class ElectronService {
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IWindowService windowService: IWindowService
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService
) {
return createChannelSender<IElectronService>(mainProcessService.getChannel('electron'), { context: windowService.windowId });
return createChannelSender<IElectronService>(mainProcessService.getChannel('electron'), { context: environmentService.configuration.windowId });
}
}
registerSingleton(IElectronService, ElectronService, true);
......@@ -25,7 +25,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { IExtensionService, toExtension } from 'vs/workbench/services/extensions/common/extensions';
import { ExtensionHostProcessManager } from 'vs/workbench/services/extensions/common/extensionHostProcessManager';
......@@ -67,7 +66,6 @@ export class ExtensionService extends AbstractExtensionService implements IExten
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
@IWindowService protected readonly _windowService: IWindowService,
@IStaticExtensionsService private readonly _staticExtensions: IStaticExtensionsService,
@IElectronService private readonly _electronService: IElectronService,
@IHostService private readonly _hostService: IHostService
......@@ -93,7 +91,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
this._remoteExtensionsEnvironmentData = new Map<string, IRemoteAgentEnvironment>();
this._extensionHostLogsLocation = URI.file(path.join(this._environmentService.logsPath, `exthost${this._windowService.windowId}`));
this._extensionHostLogsLocation = URI.file(path.join(this._environmentService.logsPath, `exthost${this._environmentService.configuration.windowId}`));
this._extensionScanner = instantiationService.createInstance(CachedExtensionScanner);
this._deltaExtensionsQueue = [];
......
......@@ -4,14 +4,15 @@
*--------------------------------------------------------------------------------------------*/
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { ShutdownReason, StartupKind, handleVetos } from 'vs/platform/lifecycle/common/lifecycle';
import { ShutdownReason, StartupKind, handleVetos, ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IStorageService, StorageScope, WillSaveStateReason } from 'vs/platform/storage/common/storage';
import { ipcRenderer as ipc } from 'electron';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { onUnexpectedError } from 'vs/base/common/errors';
import { AbstractLifecycleService } from 'vs/platform/lifecycle/common/lifecycleService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
export class LifecycleService extends AbstractLifecycleService {
......@@ -23,7 +24,7 @@ export class LifecycleService extends AbstractLifecycleService {
constructor(
@INotificationService private readonly notificationService: INotificationService,
@IWindowService private readonly windowService: IWindowService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IStorageService readonly storageService: IStorageService,
@ILogService readonly logService: ILogService
) {
......@@ -53,7 +54,7 @@ export class LifecycleService extends AbstractLifecycleService {
}
private registerListeners(): void {
const windowId = this.windowService.windowId;
const windowId = this.environmentService.configuration.windowId;
// Main side indicates that window is about to unload, check for vetos
ipc.on('vscode:onBeforeUnload', (_event: unknown, reply: { okChannel: string, cancelChannel: string, reason: ShutdownReason }) => {
......@@ -132,3 +133,5 @@ export class LifecycleService extends AbstractLifecycleService {
}
}
}
registerSingleton(ILifecycleService, LifecycleService);
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Client } from 'vs/base/parts/ipc/common/ipc.net';
import { connect } from 'vs/base/parts/ipc/node/ipc.net';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IChannel, IServerChannel, getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
export class SharedProcessService implements ISharedProcessService {
_serviceBrand: undefined;
private withSharedProcessConnection: Promise<Client<string>>;
private sharedProcessMainChannel: IChannel;
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService
) {
this.sharedProcessMainChannel = mainProcessService.getChannel('sharedProcess');
this.withSharedProcessConnection = this.whenSharedProcessReady()
.then(() => connect(environmentService.sharedIPCHandle, `window:${environmentService.configuration.windowId}`));
}
whenSharedProcessReady(): Promise<void> {
return this.sharedProcessMainChannel.call('whenSharedProcessReady');
}
getChannel(channelName: string): IChannel {
return getDelayedChannel(this.withSharedProcessConnection.then(connection => connection.getChannel(channelName)));
}
registerChannel(channelName: string, channel: IServerChannel<string>): void {
this.withSharedProcessConnection.then(connection => connection.registerChannel(channelName, channel));
}
toggleSharedProcessWindow(): Promise<void> {
return this.sharedProcessMainChannel.call('toggleSharedProcessWindow');
}
}
registerSingleton(ISharedProcessService, SharedProcessService, true);
......@@ -11,7 +11,7 @@ import { URLService } from 'vs/platform/url/node/urlService';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import product from 'vs/platform/product/common/product';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
export class RelayURLService extends URLService implements IURLHandler {
......@@ -20,7 +20,7 @@ export class RelayURLService extends URLService implements IURLHandler {
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IOpenerService openerService: IOpenerService,
@IWindowService private windowService: IWindowService
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService
) {
super();
......@@ -35,9 +35,9 @@ export class RelayURLService extends URLService implements IURLHandler {
let query = uri.query;
if (!query) {
query = `windowId=${encodeURIComponent(this.windowService.windowId)}`;
query = `windowId=${encodeURIComponent(this.environmentService.configuration.windowId)}`;
} else {
query += `&windowId=${encodeURIComponent(this.windowService.windowId)}`;
query += `&windowId=${encodeURIComponent(this.environmentService.configuration.windowId)}`;
}
return uri.with({ query });
......
......@@ -14,23 +14,15 @@ export class WindowService extends Disposable implements IWindowService {
_serviceBrand: undefined;
private _windowId: number;
constructor(
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IWindowsService private readonly windowsService: IWindowsService
) {
super();
this._windowId = environmentService.configuration.windowId;
}
get windowId(): number {
return this._windowId;
}
getRecentlyOpened(): Promise<IRecentlyOpened> {
return this.windowsService.getRecentlyOpened(this.windowId);
return this.windowsService.getRecentlyOpened(this.environmentService.configuration.windowId);
}
addRecentlyOpened(recents: IRecent[]): Promise<void> {
......
......@@ -8,7 +8,7 @@ import { IWorkspacesService, IWorkspaceIdentifier, IWorkspaceFolderCreationData,
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { URI } from 'vs/base/common/uri';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
export class WorkspacesService implements IWorkspacesService {
......@@ -18,13 +18,13 @@ export class WorkspacesService implements IWorkspacesService {
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IWindowService private readonly windowService: IWindowService
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
) {
this.channel = mainProcessService.getChannel('workspaces');
}
async enterWorkspace(path: URI): Promise<IEnterWorkspaceResult | undefined> {
const result: IEnterWorkspaceResult = await this.channel.call('enterWorkspace', [this.windowService.windowId, path]);
const result: IEnterWorkspaceResult = await this.channel.call('enterWorkspace', [this.environmentService.configuration.windowId, path]);
if (result) {
result.workspace = reviveWorkspaceIdentifier(result.workspace);
}
......
......@@ -1181,8 +1181,6 @@ export class TestWindowService implements IWindowService {
public _serviceBrand: undefined;
readonly windowId = 0;
getRecentlyOpened(): Promise<IRecentlyOpened> {
return Promise.resolve({
workspaces: [],
......
......@@ -53,15 +53,15 @@ import 'vs/workbench/services/workspace/electron-browser/workspacesService';
import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncService';
import 'vs/workbench/services/host/electron-browser/desktopHostService';
import 'vs/workbench/services/request/electron-browser/requestService';
import 'vs/workbench/services/lifecycle/electron-browser/lifecycleService';
import 'vs/workbench/services/sharedProcess/electron-browser/sharedProcessService';
import 'vs/workbench/services/electron/electron-browser/electronService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { ClipboardService } from 'vs/platform/clipboard/electron-browser/clipboardService';
import { LifecycleService } from 'vs/platform/lifecycle/electron-browser/lifecycleService';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { ILocalizationsService } from 'vs/platform/localizations/common/localizations';
import { LocalizationsService } from 'vs/platform/localizations/electron-browser/localizationsService';
import { ISharedProcessService, SharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { WindowsService } from 'vs/platform/windows/electron-browser/windowsService';
import { IUpdateService } from 'vs/platform/update/common/update';
......@@ -70,20 +70,15 @@ import { IIssueService } from 'vs/platform/issue/node/issue';
import { IssueService } from 'vs/platform/issue/electron-browser/issueService';
import { IMenubarService } from 'vs/platform/menubar/node/menubar';
import { MenubarService } from 'vs/platform/menubar/electron-browser/menubarService';
import { IElectronService } from 'vs/platform/electron/node/electron';
import { ElectronService } from 'vs/platform/electron/electron-browser/electronService';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import { NativeWorkspaceEditingService } from 'vs/workbench/services/workspace/electron-browser/workspaceEditingService';
registerSingleton(IClipboardService, ClipboardService, true);
registerSingleton(ILifecycleService, LifecycleService);
registerSingleton(ILocalizationsService, LocalizationsService);
registerSingleton(ISharedProcessService, SharedProcessService, true);
registerSingleton(IWindowsService, WindowsService);
registerSingleton(IUpdateService, UpdateService);
registerSingleton(IIssueService, IssueService);
registerSingleton(IMenubarService, MenubarService);
registerSingleton(IElectronService, ElectronService, true);
registerSingleton(IWorkspaceEditingService, NativeWorkspaceEditingService, true);
//#endregion
......
......@@ -52,13 +52,13 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
import { BrowserClipboardService } from 'vs/platform/clipboard/browser/clipboardService';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { BrowserAccessibilityService } from 'vs/platform/accessibility/common/accessibilityService';
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { BrowserLifecycleService } from 'vs/platform/lifecycle/browser/lifecycleService';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { ContextMenuService } from 'vs/platform/contextview/browser/contextMenuService';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { BackupFileService } from 'vs/workbench/services/backup/common/backupFileService';
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/extensionManagementService';
import { ITunnelService } from 'vs/platform/remote/common/tunnel';
import { NoOpTunnelService } from 'vs/platform/remote/common/tunnelService';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册