diff --git a/src/vs/platform/instantiation/common/instantiationService.ts b/src/vs/platform/instantiation/common/instantiationService.ts index c817c55f700ae6d865d4739cf88edf4ad8215de0..5345229bdc17dfa2fdedcde4195f7ec13b195691 100644 --- a/src/vs/platform/instantiation/common/instantiationService.ts +++ b/src/vs/platform/instantiation/common/instantiationService.ts @@ -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}`); } } diff --git a/src/vs/platform/ipc/electron-browser/sharedProcessService.ts b/src/vs/platform/ipc/electron-browser/sharedProcessService.ts index bfeaf0ac6533ffafa69a8b51fc076bfdd47469ad..d02e7d8e005379c1d5d79c12f8cc3d4fe657dd8b 100644 --- a/src/vs/platform/ipc/electron-browser/sharedProcessService.ts +++ b/src/vs/platform/ipc/electron-browser/sharedProcessService.ts @@ -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('sharedProcessService'); @@ -23,38 +18,3 @@ export interface ISharedProcessService { whenSharedProcessReady(): Promise; toggleSharedProcessWindow(): Promise; } - -export class SharedProcessService implements ISharedProcessService { - - _serviceBrand: undefined; - - private withSharedProcessConnection: Promise>; - 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 { - return this.sharedProcessMainChannel.call('whenSharedProcessReady'); - } - - getChannel(channelName: string): IChannel { - return getDelayedChannel(this.withSharedProcessConnection.then(connection => connection.getChannel(channelName))); - } - - registerChannel(channelName: string, channel: IServerChannel): void { - this.withSharedProcessConnection.then(connection => connection.registerChannel(channelName, channel)); - } - - toggleSharedProcessWindow(): Promise { - return this.sharedProcessMainChannel.call('toggleSharedProcessWindow'); - } -} diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index 2a9c017b2194f7dd2f8b0db480796d25ec2c909c..72dfda9076089a15b70194a33c6e5b0594a1da89 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -97,8 +97,6 @@ export interface IWindowService { _serviceBrand: undefined; - readonly windowId: number; - getRecentlyOpened(): Promise; addRecentlyOpened(recents: IRecent[]): Promise; removeFromRecentlyOpened(paths: URI[]): Promise; diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts index 36dda0cc37e31a400743f317d5b456e7689322a4..ad6b8a3ec6c427241c39684a919dfc3260718e81 100644 --- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts @@ -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())); } diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index 3eb12e54ff283abf4f7f1f8834636f18effc9871..51ff9141c89718c0e75bbd885e4af51479d44b14 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -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))); } diff --git a/src/vs/workbench/browser/web.simpleservices.ts b/src/vs/workbench/browser/web.simpleservices.ts index f416c4458322c61ae973ab1716ce2c8430940d82..e63c0c8621f0458b03c20ba705ced5a7af15ad15 100644 --- a/src/vs/workbench/browser/web.simpleservices.ts +++ b/src/vs/workbench/browser/web.simpleservices.ts @@ -20,8 +20,6 @@ export class SimpleWindowService extends Disposable implements IWindowService { _serviceBrand: undefined; - readonly windowId = 0; - static readonly RECENTLY_OPENED_KEY = 'recently.opened'; constructor( diff --git a/src/vs/workbench/contrib/splash/electron-browser/partsSplash.contribution.ts b/src/vs/workbench/contrib/splash/electron-browser/partsSplash.contribution.ts index 011b14816fb79ae6a6c2c7ce40246857ff05d671..cd74aa81d409173c338dc3ff72f09076f344b331 100644 --- a/src/vs/workbench/contrib/splash/electron-browser/partsSplash.contribution.ts +++ b/src/vs/workbench/contrib/splash/electron-browser/partsSplash.contribution.ts @@ -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); } } diff --git a/src/vs/workbench/electron-browser/actions/windowActions.ts b/src/vs/workbench/electron-browser/actions/windowActions.ts index 440cba68b5643ce328c946f7407c333faab73b12..782aacaf14a69c7fb3927605080b7de2d0a0cb1f 100644 --- a/src/vs/workbench/electron-browser/actions/windowActions.ts +++ b/src/vs/workbench/electron-browser/actions/windowActions.ts @@ -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 { - 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 { diff --git a/src/vs/workbench/electron-browser/desktop.main.ts b/src/vs/workbench/electron-browser/desktop.main.ts index 3e1d93baed2b457c42bef888ae37f0b04440f7c8..af2c553f47ff6a3b35d495c11907ac0c7cb69981 100644 --- a/src/vs/workbench/electron-browser/desktop.main.ts +++ b/src/vs/workbench/electron-browser/desktop.main.ts @@ -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'; diff --git a/src/vs/platform/driver/electron-browser/driver.ts b/src/vs/workbench/electron-browser/driver.ts similarity index 90% rename from src/vs/platform/driver/electron-browser/driver.ts rename to src/vs/workbench/electron-browser/driver.ts index 941c4aa63b5f171021666df7e683f15512c394fe..e98db131e49275714911b10a08061fcb3c5a9edc 100644 --- a/src/vs/platform/driver/electron-browser/driver.ts +++ b/src/vs/workbench/electron-browser/driver.ts @@ -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 { 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)); } diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 6cc69b81369dd1680a422d8a76a5b9023df29d52..00f11c05a745e26c3101ead2c6b153a75a36de0c 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -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); } } diff --git a/src/vs/platform/electron/electron-browser/electronService.ts b/src/vs/workbench/services/electron/electron-browser/electronService.ts similarity index 66% rename from src/vs/platform/electron/electron-browser/electronService.ts rename to src/vs/workbench/services/electron/electron-browser/electronService.ts index 690925f54f07b0ffba59a525480d25840e0b21a9..0286416b0dca2e0ed130d8c72df70c32976c01c8 100644 --- a/src/vs/platform/electron/electron-browser/electronService.ts +++ b/src/vs/workbench/services/electron/electron-browser/electronService.ts @@ -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(mainProcessService.getChannel('electron'), { context: windowService.windowId }); + return createChannelSender(mainProcessService.getChannel('electron'), { context: environmentService.configuration.windowId }); } } + +registerSingleton(IElectronService, ElectronService, true); diff --git a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts index 3511f45c56ebeed13cb10a4cb816795f696da89a..af2a981604ae94c6340933803c59a3ff7f21f0dc 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts @@ -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(); - 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 = []; diff --git a/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts b/src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts similarity index 89% rename from src/vs/platform/lifecycle/electron-browser/lifecycleService.ts rename to src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts index 8505d978cd69fe1d503206b22fe7478fca131638..58051e5710f9d46f0e53610060cd156f78bda321 100644 --- a/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts +++ b/src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts @@ -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); diff --git a/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts b/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts new file mode 100644 index 0000000000000000000000000000000000000000..50de47001bebda7923bd19b04f4630c4c6f30ffc --- /dev/null +++ b/src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts @@ -0,0 +1,48 @@ +/*--------------------------------------------------------------------------------------------- + * 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>; + 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 { + return this.sharedProcessMainChannel.call('whenSharedProcessReady'); + } + + getChannel(channelName: string): IChannel { + return getDelayedChannel(this.withSharedProcessConnection.then(connection => connection.getChannel(channelName))); + } + + registerChannel(channelName: string, channel: IServerChannel): void { + this.withSharedProcessConnection.then(connection => connection.registerChannel(channelName, channel)); + } + + toggleSharedProcessWindow(): Promise { + return this.sharedProcessMainChannel.call('toggleSharedProcessWindow'); + } +} + +registerSingleton(ISharedProcessService, SharedProcessService, true); diff --git a/src/vs/workbench/services/url/electron-browser/urlService.ts b/src/vs/workbench/services/url/electron-browser/urlService.ts index 45a819abc789d67387849d994869b96e0b7bf52d..8759f5fdceec0ea1d04c9102fab15e70fffd158e 100644 --- a/src/vs/workbench/services/url/electron-browser/urlService.ts +++ b/src/vs/workbench/services/url/electron-browser/urlService.ts @@ -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 }); diff --git a/src/vs/workbench/services/window/electron-browser/windowService.ts b/src/vs/workbench/services/window/electron-browser/windowService.ts index a2da9c8bd2a3444069bb25a89a23fed74e9beece..ab9439cb09c5464c5269b09817eaf8981d115b1e 100644 --- a/src/vs/workbench/services/window/electron-browser/windowService.ts +++ b/src/vs/workbench/services/window/electron-browser/windowService.ts @@ -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 { - return this.windowsService.getRecentlyOpened(this.windowId); + return this.windowsService.getRecentlyOpened(this.environmentService.configuration.windowId); } addRecentlyOpened(recents: IRecent[]): Promise { diff --git a/src/vs/workbench/services/workspace/electron-browser/workspacesService.ts b/src/vs/workbench/services/workspace/electron-browser/workspacesService.ts index ee5fcb3dc6ad151534df616d65e3028bf06b1dea..bb84d54aa50e91c5d8825b838f197226a0bfcfe5 100644 --- a/src/vs/workbench/services/workspace/electron-browser/workspacesService.ts +++ b/src/vs/workbench/services/workspace/electron-browser/workspacesService.ts @@ -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 { - 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); } diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 08e47bee8efde4524f82870f50e0fa82340288cf..dc9b30f3ad4b75684bb5f4089a892844f259f338 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -1181,8 +1181,6 @@ export class TestWindowService implements IWindowService { public _serviceBrand: undefined; - readonly windowId = 0; - getRecentlyOpened(): Promise { return Promise.resolve({ workspaces: [], diff --git a/src/vs/workbench/workbench.desktop.main.ts b/src/vs/workbench/workbench.desktop.main.ts index bf5da3657b343037da4e53b1eb245677e701b497..8c468a747604f5bb1593ae72b85d8c973dee3e8e 100644 --- a/src/vs/workbench/workbench.desktop.main.ts +++ b/src/vs/workbench/workbench.desktop.main.ts @@ -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 diff --git a/src/vs/workbench/workbench.web.main.ts b/src/vs/workbench/workbench.web.main.ts index ee239acabf7fb5a47dfa46a34df0fa47874553b6..9545c435ea95223a0e3031bb477570b98c1f389b 100644 --- a/src/vs/workbench/workbench.web.main.ts +++ b/src/vs/workbench/workbench.web.main.ts @@ -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';