From ca4dd67abe11321dc977f8396616ff5e5714dfee Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 12 Oct 2020 11:12:35 +0200 Subject: [PATCH] debt - introduce environment main service to have properties there exclusively --- .../contrib/storageDataCleaner.ts | 26 +++++++++------- .../sharedProcess/sharedProcessMain.ts | 3 +- src/vs/code/electron-main/app.ts | 4 +-- src/vs/code/electron-main/main.ts | 16 +++++----- src/vs/code/electron-main/sharedProcess.ts | 7 +++-- src/vs/code/electron-main/window.ts | 4 +-- .../backup/electron-main/backupMainService.ts | 4 +-- .../electron-main/backupMainService.test.ts | 4 +-- .../platform/driver/electron-main/driver.ts | 4 +-- .../environment/common/environment.ts | 2 -- .../electron-main/environmentMainService.ts | 30 +++++++++++++++++++ .../environment/node/environmentService.ts | 6 ---- .../issue/electron-main/issueMainService.ts | 4 +-- .../platform/menubar/electron-main/menubar.ts | 4 +-- .../electron-main/nativeHostMainService.ts | 4 +-- .../electron-main/abstractUpdateService.ts | 4 +-- .../electron-main/updateService.darwin.ts | 4 +-- .../electron-main/updateService.linux.ts | 4 +-- .../electron-main/updateService.snap.ts | 6 ++-- .../electron-main/updateService.win32.ts | 4 +-- .../url/electron-main/electronUrlListener.ts | 4 +-- .../electron-main/windowsMainService.ts | 4 +-- .../workspacesHistoryMainService.ts | 4 +-- .../electron-main/workspacesMainService.ts | 4 +-- .../workspacesMainService.test.ts | 4 +-- .../sandbox.simpleservices.ts | 2 -- 26 files changed, 98 insertions(+), 68 deletions(-) create mode 100644 src/vs/platform/environment/electron-main/environmentMainService.ts diff --git a/src/vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner.ts b/src/vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner.ts index ac8a7fc175c..66b8d79b5fa 100644 --- a/src/vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner.ts +++ b/src/vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner.ts @@ -16,6 +16,7 @@ export class StorageDataCleaner extends Disposable { private static readonly NON_EMPTY_WORKSPACE_ID_LENGTH = 128 / 4; constructor( + private readonly backupWorkspacesPath: string, @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService ) { super(); @@ -27,14 +28,17 @@ export class StorageDataCleaner extends Disposable { let handle: NodeJS.Timeout | undefined = setTimeout(() => { handle = undefined; - // Leverage the backup workspace file to find out which empty workspace is currently in use to - // determine which empty workspace storage can safely be deleted - readFile(this.environmentService.backupWorkspacesPath, 'utf8').then(contents => { - const workspaces = JSON.parse(contents) as IBackupWorkspacesFormat; - const emptyWorkspaces = workspaces.emptyWorkspaceInfos.map(info => info.backupFolder); + (async () => { + try { + // Leverage the backup workspace file to find out which empty workspace is currently in use to + // determine which empty workspace storage can safely be deleted + const contents = await readFile(this.backupWorkspacesPath, 'utf8'); - // Read all workspace storage folders that exist - return readdir(this.environmentService.workspaceStorageHome.fsPath).then(storageFolders => { + const workspaces = JSON.parse(contents) as IBackupWorkspacesFormat; + const emptyWorkspaces = workspaces.emptyWorkspaceInfos.map(info => info.backupFolder); + + // Read all workspace storage folders that exist + const storageFolders = await readdir(this.environmentService.workspaceStorageHome.fsPath); const deletes: Promise[] = []; storageFolders.forEach(storageFolder => { @@ -47,9 +51,11 @@ export class StorageDataCleaner extends Disposable { } }); - return Promise.all(deletes); - }); - }).then(null, onUnexpectedError); + await Promise.all(deletes); + } catch (error) { + onUnexpectedError(error); + } + })(); }, 30 * 1000); this._register(toDisposable(() => { diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts index 29ed5fccdd7..2d0027ca097 100644 --- a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts +++ b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts @@ -84,6 +84,7 @@ interface ISharedProcessInitData { sharedIPCHandle: string; args: NativeParsedArgs; logLevel: LogLevel; + backupWorkspacesPath: string; } const eventPrefix = 'monacoworkbench'; @@ -262,7 +263,7 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat disposables.add(combinedDisposable( instantiationService2.createInstance(NodeCachedDataCleaner), instantiationService2.createInstance(LanguagePackCachedDataCleaner), - instantiationService2.createInstance(StorageDataCleaner), + instantiationService2.createInstance(StorageDataCleaner, initData.backupWorkspacesPath), instantiationService2.createInstance(LogsDataCleaner), userDataAutoSync )); diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 80d37a05885..e94b3404495 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -22,7 +22,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ILogService } from 'vs/platform/log/common/log'; import { IStateService } from 'vs/platform/state/node/state'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IURLService } from 'vs/platform/url/common/url'; import { URLHandlerChannelClient, URLHandlerRouter } from 'vs/platform/url/common/urlIpc'; @@ -93,7 +93,7 @@ export class CodeApplication extends Disposable { private readonly userEnv: IProcessEnvironment, @IInstantiationService private readonly instantiationService: IInstantiationService, @ILogService private readonly logService: ILogService, - @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService, @IConfigurationService private readonly configurationService: IConfigurationService, @IStateService private readonly stateService: IStateService diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index c0729b964ed..b2ca5d979d5 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -24,7 +24,7 @@ import { StateService } from 'vs/platform/state/node/stateService'; import { IStateService } from 'vs/platform/state/node/state'; import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment'; import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; -import { NativeEnvironmentService, xdgRuntimeDir } from 'vs/platform/environment/node/environmentService'; +import { xdgRuntimeDir } from 'vs/platform/environment/node/environmentService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ConfigurationService } from 'vs/platform/configuration/common/configurationService'; import { IRequestService } from 'vs/platform/request/common/request'; @@ -54,6 +54,7 @@ import { isNumber } from 'vs/base/common/types'; import { rtrim, trim } from 'vs/base/common/strings'; import { basename, resolve } from 'vs/base/common/path'; import { coalesce, distinct } from 'vs/base/common/arrays'; +import { EnvironmentMainService, IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; class ExpectedError extends Error { readonly isExpected = true; @@ -146,13 +147,14 @@ class CodeMain { } } - private createServices(args: NativeParsedArgs, bufferLogService: BufferLogService): [IInstantiationService, IProcessEnvironment, INativeEnvironmentService] { + private createServices(args: NativeParsedArgs, bufferLogService: BufferLogService): [IInstantiationService, IProcessEnvironment, IEnvironmentMainService] { const services = new ServiceCollection(); - const environmentService = new NativeEnvironmentService(args); + const environmentService = new EnvironmentMainService(args); const instanceEnvironment = this.patchEnvironment(environmentService); // Patch `process.env` with the instance's environment services.set(IEnvironmentService, environmentService); services.set(INativeEnvironmentService, environmentService); + services.set(IEnvironmentMainService, environmentService); const logService = new MultiplexLogService([new ConsoleLogMainService(getLogLevel(environmentService)), bufferLogService]); process.once('exit', () => logService.dispose()); @@ -176,7 +178,7 @@ class CodeMain { return [new InstantiationService(services, true), instanceEnvironment, environmentService]; } - private initServices(environmentService: INativeEnvironmentService, configurationService: ConfigurationService, stateService: StateService): Promise { + private initServices(environmentService: IEnvironmentMainService, configurationService: ConfigurationService, stateService: StateService): Promise { // Environment service (paths) const environmentServiceInitialization = Promise.all([ @@ -197,7 +199,7 @@ class CodeMain { return Promise.all([environmentServiceInitialization, configurationServiceInitialization, stateServiceInitialization]); } - private patchEnvironment(environmentService: INativeEnvironmentService): IProcessEnvironment { + private patchEnvironment(environmentService: IEnvironmentMainService): IProcessEnvironment { const instanceEnvironment: IProcessEnvironment = { VSCODE_IPC_HOOK: environmentService.mainIPCHandle }; @@ -214,7 +216,7 @@ class CodeMain { return instanceEnvironment; } - private async doStartup(args: NativeParsedArgs, logService: ILogService, environmentService: INativeEnvironmentService, lifecycleMainService: ILifecycleMainService, instantiationService: IInstantiationService, retry: boolean): Promise { + private async doStartup(args: NativeParsedArgs, logService: ILogService, environmentService: IEnvironmentMainService, lifecycleMainService: ILifecycleMainService, instantiationService: IInstantiationService, retry: boolean): Promise { // Try to setup a server for running. If that succeeds it means // we are the first instance to startup. Otherwise it is likely @@ -343,7 +345,7 @@ class CodeMain { return server; } - private handleStartupDataDirError(environmentService: INativeEnvironmentService, error: NodeJS.ErrnoException): void { + private handleStartupDataDirError(environmentService: IEnvironmentMainService, error: NodeJS.ErrnoException): void { if (error.code === 'EACCES' || error.code === 'EPERM') { const directories = [environmentService.userDataPath]; diff --git a/src/vs/code/electron-main/sharedProcess.ts b/src/vs/code/electron-main/sharedProcess.ts index c541a2c7e08..36e34044463 100644 --- a/src/vs/code/electron-main/sharedProcess.ts +++ b/src/vs/code/electron-main/sharedProcess.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { memoize } from 'vs/base/common/decorators'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { BrowserWindow, ipcMain, WebContents, Event as ElectronEvent } from 'electron'; import { ISharedProcess } from 'vs/platform/ipc/electron-main/sharedProcessMainService'; import { Barrier } from 'vs/base/common/async'; @@ -26,7 +26,7 @@ export class SharedProcess implements ISharedProcess { constructor( private readonly machineId: string, private userEnv: NodeJS.ProcessEnv, - @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService, @ILogService private readonly logService: ILogService, @IThemeMainService private readonly themeMainService: IThemeMainService @@ -115,7 +115,8 @@ export class SharedProcess implements ISharedProcess { sender.send('vscode:electron-main->shared-process=payload', { sharedIPCHandle: this.environmentService.sharedIPCHandle, args: this.environmentService.args, - logLevel: this.logService.getLevel() + logLevel: this.logService.getLevel(), + backupWorkspacesPath: this.environmentService.backupWorkspacesPath }); // signal exit to shared process when we get disposed diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index 08934128694..79e1658c61e 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -9,7 +9,7 @@ import * as nls from 'vs/nls'; import { Emitter } from 'vs/base/common/event'; import { URI } from 'vs/base/common/uri'; import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display, TouchBarSegmentedControl, NativeImage, BrowserWindowConstructorOptions, SegmentedControlSegment, nativeTheme, Event, Details } from 'electron'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { ILogService } from 'vs/platform/log/common/log'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv'; @@ -122,7 +122,7 @@ export class CodeWindow extends Disposable implements ICodeWindow { constructor( config: IWindowCreationOptions, @ILogService private readonly logService: ILogService, - @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @IFileService private readonly fileService: IFileService, @IStorageMainService private readonly storageService: IStorageMainService, @IConfigurationService private readonly configurationService: IConfigurationService, diff --git a/src/vs/platform/backup/electron-main/backupMainService.ts b/src/vs/platform/backup/electron-main/backupMainService.ts index 7ec91776da3..a7e9a9ee316 100644 --- a/src/vs/platform/backup/electron-main/backupMainService.ts +++ b/src/vs/platform/backup/electron-main/backupMainService.ts @@ -10,7 +10,7 @@ import * as platform from 'vs/base/common/platform'; import { writeFileSync, writeFile, readFile, readdir, exists, rimraf, rename, RimRafMode } from 'vs/base/node/pfs'; import { IBackupMainService, IWorkspaceBackupInfo, isWorkspaceBackupInfo } from 'vs/platform/backup/electron-main/backup'; import { IBackupWorkspacesFormat, IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IFilesConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files'; import { ILogService } from 'vs/platform/log/common/log'; @@ -38,7 +38,7 @@ export class BackupMainService implements IBackupMainService { private readonly backupPathComparer = { isEqual: (pathA: string, pathB: string) => isEqual(pathA, pathB, !platform.isLinux) }; constructor( - @INativeEnvironmentService environmentService: INativeEnvironmentService, + @IEnvironmentMainService environmentService: IEnvironmentMainService, @IConfigurationService private readonly configurationService: IConfigurationService, @ILogService private readonly logService: ILogService ) { diff --git a/src/vs/platform/backup/test/electron-main/backupMainService.test.ts b/src/vs/platform/backup/test/electron-main/backupMainService.test.ts index bfe03bb8bea..4db502cca8a 100644 --- a/src/vs/platform/backup/test/electron-main/backupMainService.test.ts +++ b/src/vs/platform/backup/test/electron-main/backupMainService.test.ts @@ -10,7 +10,7 @@ import * as os from 'os'; import * as path from 'vs/base/common/path'; import * as pfs from 'vs/base/node/pfs'; import { URI } from 'vs/base/common/uri'; -import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { EnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv'; import { BackupMainService } from 'vs/platform/backup/electron-main/backupMainService'; import { IWorkspaceBackupInfo } from 'vs/platform/backup/electron-main/backup'; @@ -34,7 +34,7 @@ suite('BackupMainService', () => { const backupHome = path.join(parentDir, 'Backups'); const backupWorkspacesPath = path.join(backupHome, 'workspaces.json'); - const environmentService = new NativeEnvironmentService(parseArgs(process.argv, OPTIONS)); + const environmentService = new EnvironmentMainService(parseArgs(process.argv, OPTIONS)); class TestBackupMainService extends BackupMainService { diff --git a/src/vs/platform/driver/electron-main/driver.ts b/src/vs/platform/driver/electron-main/driver.ts index 21cbd2d9e41..62d7cb313e6 100644 --- a/src/vs/platform/driver/electron-main/driver.ts +++ b/src/vs/platform/driver/electron-main/driver.ts @@ -13,7 +13,7 @@ import { SimpleKeybinding, KeyCode } from 'vs/base/common/keyCodes'; import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding'; import { OS } from 'vs/base/common/platform'; import { Emitter, Event } from 'vs/base/common/event'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { ScanCodeBinding } from 'vs/base/common/scanCode'; import { KeybindingParser } from 'vs/base/common/keybindingParser'; import { timeout } from 'vs/base/common/async'; @@ -207,7 +207,7 @@ export class Driver implements IDriver, IWindowDriverRegistry { export async function serve( windowServer: IPCServer, handle: string, - environmentService: INativeEnvironmentService, + environmentService: IEnvironmentMainService, instantiationService: IInstantiationService ): Promise { const verbose = environmentService.driverVerbose; diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index 40e4ba85515..d2c26a4f6f7 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -100,8 +100,6 @@ export interface INativeEnvironmentService extends IEnvironmentService { tmpDir: URI; userDataPath: string; machineSettingsResource: URI; - backupHome: string; - backupWorkspacesPath: string; nodeCachedDataDir?: string; installSourcePath: string; diff --git a/src/vs/platform/environment/electron-main/environmentMainService.ts b/src/vs/platform/environment/electron-main/environmentMainService.ts new file mode 100644 index 00000000000..c87f83f190e --- /dev/null +++ b/src/vs/platform/environment/electron-main/environmentMainService.ts @@ -0,0 +1,30 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { join } from 'vs/base/common/path'; +import { memoize } from 'vs/base/common/decorators'; +import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; +import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; + +export const IEnvironmentMainService = createDecorator('environmentMainService'); + +/** + * A subclass of the `INativeEnvironmentService` to be used only in electron-main + * environments. + */ +export interface IEnvironmentMainService extends INativeEnvironmentService { + backupHome: string; + backupWorkspacesPath: string; +} + +export class EnvironmentMainService extends NativeEnvironmentService { + + @memoize + get backupHome(): string { return join(this.userDataPath, 'Backups'); } + + @memoize + get backupWorkspacesPath(): string { return join(this.backupHome, 'workspaces.json'); } +} diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index 9e7765e2f38..e13d59e6f81 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -93,12 +93,6 @@ export class NativeEnvironmentService implements INativeEnvironmentService { @memoize get isExtensionDevelopment(): boolean { return !!this._args.extensionDevelopmentPath; } - @memoize - get backupHome(): string { return path.join(this.userDataPath, 'Backups'); } - - @memoize - get backupWorkspacesPath(): string { return path.join(this.backupHome, 'workspaces.json'); } - @memoize get untitledWorkspacesHome(): URI { return URI.file(path.join(this.userDataPath, 'Workspaces')); } diff --git a/src/vs/platform/issue/electron-main/issueMainService.ts b/src/vs/platform/issue/electron-main/issueMainService.ts index bc2b9bc4deb..1760044f9d1 100644 --- a/src/vs/platform/issue/electron-main/issueMainService.ts +++ b/src/vs/platform/issue/electron-main/issueMainService.ts @@ -12,7 +12,7 @@ import { BrowserWindow, ipcMain, screen, IpcMainEvent, Display, shell } from 'el import { ILaunchMainService } from 'vs/platform/launch/electron-main/launchMainService'; import { PerformanceInfo, isRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnostics'; import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { isMacintosh, IProcessEnvironment } from 'vs/base/common/platform'; import { ILogService } from 'vs/platform/log/common/log'; import { IWindowState } from 'vs/platform/windows/electron-main/windows'; @@ -38,7 +38,7 @@ export class IssueMainService implements ICommonIssueService { constructor( private machineId: string, private userEnv: IProcessEnvironment, - @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @ILaunchMainService private readonly launchMainService: ILaunchMainService, @ILogService private readonly logService: ILogService, @IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService, diff --git a/src/vs/platform/menubar/electron-main/menubar.ts b/src/vs/platform/menubar/electron-main/menubar.ts index 1bec83c2d55..c8d43ffee4b 100644 --- a/src/vs/platform/menubar/electron-main/menubar.ts +++ b/src/vs/platform/menubar/electron-main/menubar.ts @@ -5,7 +5,7 @@ import * as nls from 'vs/nls'; import { isMacintosh, language } from 'vs/base/common/platform'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { app, shell, Menu, MenuItem, BrowserWindow, MenuItemConstructorOptions, WebContents, Event, KeyboardEvent } from 'electron'; import { getTitleBarStyle, INativeRunActionInWindowRequest, INativeRunKeybindingInWindowRequest, IWindowOpenable } from 'vs/platform/windows/common/windows'; import { OpenContext } from 'vs/platform/windows/node/window'; @@ -67,7 +67,7 @@ export class Menubar { @IUpdateService private readonly updateService: IUpdateService, @IConfigurationService private readonly configurationService: IConfigurationService, @IWindowsMainService private readonly windowsMainService: IWindowsMainService, - @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @ITelemetryService private readonly telemetryService: ITelemetryService, @IWorkspacesHistoryMainService private readonly workspacesHistoryMainService: IWorkspacesHistoryMainService, @IStateService private readonly stateService: IStateService, diff --git a/src/vs/platform/native/electron-main/nativeHostMainService.ts b/src/vs/platform/native/electron-main/nativeHostMainService.ts index a1f4042203c..93d0f2143d1 100644 --- a/src/vs/platform/native/electron-main/nativeHostMainService.ts +++ b/src/vs/platform/native/electron-main/nativeHostMainService.ts @@ -13,7 +13,7 @@ import { INativeOpenDialogOptions } from 'vs/platform/dialogs/common/dialogs'; import { isMacintosh, isWindows, isRootUser, isLinux } from 'vs/base/common/platform'; import { ICommonNativeHostService, IOSProperties, IOSStatistics } from 'vs/platform/native/common/native'; import { ISerializableCommandAction } from 'vs/platform/actions/common/actions'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { AddFirstParameterToFunctions } from 'vs/base/common/types'; import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogs'; import { dirExists } from 'vs/base/node/pfs'; @@ -40,7 +40,7 @@ export class NativeHostMainService implements INativeHostMainService { @IWindowsMainService private readonly windowsMainService: IWindowsMainService, @IDialogMainService private readonly dialogMainService: IDialogMainService, @ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService, - @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @ITelemetryService private readonly telemetryService: ITelemetryService, @ILogService private readonly logService: ILogService ) { diff --git a/src/vs/platform/update/electron-main/abstractUpdateService.ts b/src/vs/platform/update/electron-main/abstractUpdateService.ts index 1c57c2ce027..f15dec1b8a7 100644 --- a/src/vs/platform/update/electron-main/abstractUpdateService.ts +++ b/src/vs/platform/update/electron-main/abstractUpdateService.ts @@ -9,7 +9,7 @@ import { IConfigurationService, getMigratedSettingValue } from 'vs/platform/conf import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import product from 'vs/platform/product/common/product'; import { IUpdateService, State, StateType, AvailableForDownload, UpdateType } from 'vs/platform/update/common/update'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { ILogService } from 'vs/platform/log/common/log'; import { IRequestService } from 'vs/platform/request/common/request'; import { CancellationToken } from 'vs/base/common/cancellation'; @@ -46,7 +46,7 @@ export abstract class AbstractUpdateService implements IUpdateService { constructor( @ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService, @IConfigurationService protected configurationService: IConfigurationService, - @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @IRequestService protected requestService: IRequestService, @ILogService protected logService: ILogService, ) { } diff --git a/src/vs/platform/update/electron-main/updateService.darwin.ts b/src/vs/platform/update/electron-main/updateService.darwin.ts index e8a43fef02d..ce1033b12d9 100644 --- a/src/vs/platform/update/electron-main/updateService.darwin.ts +++ b/src/vs/platform/update/electron-main/updateService.darwin.ts @@ -11,7 +11,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { State, IUpdate, StateType, UpdateType } from 'vs/platform/update/common/update'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { ILogService } from 'vs/platform/log/common/log'; import { AbstractUpdateService, createUpdateURL, UpdateNotAvailableClassification } from 'vs/platform/update/electron-main/abstractUpdateService'; import { IRequestService } from 'vs/platform/request/common/request'; @@ -31,7 +31,7 @@ export class DarwinUpdateService extends AbstractUpdateService { @ILifecycleMainService lifecycleMainService: ILifecycleMainService, @IConfigurationService configurationService: IConfigurationService, @ITelemetryService private readonly telemetryService: ITelemetryService, - @INativeEnvironmentService environmentService: INativeEnvironmentService, + @IEnvironmentMainService environmentService: IEnvironmentMainService, @IRequestService requestService: IRequestService, @ILogService logService: ILogService ) { diff --git a/src/vs/platform/update/electron-main/updateService.linux.ts b/src/vs/platform/update/electron-main/updateService.linux.ts index 236aa3f40db..c053ff38c95 100644 --- a/src/vs/platform/update/electron-main/updateService.linux.ts +++ b/src/vs/platform/update/electron-main/updateService.linux.ts @@ -8,7 +8,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { State, IUpdate, AvailableForDownload, UpdateType } from 'vs/platform/update/common/update'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { ILogService } from 'vs/platform/log/common/log'; import { createUpdateURL, AbstractUpdateService, UpdateNotAvailableClassification } from 'vs/platform/update/electron-main/abstractUpdateService'; import { IRequestService, asJson } from 'vs/platform/request/common/request'; @@ -23,7 +23,7 @@ export class LinuxUpdateService extends AbstractUpdateService { @ILifecycleMainService lifecycleMainService: ILifecycleMainService, @IConfigurationService configurationService: IConfigurationService, @ITelemetryService private readonly telemetryService: ITelemetryService, - @INativeEnvironmentService environmentService: INativeEnvironmentService, + @IEnvironmentMainService environmentService: IEnvironmentMainService, @IRequestService requestService: IRequestService, @ILogService logService: ILogService ) { diff --git a/src/vs/platform/update/electron-main/updateService.snap.ts b/src/vs/platform/update/electron-main/updateService.snap.ts index fe1fd23099f..1712182c365 100644 --- a/src/vs/platform/update/electron-main/updateService.snap.ts +++ b/src/vs/platform/update/electron-main/updateService.snap.ts @@ -7,7 +7,7 @@ import { Event, Emitter } from 'vs/base/common/event'; import { timeout } from 'vs/base/common/async'; import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { IUpdateService, State, StateType, AvailableForDownload, UpdateType } from 'vs/platform/update/common/update'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { ILogService } from 'vs/platform/log/common/log'; import * as path from 'vs/base/common/path'; import { realpath, watch } from 'fs'; @@ -36,7 +36,7 @@ abstract class AbstractUpdateService2 implements IUpdateService { constructor( @ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService, - @INativeEnvironmentService environmentService: INativeEnvironmentService, + @IEnvironmentMainService environmentService: IEnvironmentMainService, @ILogService protected logService: ILogService, ) { if (environmentService.disableUpdates) { @@ -140,7 +140,7 @@ export class SnapUpdateService extends AbstractUpdateService2 { private snap: string, private snapRevision: string, @ILifecycleMainService lifecycleMainService: ILifecycleMainService, - @INativeEnvironmentService environmentService: INativeEnvironmentService, + @IEnvironmentMainService environmentService: IEnvironmentMainService, @ILogService logService: ILogService, @ITelemetryService private readonly telemetryService: ITelemetryService ) { diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts index a0fad1214c8..d9b2729ce30 100644 --- a/src/vs/platform/update/electron-main/updateService.win32.ts +++ b/src/vs/platform/update/electron-main/updateService.win32.ts @@ -12,7 +12,7 @@ import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifec import product from 'vs/platform/product/common/product'; import { State, IUpdate, StateType, AvailableForDownload, UpdateType } from 'vs/platform/update/common/update'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { ILogService } from 'vs/platform/log/common/log'; import { createUpdateURL, AbstractUpdateService, UpdateNotAvailableClassification } from 'vs/platform/update/electron-main/abstractUpdateService'; import { IRequestService, asJson } from 'vs/platform/request/common/request'; @@ -63,7 +63,7 @@ export class Win32UpdateService extends AbstractUpdateService { @ILifecycleMainService lifecycleMainService: ILifecycleMainService, @IConfigurationService configurationService: IConfigurationService, @ITelemetryService private readonly telemetryService: ITelemetryService, - @INativeEnvironmentService environmentService: INativeEnvironmentService, + @IEnvironmentMainService environmentService: IEnvironmentMainService, @IRequestService requestService: IRequestService, @ILogService logService: ILogService, @IFileService private readonly fileService: IFileService diff --git a/src/vs/platform/url/electron-main/electronUrlListener.ts b/src/vs/platform/url/electron-main/electronUrlListener.ts index 22db37fc51e..efc15e02965 100644 --- a/src/vs/platform/url/electron-main/electronUrlListener.ts +++ b/src/vs/platform/url/electron-main/electronUrlListener.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { Event } from 'vs/base/common/event'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { IURLService } from 'vs/platform/url/common/url'; import product from 'vs/platform/product/common/product'; import { app, Event as ElectronEvent } from 'electron'; @@ -43,7 +43,7 @@ export class ElectronURLListener { initialUrisToHandle: URI[], private readonly urlService: IURLService, windowsMainService: IWindowsMainService, - environmentService: INativeEnvironmentService + environmentService: IEnvironmentMainService ) { // the initial set of URIs we need to handle once the window is ready diff --git a/src/vs/platform/windows/electron-main/windowsMainService.ts b/src/vs/platform/windows/electron-main/windowsMainService.ts index 6813c6aa70f..6f9f98cf620 100644 --- a/src/vs/platform/windows/electron-main/windowsMainService.ts +++ b/src/vs/platform/windows/electron-main/windowsMainService.ts @@ -10,7 +10,7 @@ import * as arrays from 'vs/base/common/arrays'; import { mixin } from 'vs/base/common/objects'; import { IBackupMainService } from 'vs/platform/backup/electron-main/backup'; import { IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; import { IStateService } from 'vs/platform/state/node/state'; import { CodeWindow, defaultWindowState } from 'vs/code/electron-main/window'; @@ -177,7 +177,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic private readonly initialUserEnv: IProcessEnvironment, @ILogService private readonly logService: ILogService, @IStateService private readonly stateService: IStateService, - @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService, @IBackupMainService private readonly backupMainService: IBackupMainService, @IConfigurationService private readonly configurationService: IConfigurationService, diff --git a/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts b/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts index 4a9094f80dd..b6321d7340b 100644 --- a/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts +++ b/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts @@ -17,7 +17,7 @@ import { ThrottledDelayer } from 'vs/base/common/async'; import { isEqual, dirname, originalFSPath, basename, extUriBiasedIgnorePathCase } from 'vs/base/common/resources'; import { URI } from 'vs/base/common/uri'; import { Schemas } from 'vs/base/common/network'; -import { INativeEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { exists } from 'vs/base/node/pfs'; import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; @@ -66,7 +66,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa @IStateService private readonly stateService: IStateService, @ILogService private readonly logService: ILogService, @IWorkspacesMainService private readonly workspacesMainService: IWorkspacesMainService, - @INativeEnvironmentService private readonly environmentService: INativeEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService ) { super(); diff --git a/src/vs/platform/workspaces/electron-main/workspacesMainService.ts b/src/vs/platform/workspaces/electron-main/workspacesMainService.ts index fdad65d7d41..f4fa065fbb5 100644 --- a/src/vs/platform/workspaces/electron-main/workspacesMainService.ts +++ b/src/vs/platform/workspaces/electron-main/workspacesMainService.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { IWorkspaceIdentifier, hasWorkspaceFileExtension, UNTITLED_WORKSPACE_NAME, IResolvedWorkspace, IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, IUntitledWorkspaceInfo, getStoredWorkspaceFolder, IEnterWorkspaceResult, isUntitledWorkspace } from 'vs/platform/workspaces/common/workspaces'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { join, dirname } from 'vs/base/common/path'; import { mkdirp, writeFile, rimrafSync, readdirSync, writeFileSync } from 'vs/base/node/pfs'; import { readFileSync, existsSync, mkdirSync } from 'fs'; @@ -75,7 +75,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain readonly onWorkspaceEntered: Event = this._onWorkspaceEntered.event; constructor( - @IEnvironmentService private readonly environmentService: IEnvironmentService, + @IEnvironmentMainService private readonly environmentService: IEnvironmentMainService, @ILogService private readonly logService: ILogService, @IBackupMainService private readonly backupMainService: IBackupMainService, @IDialogMainService private readonly dialogMainService: IDialogMainService diff --git a/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts b/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts index d2c3a1c06b3..07304aa32b0 100644 --- a/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts +++ b/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts @@ -8,7 +8,7 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'vs/base/common/path'; import * as pfs from 'vs/base/node/pfs'; -import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService'; +import { EnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv'; import { WorkspacesMainService, IStoredWorkspace } from 'vs/platform/workspaces/electron-main/workspacesMainService'; import { WORKSPACE_EXTENSION, IRawFileWorkspaceFolder, IWorkspaceFolderCreationData, IRawUriWorkspaceFolder, rewriteWorkspaceFileForNewLocation, IWorkspaceIdentifier, IStoredWorkspaceFolder } from 'vs/platform/workspaces/common/workspaces'; @@ -108,7 +108,7 @@ suite('WorkspacesMainService', () => { const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'workspacesservice'); const untitledWorkspacesHomePath = path.join(parentDir, 'Workspaces'); - class TestEnvironmentService extends NativeEnvironmentService { + class TestEnvironmentService extends EnvironmentMainService { get untitledWorkspacesHome(): URI { return URI.file(untitledWorkspacesHomePath); } diff --git a/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts b/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts index 81b9093cd04..82829fee164 100644 --- a/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts +++ b/src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts @@ -120,8 +120,6 @@ export class SimpleNativeWorkbenchEnvironmentService implements INativeWorkbench appSettingsHome: URI = undefined!; userDataPath: string = undefined!; machineSettingsResource: URI = undefined!; - backupHome: string = undefined!; - backupWorkspacesPath: string = undefined!; log?: string | undefined; extHostLogsPath: URI = undefined!;