mirror of
https://github.com/Microsoft/vscode
synced 2024-11-05 18:29:38 +00:00
debt - strict layer rules for more services (#175411)
This commit is contained in:
parent
35b3a1e146
commit
9bbce647b3
11 changed files with 91 additions and 42 deletions
File diff suppressed because one or more lines are too long
|
@ -68,7 +68,9 @@ const NATIVE_TYPES = [
|
|||
'INativeEnvironmentService',
|
||||
'AbstractNativeEnvironmentService',
|
||||
'INativeWindowConfiguration',
|
||||
'ICommonNativeHostService'
|
||||
'ICommonNativeHostService',
|
||||
'INativeHostService',
|
||||
'IMainProcessService'
|
||||
];
|
||||
|
||||
const RULES: IRule[] = [
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* eslint-disable local/code-layering, local/code-import-patterns */
|
||||
// TODO@bpasero remove these once utility process is the only way
|
||||
import { Server as BrowserWindowMessagePortServer } from 'vs/base/parts/ipc/electron-browser/ipc.mp';
|
||||
import { SharedProcessWorkerService } from 'vs/platform/sharedProcess/electron-browser/sharedProcessWorkerService';
|
||||
import { ILocalPtyService } from 'vs/platform/terminal/electron-sandbox/terminal';
|
||||
|
||||
import { hostname, release } from 'os';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { onUnexpectedError, setUnexpectedErrorHandler } from 'vs/base/common/errors';
|
||||
|
@ -71,7 +77,8 @@ import { UserDataSyncEnablementService } from 'vs/platform/userDataSync/common/u
|
|||
import { UserDataSyncService } from 'vs/platform/userDataSync/common/userDataSyncService';
|
||||
import { UserDataSyncChannel } from 'vs/platform/userDataSync/common/userDataSyncServiceIpc';
|
||||
import { UserDataSyncStoreManagementService, UserDataSyncStoreService } from 'vs/platform/userDataSync/common/userDataSyncStoreService';
|
||||
import { IUserDataProfileStorageService, NativeUserDataProfileStorageService } from 'vs/platform/userDataProfile/common/userDataProfileStorageService';
|
||||
import { IUserDataProfileStorageService } from 'vs/platform/userDataProfile/common/userDataProfileStorageService';
|
||||
import { NativeUserDataProfileStorageService } from 'vs/platform/userDataProfile/node/userDataProfileStorageService';
|
||||
import { ActiveWindowManager } from 'vs/platform/windows/node/windowTracker';
|
||||
import { ISignService } from 'vs/platform/sign/common/sign';
|
||||
import { SignService } from 'vs/platform/sign/node/signService';
|
||||
|
@ -112,13 +119,7 @@ import { INativeHostService } from 'vs/platform/native/common/native';
|
|||
import { UserDataAutoSyncService } from 'vs/platform/userDataSync/node/userDataAutoSyncService';
|
||||
import { ExtensionTipsService } from 'vs/platform/extensionManagement/node/extensionTipsService';
|
||||
import { IMainProcessService, MainProcessService } from 'vs/platform/ipc/common/mainProcessService';
|
||||
import { NativeStorageService } from 'vs/platform/storage/common/storageService';
|
||||
|
||||
/* eslint-disable local/code-layering, local/code-import-patterns */
|
||||
// TODO@bpasero remove these once utility process is the only way
|
||||
import { Server as BrowserWindowMessagePortServer } from 'vs/base/parts/ipc/electron-browser/ipc.mp';
|
||||
import { SharedProcessWorkerService } from 'vs/platform/sharedProcess/electron-browser/sharedProcessWorkerService';
|
||||
import { ILocalPtyService } from 'vs/platform/terminal/electron-sandbox/terminal';
|
||||
import { RemoteStorageService } from 'vs/platform/storage/common/storageService';
|
||||
|
||||
class SharedProcessMain extends Disposable {
|
||||
|
||||
|
@ -277,7 +278,7 @@ class SharedProcessMain extends Disposable {
|
|||
services.set(IConfigurationService, configurationService);
|
||||
|
||||
// Storage (global access only)
|
||||
const storageService = new NativeStorageService(undefined, { defaultProfile: userDataProfilesService.defaultProfile, currentProfile: userDataProfilesService.defaultProfile }, mainProcessService, environmentService);
|
||||
const storageService = new RemoteStorageService(undefined, { defaultProfile: userDataProfilesService.defaultProfile, currentProfile: userDataProfilesService.defaultProfile }, mainProcessService, environmentService);
|
||||
services.set(IStorageService, storageService);
|
||||
this._register(toDisposable(() => storageService.flush()));
|
||||
|
||||
|
|
|
@ -5,14 +5,11 @@
|
|||
|
||||
import { IChannel, IPCServer, IServerChannel, StaticRouter } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IRemoteService } from 'vs/platform/ipc/common/services';
|
||||
|
||||
export const IMainProcessService = createDecorator<IMainProcessService>('mainProcessService');
|
||||
|
||||
export interface IMainProcessService {
|
||||
readonly _serviceBrand: undefined;
|
||||
getChannel(channelName: string): IChannel;
|
||||
registerChannel(channelName: string, channel: IServerChannel<string>): void;
|
||||
}
|
||||
export interface IMainProcessService extends IRemoteService { }
|
||||
|
||||
/**
|
||||
* An implementation of `IMainProcessService` that leverages `IPCServer`.
|
||||
|
|
14
src/vs/platform/ipc/common/services.ts
Normal file
14
src/vs/platform/ipc/common/services.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
|
||||
export interface IRemoteService {
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
getChannel(channelName: string): IChannel;
|
||||
registerChannel(channelName: string, channel: IServerChannel<string>): void;
|
||||
}
|
|
@ -3,11 +3,12 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IChannel, IServerChannel, ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IChannel, ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { createDecorator, IInstantiationService, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/common/mainProcessService';
|
||||
import { IRemoteService } from 'vs/platform/ipc/common/services';
|
||||
|
||||
type ChannelClientCtor<T> = { new(channel: IChannel, ...args: any[]): T };
|
||||
type Remote = { getChannel(channelName: string): IChannel };
|
||||
|
@ -61,13 +62,7 @@ export function registerMainProcessRemoteService<T>(id: ServiceIdentifier<T>, ch
|
|||
|
||||
export const ISharedProcessService = createDecorator<ISharedProcessService>('sharedProcessService');
|
||||
|
||||
export interface ISharedProcessService {
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
getChannel(channelName: string): IChannel;
|
||||
registerChannel(channelName: string, channel: IServerChannel<string>): void;
|
||||
|
||||
export interface ISharedProcessService extends IRemoteService {
|
||||
notifyRestored(): void;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
|
|||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { IStorage, Storage } from 'vs/base/parts/storage/common/storage';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/common/mainProcessService';
|
||||
import { IRemoteService } from 'vs/platform/ipc/common/services';
|
||||
import { AbstractStorageService, isProfileUsingDefaultStorage, StorageScope, WillSaveStateReason } from 'vs/platform/storage/common/storage';
|
||||
import { ApplicationStorageDatabaseClient, ProfileStorageDatabaseClient, WorkspaceStorageDatabaseClient } from 'vs/platform/storage/common/storageIpc';
|
||||
import { isUserDataProfile, IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
|
||||
import { IAnyWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
export class NativeStorageService extends AbstractStorageService {
|
||||
export class RemoteStorageService extends AbstractStorageService {
|
||||
|
||||
private readonly applicationStorageProfile = this.initialProfiles.defaultProfile;
|
||||
private readonly applicationStorage = this.createApplicationStorage();
|
||||
|
@ -30,14 +30,14 @@ export class NativeStorageService extends AbstractStorageService {
|
|||
constructor(
|
||||
private readonly initialWorkspace: IAnyWorkspaceIdentifier | undefined,
|
||||
private readonly initialProfiles: { defaultProfile: IUserDataProfile; currentProfile: IUserDataProfile },
|
||||
private readonly mainProcessService: IMainProcessService,
|
||||
private readonly remoteService: IRemoteService,
|
||||
private readonly environmentService: IEnvironmentService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
private createApplicationStorage(): IStorage {
|
||||
const storageDataBaseClient = this._register(new ApplicationStorageDatabaseClient(this.mainProcessService.getChannel('storage')));
|
||||
const storageDataBaseClient = this._register(new ApplicationStorageDatabaseClient(this.remoteService.getChannel('storage')));
|
||||
const applicationStorage = this._register(new Storage(storageDataBaseClient));
|
||||
|
||||
this._register(applicationStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.APPLICATION, key)));
|
||||
|
@ -63,7 +63,7 @@ export class NativeStorageService extends AbstractStorageService {
|
|||
|
||||
profileStorage = this.applicationStorage;
|
||||
} else {
|
||||
const storageDataBaseClient = this.profileStorageDisposables.add(new ProfileStorageDatabaseClient(this.mainProcessService.getChannel('storage'), profile));
|
||||
const storageDataBaseClient = this.profileStorageDisposables.add(new ProfileStorageDatabaseClient(this.remoteService.getChannel('storage'), profile));
|
||||
profileStorage = this.profileStorageDisposables.add(new Storage(storageDataBaseClient));
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ export class NativeStorageService extends AbstractStorageService {
|
|||
|
||||
let workspaceStorage: IStorage | undefined = undefined;
|
||||
if (workspace) {
|
||||
const storageDataBaseClient = this.workspaceStorageDisposables.add(new WorkspaceStorageDatabaseClient(this.mainProcessService.getChannel('storage'), workspace));
|
||||
const storageDataBaseClient = this.workspaceStorageDisposables.add(new WorkspaceStorageDatabaseClient(this.remoteService.getChannel('storage'), workspace));
|
||||
workspaceStorage = this.workspaceStorageDisposables.add(new Storage(storageDataBaseClient));
|
||||
|
||||
this.workspaceStorageDisposables.add(workspaceStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.WORKSPACE, key)));
|
||||
|
|
|
@ -8,7 +8,7 @@ import { IStorage, IStorageDatabase, Storage } from 'vs/base/parts/storage/commo
|
|||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { AbstractStorageService, IStorageService, IStorageValueChangeEvent, StorageScope, StorageTarget, isProfileUsingDefaultStorage } from 'vs/platform/storage/common/storage';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/common/mainProcessService';
|
||||
import { IRemoteService } from 'vs/platform/ipc/common/services';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ApplicationStorageDatabaseClient, ProfileStorageDatabaseClient } from 'vs/platform/storage/common/storageIpc';
|
||||
import { IUserDataProfile, IUserDataProfilesService, reviveProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
|
||||
|
@ -126,20 +126,20 @@ export abstract class AbstractUserDataProfileStorageService extends Disposable i
|
|||
protected abstract createStorageDatabase(profile: IUserDataProfile): Promise<IStorageDatabase>;
|
||||
}
|
||||
|
||||
export class NativeUserDataProfileStorageService extends AbstractUserDataProfileStorageService implements IUserDataProfileStorageService {
|
||||
export class RemoteUserDataProfileStorageService extends AbstractUserDataProfileStorageService implements IUserDataProfileStorageService {
|
||||
|
||||
private readonly _onDidChange: Emitter<IProfileStorageChanges>;
|
||||
readonly onDidChange: Event<IProfileStorageChanges>;
|
||||
|
||||
constructor(
|
||||
@IMainProcessService private readonly mainProcessService: IMainProcessService,
|
||||
@IUserDataProfilesService userDataProfilesService: IUserDataProfilesService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@ILogService logService: ILogService,
|
||||
private readonly remoteService: IRemoteService,
|
||||
userDataProfilesService: IUserDataProfilesService,
|
||||
storageService: IStorageService,
|
||||
logService: ILogService,
|
||||
) {
|
||||
super(storageService);
|
||||
|
||||
const channel = mainProcessService.getChannel('profileStorageListener');
|
||||
const channel = remoteService.getChannel('profileStorageListener');
|
||||
const disposable = this._register(new MutableDisposable());
|
||||
this._onDidChange = this._register(new Emitter<IProfileStorageChanges>({
|
||||
// Start listening to profile storage changes only when someone is listening
|
||||
|
@ -159,7 +159,7 @@ export class NativeUserDataProfileStorageService extends AbstractUserDataProfile
|
|||
}
|
||||
|
||||
protected async createStorageDatabase(profile: IUserDataProfile): Promise<IStorageDatabase> {
|
||||
const storageChannel = this.mainProcessService.getChannel('storage');
|
||||
const storageChannel = this.remoteService.getChannel('storage');
|
||||
return isProfileUsingDefaultStorage(profile) ? new ApplicationStorageDatabaseClient(storageChannel) : new ProfileStorageDatabaseClient(storageChannel, profile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,23 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IUserDataProfileStorageService, NativeUserDataProfileStorageService } from 'vs/platform/userDataProfile/common/userDataProfileStorageService';
|
||||
import { IUserDataProfileStorageService, RemoteUserDataProfileStorageService } from 'vs/platform/userDataProfile/common/userDataProfileStorageService';
|
||||
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/common/mainProcessService';
|
||||
|
||||
export class NativeUserDataProfileStorageService extends RemoteUserDataProfileStorageService {
|
||||
|
||||
constructor(
|
||||
@IMainProcessService mainProcessService: IMainProcessService,
|
||||
@IUserDataProfilesService userDataProfilesService: IUserDataProfilesService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@ILogService logService: ILogService,
|
||||
) {
|
||||
super(mainProcessService, userDataProfilesService, storageService, logService);
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IUserDataProfileStorageService, NativeUserDataProfileStorageService, InstantiationType.Delayed);
|
||||
|
|
|
@ -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.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/common/mainProcessService';
|
||||
import { RemoteUserDataProfileStorageService } from 'vs/platform/userDataProfile/common/userDataProfileStorageService';
|
||||
|
||||
export class NativeUserDataProfileStorageService extends RemoteUserDataProfileStorageService {
|
||||
|
||||
constructor(
|
||||
@IMainProcessService mainProcessService: IMainProcessService,
|
||||
@IUserDataProfilesService userDataProfilesService: IUserDataProfilesService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@ILogService logService: ILogService,
|
||||
) {
|
||||
super(mainProcessService, userDataProfilesService, storageService, logService);
|
||||
}
|
||||
}
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/common/mainProcessService';
|
||||
import { NativeStorageService } from 'vs/platform/storage/common/storageService';
|
||||
import { RemoteStorageService } from 'vs/platform/storage/common/storageService';
|
||||
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
|
||||
import { IAnyWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
|
||||
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
|
||||
|
||||
export class NativeWorkbenchStorageService extends NativeStorageService {
|
||||
export class NativeWorkbenchStorageService extends RemoteStorageService {
|
||||
|
||||
constructor(
|
||||
workspace: IAnyWorkspaceIdentifier | undefined,
|
||||
|
|
Loading…
Reference in a new issue