Skip to content

Commit

Permalink
debt - more platform/electron-main cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 17, 2019
1 parent 19fed1d commit a8d5382
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 47 deletions.
8 changes: 4 additions & 4 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { WindowsManager } from 'vs/code/electron-main/windows';
import { IWindowsService, OpenContext, ActiveWindowManager, IURIToOpen } from 'vs/platform/windows/common/windows';
import { WindowsChannel } from 'vs/platform/windows/common/windowsIpc';
import { WindowsService } from 'vs/platform/windows/electron-main/windowsService';
import { ILifecycleService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { getShellEnvironment } from 'vs/code/node/shellEnv';
import { IUpdateService } from 'vs/platform/update/common/update';
import { UpdateChannel } from 'vs/platform/update/electron-main/updateIpc';
Expand Down Expand Up @@ -52,7 +52,7 @@ import { setUnexpectedErrorHandler, onUnexpectedError } from 'vs/base/common/err
import { ElectronURLListener } from 'vs/platform/url/electron-main/electronUrlListener';
import { serve as serveDriver } from 'vs/platform/driver/electron-main/driver';
import { IMenubarService } from 'vs/platform/menubar/node/menubar';
import { MenubarService } from 'vs/platform/menubar/electron-main/menubarService';
import { MenubarMainService } from 'vs/platform/menubar/electron-main/menubarMainService';
import { MenubarChannel } from 'vs/platform/menubar/node/menubarIpc';
import { RunOnceScheduler } from 'vs/base/common/async';
import { registerContextMenuListener } from 'vs/base/parts/contextmenu/electron-main/contextmenu';
Expand Down Expand Up @@ -92,7 +92,7 @@ export class CodeApplication extends Disposable {
@IInstantiationService private readonly instantiationService: IInstantiationService,
@ILogService private readonly logService: ILogService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@ILifecycleMainService private readonly lifecycleService: ILifecycleMainService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IStateService private readonly stateService: IStateService
) {
Expand Down Expand Up @@ -457,7 +457,7 @@ export class CodeApplication extends Disposable {

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

const storageMainService = new StorageMainService(this.logService, this.environmentService);
services.set(IStorageMainService, storageMainService);
Expand Down
14 changes: 7 additions & 7 deletions src/vs/code/electron-main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { parseMainProcessArgv } from 'vs/platform/environment/node/argvHelper';
import { addArg, createWaitMarkerFile } from 'vs/platform/environment/node/argv';
import { mkdirp } from 'vs/base/node/pfs';
import { validatePaths } from 'vs/code/node/paths';
import { LifecycleService, ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import { LifecycleMainService, ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { Server, serve, connect } from 'vs/base/parts/ipc/node/ipc.net';
import { LaunchChannelClient } from 'vs/platform/launch/electron-main/launchService';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
Expand All @@ -27,7 +27,7 @@ import { EnvironmentService, xdgRuntimeDir } from 'vs/platform/environment/node/
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ConfigurationService } from 'vs/platform/configuration/node/configurationService';
import { IRequestService } from 'vs/platform/request/common/request';
import { RequestService } from 'vs/platform/request/electron-main/requestService';
import { RequestMainService } from 'vs/platform/request/electron-main/requestMainService';
import * as fs from 'fs';
import { CodeApplication } from 'vs/code/electron-main/app';
import { localize } from 'vs/nls';
Expand Down Expand Up @@ -116,7 +116,7 @@ class CodeMain {
await instantiationService.invokeFunction(async accessor => {
const environmentService = accessor.get(IEnvironmentService);
const logService = accessor.get(ILogService);
const lifecycleService = accessor.get(ILifecycleService);
const lifecycleService = accessor.get(ILifecycleMainService);
const configurationService = accessor.get(IConfigurationService);

const mainIpcServer = await this.doStartup(logService, environmentService, lifecycleService, instantiationService, true);
Expand All @@ -143,9 +143,9 @@ class CodeMain {
services.set(ILogService, logService);

services.set(IConfigurationService, new ConfigurationService(environmentService.settingsResource));
services.set(ILifecycleService, new SyncDescriptor(LifecycleService));
services.set(ILifecycleMainService, new SyncDescriptor(LifecycleMainService));
services.set(IStateService, new SyncDescriptor(StateService));
services.set(IRequestService, new SyncDescriptor(RequestService));
services.set(IRequestService, new SyncDescriptor(RequestMainService));
services.set(IThemeMainService, new SyncDescriptor(ThemeMainService));
services.set(ISignService, new SyncDescriptor(SignService));

Expand Down Expand Up @@ -189,7 +189,7 @@ class CodeMain {
return instanceEnvironment;
}

private async doStartup(logService: ILogService, environmentService: IEnvironmentService, lifecycleService: ILifecycleService, instantiationService: IInstantiationService, retry: boolean): Promise<Server> {
private async doStartup(logService: ILogService, environmentService: IEnvironmentService, lifecycleService: ILifecycleMainService, instantiationService: IInstantiationService, retry: boolean): Promise<Server> {

// Try to setup a server for running. If that succeeds it means
// we are the first instance to startup. Otherwise it is likely
Expand Down Expand Up @@ -374,7 +374,7 @@ class CodeMain {

private quit(accessor: ServicesAccessor, reason?: ExpectedError | Error): void {
const logService = accessor.get(ILogService);
const lifecycleService = accessor.get(ILifecycleService);
const lifecycleService = accessor.get(ILifecycleMainService);

let exitCode = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/vs/code/electron-main/sharedProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BrowserWindow, ipcMain } from 'electron';
import { ISharedProcess } from 'vs/platform/windows/electron-main/windows';
import { Barrier } from 'vs/base/common/async';
import { ILogService } from 'vs/platform/log/common/log';
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService';
import { toDisposable, DisposableStore } from 'vs/base/common/lifecycle';

Expand All @@ -24,7 +24,7 @@ export class SharedProcess implements ISharedProcess {
private readonly machineId: string,
private userEnv: NodeJS.ProcessEnv,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@ILifecycleMainService private readonly lifecycleService: ILifecycleMainService,
@ILogService private readonly logService: ILogService,
@IThemeMainService private readonly themeMainService: IThemeMainService
) { }
Expand Down
6 changes: 3 additions & 3 deletions src/vs/code/electron-main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IStateService } from 'vs/platform/state/common/state';
import { CodeWindow, defaultWindowState } from 'vs/code/electron-main/window';
import { ipcMain as ipc, screen, BrowserWindow, dialog, systemPreferences, FileFilter } from 'electron';
import { parseLineAndColumnAware } from 'vs/code/node/paths';
import { ILifecycleService, UnloadReason, LifecycleService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import { ILifecycleMainService, UnloadReason, LifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';
import { IWindowSettings, OpenContext, IPath, IWindowConfiguration, INativeOpenDialogOptions, IPathsToWaitFor, IEnterWorkspaceResult, IMessageBoxResult, INewWindowOptions, IURIToOpen, isFileToOpen, isWorkspaceToOpen, isFolderToOpen } from 'vs/platform/windows/common/windows';
Expand Down Expand Up @@ -188,7 +188,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
@ILogService private readonly logService: ILogService,
@IStateService private readonly stateService: IStateService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@ILifecycleMainService private readonly lifecycleService: ILifecycleMainService,
@IBackupMainService private readonly backupMainService: IBackupMainService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IConfigurationService private readonly configurationService: IConfigurationService,
Expand Down Expand Up @@ -1364,7 +1364,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
window.win.on('closed', () => this.onWindowClosed(window!));

// Lifecycle
(this.lifecycleService as LifecycleService).registerWindow(window);
(this.lifecycleService as LifecycleMainService).registerWindow(window);
}

// Existing window
Expand Down
1 change: 0 additions & 1 deletion src/vs/platform/history/common/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ export function isRecentFolder(curr: IRecent): curr is IRecentFolder {
export function isRecentFile(curr: IRecent): curr is IRecentFile {
return curr.hasOwnProperty('fileUri');
}

4 changes: 2 additions & 2 deletions src/vs/platform/history/electron-main/historyMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
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 { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';

export const IHistoryMainService = createDecorator<IHistoryMainService>('historyMainService');
Expand Down Expand Up @@ -68,7 +68,7 @@ export class HistoryMainService implements IHistoryMainService {
@ILogService private readonly logService: ILogService,
@IWorkspacesMainService private readonly workspacesMainService: IWorkspacesMainService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@ILifecycleService lifecycleService: ILifecycleService
@ILifecycleMainService lifecycleService: ILifecycleMainService
) {
this.macOSRecentDocumentsUpdater = new ThrottledDelayer<void>(800);

Expand Down
3 changes: 2 additions & 1 deletion src/vs/platform/launch/common/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { UriComponents } from 'vs/base/common/uri';

export interface IWindowInfo {
Expand All @@ -18,4 +19,4 @@ export interface IMainProcessInfo {
windows: IWindowInfo[];
screenReader: boolean;
gpuFeatureStatus: any;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { isMacintosh, isWindows } from 'vs/base/common/platform';
import { Disposable } from 'vs/base/common/lifecycle';
import { Barrier } from 'vs/base/common/async';

export const ILifecycleService = createDecorator<ILifecycleService>('lifecycleService');
export const ILifecycleMainService = createDecorator<ILifecycleMainService>('lifecycleMainService');

export const enum UnloadReason {
CLOSE = 1,
Expand All @@ -38,7 +38,7 @@ export interface ShutdownEvent {
join(promise: Promise<void>): void;
}

export interface ILifecycleService {
export interface ILifecycleMainService {

_serviceBrand: undefined;

Expand Down Expand Up @@ -129,7 +129,7 @@ export const enum LifecycleMainPhase {
AfterWindowOpen = 3
}

export class LifecycleService extends Disposable implements ILifecycleService {
export class LifecycleMainService extends Disposable implements ILifecycleMainService {

_serviceBrand: undefined;

Expand Down Expand Up @@ -178,10 +178,10 @@ export class LifecycleService extends Disposable implements ILifecycleService {
}

private handleRestarted(): void {
this._wasRestarted = !!this.stateService.getItem(LifecycleService.QUIT_FROM_RESTART_MARKER);
this._wasRestarted = !!this.stateService.getItem(LifecycleMainService.QUIT_FROM_RESTART_MARKER);

if (this._wasRestarted) {
this.stateService.removeItem(LifecycleService.QUIT_FROM_RESTART_MARKER); // remove the marker right after if found
this.stateService.removeItem(LifecycleMainService.QUIT_FROM_RESTART_MARKER); // remove the marker right after if found
}
}

Expand Down Expand Up @@ -468,7 +468,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {

// Remember the reason for quit was to restart
if (fromUpdate) {
this.stateService.setItem(LifecycleService.QUIT_FROM_RESTART_MARKER, true);
this.stateService.setItem(LifecycleMainService.QUIT_FROM_RESTART_MARKER, true);
}

this.pendingQuitPromise = new Promise(resolve => {
Expand Down Expand Up @@ -507,7 +507,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
if (!quitVetoed) {

// Remember the reason for quit was to restart
this.stateService.setItem(LifecycleService.QUIT_FROM_RESTART_MARKER, true);
this.stateService.setItem(LifecycleMainService.QUIT_FROM_RESTART_MARKER, true);

// Windows: we are about to restart and as such we need to restore the original
// current working directory we had on startup to get the exact same startup
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/menubar/electron-main/menubar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { IHistoryMainService } from 'vs/platform/history/electron-main/historyMa
import { IMenubarData, IMenubarKeybinding, MenubarMenuItem, isMenubarMenuItemSeparator, isMenubarMenuItemSubmenu, isMenubarMenuItemAction, IMenubarMenu, isMenubarMenuItemUriAction } from 'vs/platform/menubar/node/menubar';
import { URI } from 'vs/base/common/uri';
import { IStateService } from 'vs/platform/state/common/state';
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } from 'vs/base/common/actions';

const telemetryFrom = 'menu';
Expand Down Expand Up @@ -68,7 +68,7 @@ export class Menubar {
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IHistoryMainService private readonly historyMainService: IHistoryMainService,
@IStateService private readonly stateService: IStateService,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@ILifecycleMainService private readonly lifecycleService: ILifecycleMainService,
@ILogService private readonly logService: ILogService
) {
this.menuUpdater = new RunOnceScheduler(() => this.doUpdateMenu(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { Menubar } from 'vs/platform/menubar/electron-main/menubar';
import { ILogService } from 'vs/platform/log/common/log';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';

export class MenubarService implements IMenubarService {
export class MenubarMainService implements IMenubarService {

_serviceBrand: undefined;

private _menubar: Menubar;
Expand All @@ -30,4 +31,4 @@ export class MenubarService implements IMenubarService {

return Promise.resolve(undefined);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function getRawRequest(options: IRequestOptions): IRawRequestFunction {
return net.request as any as IRawRequestFunction;
}

export class RequestService extends NodeRequestService {
export class RequestMainService extends NodeRequestService {

request(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> {
return super.request(assign({}, options || {}, { getRawRequest }), token);
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/theme/electron-main/themeMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class ThemeMainService implements IThemeMainService {
this.stateService.setItem(THEME_BG_STORAGE_KEY, data.background);
}

public getBackgroundColor(): string {
getBackgroundColor(): string {
if (isWindows && systemPreferences.isInvertedColorScheme()) {
return DEFAULT_BG_HC_BLACK;
}
Expand All @@ -64,4 +64,4 @@ export class ThemeMainService implements IThemeMainService {

return background;
}
}
}
4 changes: 2 additions & 2 deletions src/vs/platform/update/electron-main/abstractUpdateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { Event, Emitter } from 'vs/base/common/event';
import { timeout } from 'vs/base/common/async';
import { IConfigurationService, getMigratedSettingValue } from 'vs/platform/configuration/common/configuration';
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
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 { IEnvironmentService } from 'vs/platform/environment/common/environment';
Expand Down Expand Up @@ -44,7 +44,7 @@ export abstract class AbstractUpdateService implements IUpdateService {
}

constructor(
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@ILifecycleMainService private readonly lifecycleService: ILifecycleMainService,
@IConfigurationService protected configurationService: IConfigurationService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@IRequestService protected requestService: IRequestService,
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/update/electron-main/updateService.darwin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { Event } from 'vs/base/common/event';
import { memoize } from 'vs/base/common/decorators';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
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 { IEnvironmentService } from 'vs/platform/environment/common/environment';
Expand All @@ -28,7 +28,7 @@ export class DarwinUpdateService extends AbstractUpdateService {
@memoize private get onRawUpdateDownloaded(): Event<IUpdate> { return Event.fromNodeEventEmitter(electron.autoUpdater, 'update-downloaded', (_, releaseNotes, version, date) => ({ releaseNotes, version, productVersion: version, date })); }

constructor(
@ILifecycleService lifecycleService: ILifecycleService,
@ILifecycleMainService lifecycleService: ILifecycleMainService,
@IConfigurationService configurationService: IConfigurationService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IEnvironmentService environmentService: IEnvironmentService,
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/update/electron-main/updateService.linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import product from 'vs/platform/product/common/product';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
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 { IEnvironmentService } from 'vs/platform/environment/common/environment';
Expand All @@ -20,7 +20,7 @@ export class LinuxUpdateService extends AbstractUpdateService {
_serviceBrand: undefined;

constructor(
@ILifecycleService lifecycleService: ILifecycleService,
@ILifecycleMainService lifecycleService: ILifecycleMainService,
@IConfigurationService configurationService: IConfigurationService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IEnvironmentService environmentService: IEnvironmentService,
Expand Down
Loading

0 comments on commit a8d5382

Please sign in to comment.