Skip to content

Commit b81bbef

Browse files
authored
move IUserDataProfileService to workbench (microsoft#152427)
1 parent 3d4a1bc commit b81bbef

File tree

32 files changed

+68
-80
lines changed

32 files changed

+68
-80
lines changed

src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,11 @@ import { InspectProfilingService as V8InspectProfilingService } from 'vs/platfor
100100
import { IV8InspectProfilingService } from 'vs/platform/profiling/common/profiling';
101101
import { IExtensionsScannerService } from 'vs/platform/extensionManagement/common/extensionsScannerService';
102102
import { ExtensionsScannerService } from 'vs/platform/extensionManagement/node/extensionsScannerService';
103-
import { IUserDataProfileService, IUserDataProfilesService, UserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
103+
import { IUserDataProfilesService, UserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
104104
import { ExtensionsProfileScannerService, IExtensionsProfileScannerService } from 'vs/platform/extensionManagement/common/extensionsProfileScannerService';
105105
import { PolicyChannelClient } from 'vs/platform/policy/common/policyIpc';
106106
import { IPolicyService, NullPolicyService } from 'vs/platform/policy/common/policy';
107107
import { OneDataSystemAppender } from 'vs/platform/telemetry/node/1dsAppender';
108-
import { UserDataProfileService } from 'vs/platform/userDataProfile/common/userDataProfileService';
109108
// import { OneDataSystemAppender } from 'vs/platform/telemetry/node/1dsAppender';
110109

111110
class SharedProcessMain extends Disposable {
@@ -236,15 +235,12 @@ class SharedProcessMain extends Disposable {
236235
const userDataProfilesService = this._register(new UserDataProfilesService(this.configuration.defaultProfile, environmentService, fileService, logService));
237236
services.set(IUserDataProfilesService, userDataProfilesService);
238237

239-
const userDataProfileService = this._register(new UserDataProfileService(userDataProfilesService.defaultProfile, userDataProfilesService.defaultProfile));
240-
services.set(IUserDataProfileService, userDataProfileService);
241-
242238
// Configuration
243239
const configurationService = this._register(new ConfigurationService(userDataProfilesService.defaultProfile.settingsResource, fileService, policyService, logService));
244240
services.set(IConfigurationService, configurationService);
245241

246242
// Storage (global access only)
247-
const storageService = new NativeStorageService(undefined, mainProcessService, userDataProfileService, environmentService);
243+
const storageService = new NativeStorageService(undefined, { defaultProfile: userDataProfilesService.defaultProfile, currentProfile: userDataProfilesService.defaultProfile }, mainProcessService, environmentService);
248244
services.set(IStorageService, storageService);
249245
this._register(toDisposable(() => storageService.flush()));
250246

src/vs/platform/storage/browser/storageService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { assertIsDefined } from 'vs/base/common/types';
1313
import { InMemoryStorageDatabase, isStorageItemsChangeEvent, IStorage, IStorageDatabase, IStorageItemsChangeEvent, IUpdateRequest, Storage } from 'vs/base/parts/storage/common/storage';
1414
import { ILogService } from 'vs/platform/log/common/log';
1515
import { AbstractStorageService, IS_NEW_KEY, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
16-
import { IUserDataProfile, IUserDataProfileService } from 'vs/platform/userDataProfile/common/userDataProfile';
16+
import { IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
1717
import { IAnyWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
1818

1919
export class BrowserStorageService extends AbstractStorageService {
@@ -42,12 +42,12 @@ export class BrowserStorageService extends AbstractStorageService {
4242

4343
constructor(
4444
private readonly payload: IAnyWorkspaceIdentifier,
45+
currentProfile: IUserDataProfile,
4546
@ILogService private readonly logService: ILogService,
46-
@IUserDataProfileService userDataProfileService: IUserDataProfileService
4747
) {
4848
super({ flushInterval: BrowserStorageService.BROWSER_DEFAULT_FLUSH_INTERVAL });
4949

50-
this.globalStorageProfile = userDataProfileService.currentProfile;
50+
this.globalStorageProfile = currentProfile;
5151
}
5252

5353
private getId(scope: StorageScope): string {

src/vs/platform/storage/electron-sandbox/storageService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
1111
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/services';
1212
import { AbstractStorageService, StorageScope, WillSaveStateReason } from 'vs/platform/storage/common/storage';
1313
import { ApplicationStorageDatabaseClient, GlobalStorageDatabaseClient, WorkspaceStorageDatabaseClient } from 'vs/platform/storage/common/storageIpc';
14-
import { IUserDataProfile, IUserDataProfileService } from 'vs/platform/userDataProfile/common/userDataProfile';
14+
import { IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
1515
import { IAnyWorkspaceIdentifier, IEmptyWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
1616

1717
export class NativeStorageService extends AbstractStorageService {
@@ -29,16 +29,16 @@ export class NativeStorageService extends AbstractStorageService {
2929

3030
constructor(
3131
workspace: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | IEmptyWorkspaceIdentifier | undefined,
32+
{ defaultProfile, currentProfile }: { defaultProfile: IUserDataProfile; currentProfile: IUserDataProfile },
3233
private readonly mainProcessService: IMainProcessService,
33-
userDataProfileService: IUserDataProfileService,
3434
private readonly environmentService: IEnvironmentService
3535
) {
3636
super();
3737

38-
this.applicationStorageProfile = userDataProfileService.defaultProfile;
38+
this.applicationStorageProfile = defaultProfile;
3939

4040
this.applicationStorage = this.createApplicationStorage();
41-
this.globalStorage = this.createGlobalStorage(userDataProfileService.currentProfile);
41+
this.globalStorage = this.createGlobalStorage(currentProfile);
4242
this.workspaceStorage = this.createWorkspaceStorage(workspace);
4343
}
4444

src/vs/platform/storage/test/browser/storageService.test.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { BrowserStorageService, IndexedDBStorageDatabase } from 'vs/platform/sto
1818
import { StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
1919
import { createSuite } from 'vs/platform/storage/test/common/storageService.test';
2020
import { IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
21-
import { UserDataProfileService } from 'vs/platform/userDataProfile/common/userDataProfileService';
2221

2322
async function createStorageService(): Promise<[DisposableStore, BrowserStorageService]> {
2423
const disposables = new DisposableStore();
@@ -31,20 +30,6 @@ async function createStorageService(): Promise<[DisposableStore, BrowserStorageS
3130

3231
const profilesRoot = URI.file('/profiles').with({ scheme: Schemas.inMemory });
3332

34-
const inMemoryDefaultProfileRoot = joinPath(profilesRoot, 'default');
35-
const inMemoryDefaultProfile: IUserDataProfile = {
36-
id: 'id',
37-
name: 'inMemory',
38-
isDefault: true,
39-
location: inMemoryDefaultProfileRoot,
40-
globalStorageHome: joinPath(inMemoryDefaultProfileRoot, 'globalStorageHome'),
41-
settingsResource: joinPath(inMemoryDefaultProfileRoot, 'settingsResource'),
42-
keybindingsResource: joinPath(inMemoryDefaultProfileRoot, 'keybindingsResource'),
43-
tasksResource: joinPath(inMemoryDefaultProfileRoot, 'tasksResource'),
44-
snippetsHome: joinPath(inMemoryDefaultProfileRoot, 'snippetsHome'),
45-
extensionsResource: joinPath(inMemoryDefaultProfileRoot, 'extensionsResource')
46-
};
47-
4833
const inMemoryExtraProfileRoot = joinPath(profilesRoot, 'extra');
4934
const inMemoryExtraProfile: IUserDataProfile = {
5035
id: 'id',
@@ -59,9 +44,7 @@ async function createStorageService(): Promise<[DisposableStore, BrowserStorageS
5944
extensionsResource: joinPath(inMemoryExtraProfileRoot, 'extensionsResource')
6045
};
6146

62-
const userDataProfileService = new UserDataProfileService(inMemoryDefaultProfile, inMemoryExtraProfile);
63-
64-
const storageService = disposables.add(new BrowserStorageService({ id: 'workspace-storage-test' }, logService, userDataProfileService));
47+
const storageService = disposables.add(new BrowserStorageService({ id: 'workspace-storage-test' }, inMemoryExtraProfile, logService));
6548

6649
await storageService.initialize();
6750

src/vs/platform/userDataProfile/common/userDataProfile.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ export interface IUserDataProfile {
4747
readonly extensionsResource: URI | undefined;
4848
}
4949

50-
export const IUserDataProfileService = createDecorator<IUserDataProfileService>('IUserDataProfileService');
51-
export interface IUserDataProfileService {
52-
readonly _serviceBrand: undefined;
53-
readonly defaultProfile: IUserDataProfile;
54-
readonly onDidChangeCurrentProfile: Event<IUserDataProfile>;
55-
readonly currentProfile: IUserDataProfile;
56-
updateCurrentProfile(currentProfile: IUserDataProfile): void;
57-
}
58-
5950
export function isUserDataProfile(thing: unknown): thing is IUserDataProfile {
6051
const candidate = thing as IUserDataProfile | undefined;
6152

src/vs/workbench/browser/web.main.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
7373
import { IProgressService } from 'vs/platform/progress/common/progress';
7474
import { DelayedLogChannel } from 'vs/workbench/services/output/common/delayedLogChannel';
7575
import { dirname, joinPath } from 'vs/base/common/resources';
76-
import { IUserDataProfileService, IUserDataProfilesService, UserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
76+
import { IUserDataProfilesService, UserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
7777
import { NullPolicyService } from 'vs/platform/policy/common/policy';
7878
import { IRemoteExplorerService, TunnelSource } from 'vs/workbench/services/remote/common/remoteExplorerService';
7979
import { DisposableTunnel } from 'vs/platform/tunnel/common/tunnel';
8080
import { ILabelService } from 'vs/platform/label/common/label';
81-
import { UserDataProfileService } from 'vs/platform/userDataProfile/common/userDataProfileService';
81+
import { UserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfileService';
82+
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
8283

8384
export class BrowserMain extends Disposable {
8485

@@ -454,7 +455,7 @@ export class BrowserMain extends Disposable {
454455
}
455456

456457
private async createStorageService(payload: IAnyWorkspaceIdentifier, logService: ILogService, userDataProfileService: IUserDataProfileService): Promise<IStorageService> {
457-
const storageService = new BrowserStorageService(payload, logService, userDataProfileService);
458+
const storageService = new BrowserStorageService(payload, userDataProfileService.currentProfile, logService);
458459

459460
try {
460461
await storageService.initialize();

src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { EditorOption } from 'vs/editor/common/config/editorOptions';
3232
import { equals } from 'vs/base/common/arrays';
3333
import { assertIsDefined } from 'vs/base/common/types';
3434
import { isEqual } from 'vs/base/common/resources';
35-
import { IUserDataProfileService } from 'vs/platform/userDataProfile/common/userDataProfile';
35+
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
3636

3737
const NLS_LAUNCH_MESSAGE = nls.localize('defineKeybinding.start', "Define Keybinding");
3838
const NLS_KB_LAYOUT_ERROR_MESSAGE = nls.localize('defineKeybinding.kbLayoutErrorMessage', "You won't be able to produce this key combination under your current keyboard layout.");

src/vs/workbench/contrib/preferences/browser/preferences.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle
4343
import { KeybindingsEditorInput } from 'vs/workbench/services/preferences/browser/keybindingsEditorInput';
4444
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
4545
import { SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
46-
import { IUserDataProfileService } from 'vs/platform/userDataProfile/common/userDataProfile';
46+
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
4747

4848
const SETTINGS_EDITOR_COMMAND_SEARCH = 'settings.action.search';
4949

src/vs/workbench/contrib/preferences/common/preferencesContribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEdit
2323
import { RegisteredEditorPriority, IEditorResolverService } from 'vs/workbench/services/editor/common/editorResolverService';
2424
import { ITextEditorService } from 'vs/workbench/services/textfile/common/textEditorService';
2525
import { DEFAULT_SETTINGS_EDITOR_SETTING, FOLDER_SETTINGS_PATH, IPreferencesService, USE_SPLIT_JSON_SETTING } from 'vs/workbench/services/preferences/common/preferences';
26-
import { IUserDataProfileService } from 'vs/platform/userDataProfile/common/userDataProfile';
26+
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
2727

2828
const schemaRegistry = Registry.as<JSONContributionRegistry.IJSONContributionRegistry>(JSONContributionRegistry.Extensions.JSONContribution);
2929

src/vs/workbench/contrib/snippets/browser/configureSnippets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
1818
import { isValidBasename } from 'vs/base/common/extpath';
1919
import { joinPath, basename } from 'vs/base/common/resources';
2020
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
21-
import { IUserDataProfileService } from 'vs/platform/userDataProfile/common/userDataProfile';
21+
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
2222

2323
namespace ISnippetPick {
2424
export function is(thing: object | undefined): thing is ISnippetPick {

0 commit comments

Comments
 (0)