Skip to content

Commit

Permalink
debt - clean up platform/electron-main (part 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 17, 2019
1 parent 96bf508 commit 3e43911
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { join } from 'vs/base/common/path';
import { readdir, readFile, rimraf } from 'vs/base/node/pfs';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
import { IBackupWorkspacesFormat } from 'vs/platform/backup/common/backup';
import { IBackupWorkspacesFormat } from 'vs/platform/backup/node/backup';

export class StorageDataCleaner extends Disposable {

Expand Down
17 changes: 8 additions & 9 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Server as ElectronIPCServer } from 'vs/base/parts/ipc/electron-main/ipc
import { Client } from 'vs/base/parts/ipc/common/ipc.net';
import { Server, connect } from 'vs/base/parts/ipc/node/ipc.net';
import { SharedProcess } from 'vs/code/electron-main/sharedProcess';
import { LaunchService, LaunchChannel, ILaunchService } from 'vs/platform/launch/electron-main/launchService';
import { LaunchMainService, LaunchChannel, ILaunchMainService } from 'vs/platform/launch/electron-main/launchService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
Expand All @@ -37,7 +37,6 @@ import product from 'vs/platform/product/common/product';
import { ProxyAuthHandler } from 'vs/code/electron-main/auth';
import { Disposable } from 'vs/base/common/lifecycle';
import { IWindowsMainService, ICodeWindow } from 'vs/platform/windows/electron-main/windows';
import { IHistoryMainService } from 'vs/platform/history/common/history';
import { URI } from 'vs/base/common/uri';
import { WorkspacesChannel } from 'vs/platform/workspaces/electron-main/workspacesIpc';
import { hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces';
Expand All @@ -46,8 +45,8 @@ import { Win32UpdateService } from 'vs/platform/update/electron-main/updateServi
import { LinuxUpdateService } from 'vs/platform/update/electron-main/updateService.linux';
import { DarwinUpdateService } from 'vs/platform/update/electron-main/updateService.darwin';
import { IIssueService } from 'vs/platform/issue/node/issue';
import { IssueChannel } from 'vs/platform/issue/node/issueIpc';
import { IssueService } from 'vs/platform/issue/electron-main/issueService';
import { IssueChannel } from 'vs/platform/issue/electron-main/issueIpc';
import { IssueMainService } from 'vs/platform/issue/electron-main/issueMainService';
import { LogLevelSetterChannel } from 'vs/platform/log/common/logIpc';
import { setUnexpectedErrorHandler, onUnexpectedError } from 'vs/base/common/errors';
import { ElectronURLListener } from 'vs/platform/url/electron-main/electronUrlListener';
Expand All @@ -66,8 +65,8 @@ import { IStorageMainService, StorageMainService } from 'vs/platform/storage/nod
import { GlobalStorageDatabaseChannel } from 'vs/platform/storage/node/storageIpc';
import { startsWith } from 'vs/base/common/strings';
import { BackupMainService } from 'vs/platform/backup/electron-main/backupMainService';
import { IBackupMainService } from 'vs/platform/backup/common/backup';
import { HistoryMainService } from 'vs/platform/history/electron-main/historyMainService';
import { IBackupMainService } from 'vs/platform/backup/electron-main/backup';
import { HistoryMainService, IHistoryMainService } from 'vs/platform/history/electron-main/historyMainService';
import { URLService } from 'vs/platform/url/node/urlService';
import { WorkspacesMainService, IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService';
import { statSync } from 'fs';
Expand Down Expand Up @@ -451,12 +450,12 @@ export class CodeApplication extends Disposable {

services.set(IWindowsMainService, new SyncDescriptor(WindowsManager, [machineId, this.userEnv]));
services.set(IWindowsService, new SyncDescriptor(WindowsService, [sharedProcess]));
services.set(ILaunchService, new SyncDescriptor(LaunchService));
services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService));

const diagnosticsChannel = getDelayedChannel(sharedProcessClient.then(client => client.getChannel('diagnostics')));
services.set(IDiagnosticsService, new SyncDescriptor(DiagnosticsService, [diagnosticsChannel]));

services.set(IIssueService, new SyncDescriptor(IssueService, [machineId, this.userEnv]));
services.set(IIssueService, new SyncDescriptor(IssueMainService, [machineId, this.userEnv]));
services.set(IElectronService, new SyncDescriptor(ElectronMainService));
services.set(IMenubarService, new SyncDescriptor(MenubarService));

Expand Down Expand Up @@ -530,7 +529,7 @@ export class CodeApplication extends Disposable {
private openFirstWindow(accessor: ServicesAccessor, electronIpcServer: ElectronIPCServer, sharedProcessClient: Promise<Client<string>>): ICodeWindow[] {

// Register more Main IPC services
const launchService = accessor.get(ILaunchService);
const launchService = accessor.get(ILaunchMainService);
const launchChannel = new LaunchChannel(launchService);
this.mainIpcServer.registerChannel('launch', launchChannel);

Expand Down
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
import { ICodeWindow, IWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows';
import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService';
import { IBackupMainService } from 'vs/platform/backup/common/backup';
import { IBackupMainService } from 'vs/platform/backup/electron-main/backup';
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
import * as perf from 'vs/base/common/performance';
import { resolveMarketplaceHeaders } from 'vs/platform/extensionManagement/common/extensionGalleryService';
Expand Down
6 changes: 4 additions & 2 deletions src/vs/code/electron-main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { basename, normalize, join, dirname } from 'vs/base/common/path';
import { localize } from 'vs/nls';
import * as arrays from 'vs/base/common/arrays';
import { assign, mixin } from 'vs/base/common/objects';
import { IBackupMainService, IEmptyWindowBackupInfo } from 'vs/platform/backup/common/backup';
import { IBackupMainService } from 'vs/platform/backup/electron-main/backup';
import { IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { IStateService } from 'vs/platform/state/common/state';
import { CodeWindow, defaultWindowState } from 'vs/code/electron-main/window';
Expand All @@ -23,7 +24,8 @@ import { Event as CommonEvent, Emitter } from 'vs/base/common/event';
import product from 'vs/platform/product/common/product';
import { ITelemetryService, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { IWindowsMainService, IOpenConfiguration, IWindowsCountChangedEvent, ICodeWindow, IWindowState as ISingleWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows';
import { IHistoryMainService, IRecent } from 'vs/platform/history/common/history';
import { IRecent } from 'vs/platform/history/common/history';
import { IHistoryMainService } from 'vs/platform/history/electron-main/historyMainService';
import { IProcessEnvironment, isMacintosh, isWindows } from 'vs/base/common/platform';
import { IWorkspaceIdentifier, WORKSPACE_FILTER, isSingleFolderWorkspaceIdentifier, hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,10 @@
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { URI } from 'vs/base/common/uri';

export interface ISerializedWorkspace { id: string; configURIPath: string; remoteAuthority?: string; }

export interface IBackupWorkspacesFormat {
rootURIWorkspaces: ISerializedWorkspace[];
folderURIWorkspaces: string[];
emptyWorkspaceInfos: IEmptyWindowBackupInfo[];

// deprecated
folderWorkspaces?: string[]; // use folderURIWorkspaces instead
emptyWorkspaces?: string[];
rootWorkspaces?: { id: string, configPath: string }[]; // use rootURIWorkspaces instead
}
import { IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup';

export const IBackupMainService = createDecorator<IBackupMainService>('backupMainService');

export interface IEmptyWindowBackupInfo {
backupFolder: string;
remoteAuthority?: string;
}

export interface IWorkspaceBackupInfo {
workspace: IWorkspaceIdentifier;
remoteAuthority?: string;
Expand All @@ -48,4 +31,4 @@ export interface IBackupMainService {
unregisterWorkspaceBackupSync(workspace: IWorkspaceIdentifier): void;
unregisterFolderBackupSync(folderUri: URI): void;
unregisterEmptyWindowBackupSync(backupFolder: string): void;
}
}
3 changes: 2 additions & 1 deletion src/vs/platform/backup/electron-main/backupMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import * as path from 'vs/base/common/path';
import * as platform from 'vs/base/common/platform';
import { writeFileSync, writeFile, readFile, readdir, exists, rimraf, rename, RimRafMode } from 'vs/base/node/pfs';
import * as arrays from 'vs/base/common/arrays';
import { IBackupMainService, IBackupWorkspacesFormat, IEmptyWindowBackupInfo, IWorkspaceBackupInfo } from 'vs/platform/backup/common/backup';
import { IBackupMainService, IWorkspaceBackupInfo } from 'vs/platform/backup/electron-main/backup';
import { IBackupWorkspacesFormat, IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IFilesConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files';
Expand Down
22 changes: 22 additions & 0 deletions src/vs/platform/backup/node/backup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

export interface ISerializedWorkspace { id: string; configURIPath: string; remoteAuthority?: string; }

export interface IBackupWorkspacesFormat {
rootURIWorkspaces: ISerializedWorkspace[];
folderURIWorkspaces: string[];
emptyWorkspaceInfos: IEmptyWindowBackupInfo[];

// deprecated
folderWorkspaces?: string[]; // use folderURIWorkspaces instead
emptyWorkspaces?: string[];
rootWorkspaces?: { id: string, configPath: string }[]; // use rootURIWorkspaces instead
}

export interface IEmptyWindowBackupInfo {
backupFolder: string;
remoteAuthority?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { URI } from 'vs/base/common/uri';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { BackupMainService } from 'vs/platform/backup/electron-main/backupMainService';
import { IBackupWorkspacesFormat, ISerializedWorkspace, IWorkspaceBackupInfo } from 'vs/platform/backup/common/backup';
import { IWorkspaceBackupInfo } from 'vs/platform/backup/electron-main/backup';
import { IBackupWorkspacesFormat, ISerializedWorkspace } from 'vs/platform/backup/node/backup';
import { HotExitConfiguration } from 'vs/platform/files/common/files';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { ConsoleLogMainService } from 'vs/platform/log/common/log';
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/diagnostics/node/diagnosticsIpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IServerChannel, IChannel } from 'vs/base/parts/ipc/common/ipc';
import { IRemoteDiagnosticInfo, IRemoteDiagnosticError, SystemInfo, PerformanceInfo } from 'vs/platform/diagnostics/common/diagnostics';
import { IDiagnosticsService } from './diagnosticsService';
import { Event } from 'vs/base/common/event';
import { IMainProcessInfo } from 'vs/platform/launch/common/launchService';
import { IMainProcessInfo } from 'vs/platform/launch/common/launch';
import { IWorkspace } from 'vs/platform/workspace/common/workspace';

export class DiagnosticsChannel implements IServerChannel {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/diagnostics/node/diagnosticsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { repeat, pad } from 'vs/base/common/strings';
import { isWindows } from 'vs/base/common/platform';
import { URI } from 'vs/base/common/uri';
import { ProcessItem } from 'vs/base/common/processes';
import { IMainProcessInfo } from 'vs/platform/launch/common/launchService';
import { IMainProcessInfo } from 'vs/platform/launch/common/launch';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';

Expand Down
18 changes: 0 additions & 18 deletions src/vs/platform/history/common/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Event as CommonEvent } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { URI } from 'vs/base/common/uri';
import { IPath } from 'vs/platform/windows/common/windows';

export const IHistoryMainService = createDecorator<IHistoryMainService>('historyMainService');

export interface IRecentlyOpened {
workspaces: Array<IRecentWorkspace | IRecentFolder>;
Expand Down Expand Up @@ -45,16 +40,3 @@ export function isRecentFile(curr: IRecent): curr is IRecentFile {
return curr.hasOwnProperty('fileUri');
}


export interface IHistoryMainService {
_serviceBrand: undefined;

onRecentlyOpenedChange: CommonEvent<void>;

addRecentlyOpened(recents: IRecent[]): void;
getRecentlyOpened(currentWorkspace?: IWorkspaceIdentifier, currentFolder?: ISingleFolderWorkspaceIdentifier, currentFiles?: IPath[]): IRecentlyOpened;
removeFromRecentlyOpened(paths: URI[]): void;
clearRecentlyOpened(): void;

updateWindowsJumpList(): void;
}
18 changes: 17 additions & 1 deletion src/vs/platform/history/electron-main/historyMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Event as CommonEvent, Emitter } from 'vs/base/common/event';
import { isWindows, isMacintosh } from 'vs/base/common/platform';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService';
import { IHistoryMainService, IRecentlyOpened, isRecentWorkspace, isRecentFolder, IRecent, isRecentFile, IRecentFolder, IRecentWorkspace, IRecentFile } from 'vs/platform/history/common/history';
import { IRecentlyOpened, isRecentWorkspace, isRecentFolder, IRecent, isRecentFile, IRecentFolder, IRecentWorkspace, IRecentFile } from 'vs/platform/history/common/history';
import { ThrottledDelayer } from 'vs/base/common/async';
import { isEqual as areResourcesEqual, dirname, originalFSPath, basename } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
Expand All @@ -24,6 +24,22 @@ import { getSimpleWorkspaceLabel } from 'vs/platform/label/common/label';
import { toStoreData, restoreRecentlyOpened, RecentlyOpenedStorageData } from 'vs/platform/history/common/historyStorage';
import { exists } from 'vs/base/node/pfs';
import { ILifecycleService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';

export const IHistoryMainService = createDecorator<IHistoryMainService>('historyMainService');

export interface IHistoryMainService {
_serviceBrand: undefined;

onRecentlyOpenedChange: CommonEvent<void>;

addRecentlyOpened(recents: IRecent[]): void;
getRecentlyOpened(currentWorkspace?: IWorkspaceIdentifier, currentFolder?: ISingleFolderWorkspaceIdentifier, currentFiles?: IPath[]): IRecentlyOpened;
removeFromRecentlyOpened(paths: URI[]): void;
clearRecentlyOpened(): void;

updateWindowsJumpList(): void;
}

export class HistoryMainService implements IHistoryMainService {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as objects from 'vs/base/common/objects';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { IIssueService, IssueReporterData, IssueReporterFeatures, ProcessExplorerData } from 'vs/platform/issue/node/issue';
import { BrowserWindow, ipcMain, screen, dialog } from 'electron';
import { ILaunchService } from 'vs/platform/launch/electron-main/launchService';
import { ILaunchMainService } from 'vs/platform/launch/electron-main/launchService';
import { PerformanceInfo, isRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnostics';
import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
Expand All @@ -20,7 +20,7 @@ import { listProcesses } from 'vs/base/node/ps';

const DEFAULT_BACKGROUND_COLOR = '#1E1E1E';

export class IssueService implements IIssueService {
export class IssueMainService implements IIssueService {
_serviceBrand: undefined;
_issueWindow: BrowserWindow | null = null;
_issueParentWindow: BrowserWindow | null = null;
Expand All @@ -31,7 +31,7 @@ export class IssueService implements IIssueService {
private machineId: string,
private userEnv: IProcessEnvironment,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@ILaunchService private readonly launchService: ILaunchService,
@ILaunchMainService private readonly launchService: ILaunchMainService,
@ILogService private readonly logService: ILogService,
@IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService,
@IWindowsService private readonly windowsService: IWindowsService
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions src/vs/platform/launch/electron-main/launchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import { BrowserWindow, ipcMain, Event as IpcEvent, app } from 'electron';
import { Event } from 'vs/base/common/event';
import { coalesce } from 'vs/base/common/arrays';
import { IDiagnosticInfoOptions, IDiagnosticInfo, IRemoteDiagnosticInfo, IRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnostics';
import { IMainProcessInfo, IWindowInfo } from 'vs/platform/launch/common/launchService';
import { IMainProcessInfo, IWindowInfo } from 'vs/platform/launch/common/launch';

export const ID = 'launchService';
export const ILaunchService = createDecorator<ILaunchService>(ID);
export const ID = 'launchMainService';
export const ILaunchMainService = createDecorator<ILaunchMainService>(ID);

export interface IStartArguments {
args: ParsedArgs;
Expand Down Expand Up @@ -51,7 +51,7 @@ function parseOpenUrl(args: ParsedArgs): URI[] {
return [];
}

export interface ILaunchService {
export interface ILaunchMainService {
_serviceBrand: undefined;
start(args: ParsedArgs, userEnv: IProcessEnvironment): Promise<void>;
getMainProcessId(): Promise<number>;
Expand All @@ -62,7 +62,7 @@ export interface ILaunchService {

export class LaunchChannel implements IServerChannel {

constructor(private service: ILaunchService) { }
constructor(private service: ILaunchMainService) { }

listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Event not found: ${event}`);
Expand Down Expand Up @@ -91,7 +91,7 @@ export class LaunchChannel implements IServerChannel {
}
}

export class LaunchChannelClient implements ILaunchService {
export class LaunchChannelClient implements ILaunchMainService {

_serviceBrand: undefined;

Expand All @@ -118,7 +118,7 @@ export class LaunchChannelClient implements ILaunchService {
}
}

export class LaunchService implements ILaunchService {
export class LaunchMainService implements ILaunchMainService {

_serviceBrand: undefined;

Expand Down
Loading

0 comments on commit 3e43911

Please sign in to comment.