From f73cd164d0762ff058859fd28b4ce23bbc8acb8f Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 21 Jun 2022 15:06:08 +0200 Subject: [PATCH] storage - rename `GLOBAL` to `APPLICATION` (#152730) --- src/vs/code/electron-main/app.ts | 4 +- .../common/extensionStorage.ts | 6 +- .../electron-sandbox/extensionTipsService.ts | 8 +- .../common/serviceMachineId.ts | 4 +- src/vs/platform/storage/common/storage.ts | 74 ++++++++--------- src/vs/platform/storage/common/storageIpc.ts | 8 +- .../storage/electron-main/storageIpc.ts | 12 +-- .../storage/electron-main/storageMain.ts | 6 +- .../electron-main/storageMainService.ts | 80 +++++++++---------- .../electron-sandbox/storageService.ts | 40 +++++----- .../test/common/storageService.test.ts | 20 ++--- .../electron-main/storageMainService.test.ts | 46 +++++------ .../common/userDataAutoSyncService.ts | 24 +++--- .../common/userDataSyncEnablementService.ts | 10 +-- .../common/userDataSyncMachines.ts | 4 +- .../common/userDataSyncService.ts | 6 +- .../common/userDataSyncStoreService.ts | 32 ++++---- .../platform/windows/electron-main/window.ts | 6 +- .../workspacesHistoryMainService.ts | 12 +-- src/vs/workbench/common/memento.ts | 22 ++--- .../experiments/common/experimentService.ts | 42 +++++----- .../experimentService.test.ts | 2 +- .../electron-sandbox/remoteExtensionsInit.ts | 4 +- .../localization.contribution.ts | 4 +- .../surveys/browser/ces.contribution.ts | 10 +-- .../browser/languageSurveys.contribution.ts | 38 ++++----- .../surveys/browser/nps.contribution.ts | 26 +++--- .../userDataSync/browser/userDataSync.ts | 4 +- .../browser/gettingStarted.ts | 2 +- .../browser/webExtensionsScannerService.ts | 4 +- .../browser/keyboardLayoutService.ts | 4 +- .../common/notificationService.ts | 4 +- .../storage/browser/storageService.ts | 52 ++++++------ .../test/browser/storageService.test.ts | 6 +- .../browser/workbenchCommonProperties.ts | 8 +- .../workbenchCommonProperties.ts | 4 +- .../electron-browser/commonProperties.test.ts | 2 +- .../services/userData/browser/userDataInit.ts | 2 +- .../browser/userDataSyncWorkbenchService.ts | 12 +-- .../workspaces/common/workspaceTrust.ts | 4 +- .../test/common/workspaceTrust.test.ts | 2 +- .../test/browser/workbenchTestServices.ts | 6 +- src/vs/workbench/test/common/memento.test.ts | 30 +++---- 43 files changed, 348 insertions(+), 348 deletions(-) diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 369ed2b12e5..4f0f279867b 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -70,7 +70,7 @@ import { SharedProcess } from 'vs/platform/sharedProcess/electron-main/sharedPro import { ISignService } from 'vs/platform/sign/common/sign'; import { IStateMainService } from 'vs/platform/state/electron-main/state'; import { StorageDatabaseChannel } from 'vs/platform/storage/electron-main/storageIpc'; -import { GlobalStorageMainService, IGlobalStorageMainService, IStorageMainService, StorageMainService } from 'vs/platform/storage/electron-main/storageMainService'; +import { ApplicationStorageMainService, IApplicationStorageMainService, IStorageMainService, StorageMainService } from 'vs/platform/storage/electron-main/storageMainService'; import { resolveCommonProperties } from 'vs/platform/telemetry/common/commonProperties'; import { ITelemetryService, machineIdKey, TelemetryLevel } from 'vs/platform/telemetry/common/telemetry'; import { TelemetryAppenderClient } from 'vs/platform/telemetry/common/telemetryIpc'; @@ -648,7 +648,7 @@ export class CodeApplication extends Disposable { // Storage services.set(IStorageMainService, new SyncDescriptor(StorageMainService)); - services.set(IGlobalStorageMainService, new SyncDescriptor(GlobalStorageMainService)); + services.set(IApplicationStorageMainService, new SyncDescriptor(ApplicationStorageMainService)); // External terminal if (isWindows) { diff --git a/src/vs/platform/extensionManagement/common/extensionStorage.ts b/src/vs/platform/extensionManagement/common/extensionStorage.ts index e6518edc228..52b35c6cb28 100644 --- a/src/vs/platform/extensionManagement/common/extensionStorage.ts +++ b/src/vs/platform/extensionManagement/common/extensionStorage.ts @@ -194,7 +194,7 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto } private get migrationList(): [string, string][] { - const value = this.storageService.get('extensionStorage.migrationList', StorageScope.GLOBAL, '[]'); + const value = this.storageService.get('extensionStorage.migrationList', StorageScope.APPLICATION, '[]'); try { const migrationList = JSON.parse(value); if (isArray(migrationList)) { @@ -206,9 +206,9 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto private set migrationList(migrationList: [string, string][]) { if (migrationList.length) { - this.storageService.store('extensionStorage.migrationList', JSON.stringify(migrationList), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store('extensionStorage.migrationList', JSON.stringify(migrationList), StorageScope.APPLICATION, StorageTarget.MACHINE); } else { - this.storageService.remove('extensionStorage.migrationList', StorageScope.GLOBAL); + this.storageService.remove('extensionStorage.migrationList', StorageScope.APPLICATION); } } diff --git a/src/vs/platform/extensionManagement/electron-sandbox/extensionTipsService.ts b/src/vs/platform/extensionManagement/electron-sandbox/extensionTipsService.ts index a8d9a94f50f..c6e03e0bf5f 100644 --- a/src/vs/platform/extensionManagement/electron-sandbox/extensionTipsService.ts +++ b/src/vs/platform/extensionManagement/electron-sandbox/extensionTipsService.ts @@ -256,7 +256,7 @@ export class ExtensionTipsService extends BaseExtensionTipsService { } private getLastPromptedMediumExeTime(): number { - let value = this.storageService.getNumber(lastPromptedMediumImpExeTimeStorageKey, StorageScope.GLOBAL); + let value = this.storageService.getNumber(lastPromptedMediumImpExeTimeStorageKey, StorageScope.APPLICATION); if (!value) { value = Date.now(); this.updateLastPromptedMediumExeTime(value); @@ -265,17 +265,17 @@ export class ExtensionTipsService extends BaseExtensionTipsService { } private updateLastPromptedMediumExeTime(value: number): void { - this.storageService.store(lastPromptedMediumImpExeTimeStorageKey, value, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(lastPromptedMediumImpExeTimeStorageKey, value, StorageScope.APPLICATION, StorageTarget.MACHINE); } private getPromptedExecutableTips(): IStringDictionary { - return JSON.parse(this.storageService.get(promptedExecutableTipsStorageKey, StorageScope.GLOBAL, '{}')); + return JSON.parse(this.storageService.get(promptedExecutableTipsStorageKey, StorageScope.APPLICATION, '{}')); } private addToRecommendedExecutables(exeName: string, tips: IExecutableBasedExtensionTip[]) { const promptedExecutableTips = this.getPromptedExecutableTips(); promptedExecutableTips[exeName] = tips.map(({ extensionId }) => extensionId.toLowerCase()); - this.storageService.store(promptedExecutableTipsStorageKey, JSON.stringify(promptedExecutableTips), StorageScope.GLOBAL, StorageTarget.USER); + this.storageService.store(promptedExecutableTipsStorageKey, JSON.stringify(promptedExecutableTips), StorageScope.APPLICATION, StorageTarget.USER); } private groupByInstalled(recommendationsToSuggest: string[], local: ILocalExtension[]): { installed: string[]; uninstalled: string[] } { diff --git a/src/vs/platform/externalServices/common/serviceMachineId.ts b/src/vs/platform/externalServices/common/serviceMachineId.ts index b65d22c9c21..6767e7d7225 100644 --- a/src/vs/platform/externalServices/common/serviceMachineId.ts +++ b/src/vs/platform/externalServices/common/serviceMachineId.ts @@ -10,7 +10,7 @@ import { IFileService } from 'vs/platform/files/common/files'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; export async function getServiceMachineId(environmentService: IEnvironmentService, fileService: IFileService, storageService: IStorageService | undefined): Promise { - let uuid: string | null = storageService ? storageService.get('storage.serviceMachineId', StorageScope.GLOBAL) || null : null; + let uuid: string | null = storageService ? storageService.get('storage.serviceMachineId', StorageScope.APPLICATION) || null : null; if (uuid) { return uuid; } @@ -31,7 +31,7 @@ export async function getServiceMachineId(environmentService: IEnvironmentServic } } - storageService?.store('storage.serviceMachineId', uuid, StorageScope.GLOBAL, StorageTarget.MACHINE); + storageService?.store('storage.serviceMachineId', uuid, StorageScope.APPLICATION, StorageTarget.MACHINE); return uuid; } diff --git a/src/vs/platform/storage/common/storage.ts b/src/vs/platform/storage/common/storage.ts index 345c96b4436..bb28f7cb775 100644 --- a/src/vs/platform/storage/common/storage.ts +++ b/src/vs/platform/storage/common/storage.ts @@ -168,7 +168,7 @@ export const enum StorageScope { /** * The stored data will be scoped to all workspaces across all profiles. */ - GLOBAL = -1, + APPLICATION = -1, /** * The stored data will be scoped to all workspaces of the same profile. @@ -311,8 +311,8 @@ export abstract class AbstractStorageService extends Disposable implements IStor // Clear our cached version which is now out of date switch (scope) { - case StorageScope.GLOBAL: - this._globalKeyTargets = undefined; + case StorageScope.APPLICATION: + this._applicationKeyTargets = undefined; break; case StorageScope.PROFILE: this._profileKeyTargets = undefined; @@ -454,19 +454,19 @@ export abstract class AbstractStorageService extends Disposable implements IStor return this._profileKeyTargets; } - private _globalKeyTargets: IKeyTargets | undefined = undefined; - private get globalKeyTargets(): IKeyTargets { - if (!this._globalKeyTargets) { - this._globalKeyTargets = this.loadKeyTargets(StorageScope.GLOBAL); + private _applicationKeyTargets: IKeyTargets | undefined = undefined; + private get applicationKeyTargets(): IKeyTargets { + if (!this._applicationKeyTargets) { + this._applicationKeyTargets = this.loadKeyTargets(StorageScope.APPLICATION); } - return this._globalKeyTargets; + return this._applicationKeyTargets; } private getKeyTargets(scope: StorageScope): IKeyTargets { switch (scope) { - case StorageScope.GLOBAL: - return this.globalKeyTargets; + case StorageScope.APPLICATION: + return this.applicationKeyTargets; case StorageScope.PROFILE: return this.profileKeyTargets; default: @@ -496,7 +496,7 @@ export abstract class AbstractStorageService extends Disposable implements IStor // Signal event to collect changes this._onWillSaveState.fire({ reason }); - const globalStorage = this.getStorage(StorageScope.GLOBAL); + const applicationStorage = this.getStorage(StorageScope.APPLICATION); const profileStorage = this.getStorage(StorageScope.PROFILE); const workspaceStorage = this.getStorage(StorageScope.WORKSPACE); @@ -505,7 +505,7 @@ export abstract class AbstractStorageService extends Disposable implements IStor // Unspecific reason: just wait when data is flushed case WillSaveStateReason.NONE: await Promises.settled([ - globalStorage?.whenFlushed() ?? Promise.resolve(), + applicationStorage?.whenFlushed() ?? Promise.resolve(), profileStorage?.whenFlushed() ?? Promise.resolve(), workspaceStorage?.whenFlushed() ?? Promise.resolve() ]); @@ -515,7 +515,7 @@ export abstract class AbstractStorageService extends Disposable implements IStor // and not hit any delays that might be there case WillSaveStateReason.SHUTDOWN: await Promises.settled([ - globalStorage?.flush(0) ?? Promise.resolve(), + applicationStorage?.flush(0) ?? Promise.resolve(), profileStorage?.flush(0) ?? Promise.resolve(), workspaceStorage?.flush(0) ?? Promise.resolve() ]); @@ -524,15 +524,15 @@ export abstract class AbstractStorageService extends Disposable implements IStor } async log(): Promise { - const globalItems = this.getStorage(StorageScope.GLOBAL)?.items ?? new Map(); + const applicationItems = this.getStorage(StorageScope.APPLICATION)?.items ?? new Map(); const profileItems = this.getStorage(StorageScope.PROFILE)?.items ?? new Map(); const workspaceItems = this.getStorage(StorageScope.WORKSPACE)?.items ?? new Map(); return logStorage( - globalItems, + applicationItems, profileItems, workspaceItems, - this.getLogDetails(StorageScope.GLOBAL) ?? '', + this.getLogDetails(StorageScope.APPLICATION) ?? '', this.getLogDetails(StorageScope.PROFILE) ?? '', this.getLogDetails(StorageScope.WORKSPACE) ?? '' ); @@ -595,7 +595,7 @@ export abstract class AbstractStorageService extends Disposable implements IStor export class InMemoryStorageService extends AbstractStorageService { - private readonly globalStorage = this._register(new Storage(new InMemoryStorageDatabase())); + private readonly applicationStorage = this._register(new Storage(new InMemoryStorageDatabase())); private readonly profileStorage = this._register(new Storage(new InMemoryStorageDatabase())); private readonly workspaceStorage = this._register(new Storage(new InMemoryStorageDatabase())); @@ -604,13 +604,13 @@ export class InMemoryStorageService extends AbstractStorageService { this._register(this.workspaceStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.WORKSPACE, key))); this._register(this.profileStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.PROFILE, key))); - this._register(this.globalStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.GLOBAL, key))); + this._register(this.applicationStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.APPLICATION, key))); } protected getStorage(scope: StorageScope): IStorage { switch (scope) { - case StorageScope.GLOBAL: - return this.globalStorage; + case StorageScope.APPLICATION: + return this.applicationStorage; case StorageScope.PROFILE: return this.profileStorage; default: @@ -620,8 +620,8 @@ export class InMemoryStorageService extends AbstractStorageService { protected getLogDetails(scope: StorageScope): string | undefined { switch (scope) { - case StorageScope.GLOBAL: - return 'inMemory (global)'; + case StorageScope.APPLICATION: + return 'inMemory (application)'; case StorageScope.PROFILE: return 'inMemory (profile)'; default: @@ -640,7 +640,7 @@ export class InMemoryStorageService extends AbstractStorageService { } } -export async function logStorage(global: Map, profile: Map, workspace: Map, globalPath: string, profilePath: string, workspacePath: string): Promise { +export async function logStorage(application: Map, profile: Map, workspace: Map, applicationPath: string, profilePath: string, workspacePath: string): Promise { const safeParse = (value: string) => { try { return JSON.parse(value); @@ -649,11 +649,11 @@ export async function logStorage(global: Map, profile: Map(); - const globalItemsParsed = new Map(); - global.forEach((value, key) => { - globalItems.set(key, value); - globalItemsParsed.set(key, safeParse(value)); + const applicationItems = new Map(); + const applicationItemsParsed = new Map(); + application.forEach((value, key) => { + applicationItems.set(key, value); + applicationItemsParsed.set(key, safeParse(value)); }); const profileItems = new Map(); @@ -670,21 +670,21 @@ export async function logStorage(global: Map, profile: Map { - globalValues.push({ key, value }); + const applicationValues: { key: string; value: string }[] = []; + applicationItems.forEach((value, key) => { + applicationValues.push({ key, value }); }); - console.table(globalValues); + console.table(applicationValues); console.groupEnd(); - console.log(globalItemsParsed); + console.log(applicationItemsParsed); - if (globalPath !== profilePath) { + if (applicationPath !== profilePath) { console.group(`Storage: Profile (path: ${profilePath}, profile specific)`); const profileValues: { key: string; value: string }[] = []; profileItems.forEach((value, key) => { diff --git a/src/vs/platform/storage/common/storageIpc.ts b/src/vs/platform/storage/common/storageIpc.ts index 1861df621f8..d5be460c5da 100644 --- a/src/vs/platform/storage/common/storageIpc.ts +++ b/src/vs/platform/storage/common/storageIpc.ts @@ -20,13 +20,13 @@ export interface IBaseSerializableStorageRequest { /** * Profile to correlate storage. Only used when no * workspace is provided. Can be undefined to denote - * global scope. + * application scope. */ readonly profile: UriDto | undefined; /** * Workspace to correlate storage. Can be undefined to - * denote global or profile scope depending on profile. + * denote application or profile scope depending on profile. */ readonly workspace: ISerializedWorkspaceIdentifier | ISerializedSingleFolderWorkspaceIdentifier | IEmptyWorkspaceIdentifier | undefined; } @@ -102,7 +102,7 @@ abstract class BaseProfileAwareStorageDatabaseClient extends BaseStorageDatabase } } -export class GlobalStorageDatabaseClient extends BaseProfileAwareStorageDatabaseClient { +export class ApplicationStorageDatabaseClient extends BaseProfileAwareStorageDatabaseClient { constructor(channel: IChannel) { super(channel, undefined); @@ -110,7 +110,7 @@ export class GlobalStorageDatabaseClient extends BaseProfileAwareStorageDatabase async close(): Promise { - // The global storage database is shared across all instances so + // The application storage database is shared across all instances so // we do not close it from the window. However we dispose the // listener for external changes because we no longer interested in it. diff --git a/src/vs/platform/storage/electron-main/storageIpc.ts b/src/vs/platform/storage/electron-main/storageIpc.ts index e83c1de8fa9..7fb51b9eb54 100644 --- a/src/vs/platform/storage/electron-main/storageIpc.ts +++ b/src/vs/platform/storage/electron-main/storageIpc.ts @@ -18,7 +18,7 @@ export class StorageDatabaseChannel extends Disposable implements IServerChannel private static readonly STORAGE_CHANGE_DEBOUNCE_TIME = 100; - private readonly onDidChangeGlobalStorageEmitter = this._register(new Emitter()); + private readonly onDidChangeApplicationStorageEmitter = this._register(new Emitter()); private readonly mapProfileToOnDidChangeProfileStorageEmitter = new Map>(); @@ -28,7 +28,7 @@ export class StorageDatabaseChannel extends Disposable implements IServerChannel ) { super(); - this.registerStorageChangeListeners(storageMainService.globalStorage, this.onDidChangeGlobalStorageEmitter); + this.registerStorageChangeListeners(storageMainService.applicationStorage, this.onDidChangeApplicationStorageEmitter); } //#region Storage Change Events @@ -76,9 +76,9 @@ export class StorageDatabaseChannel extends Disposable implements IServerChannel case 'onDidChangeStorage': { const profile = arg.profile ? revive(arg.profile) : undefined; - // Without profile: global scope + // Without profile: application scope if (!profile) { - return this.onDidChangeGlobalStorageEmitter.event; + return this.onDidChangeApplicationStorageEmitter.event; } // With profile: profile scope for the profile @@ -137,13 +137,13 @@ export class StorageDatabaseChannel extends Disposable implements IServerChannel } else if (profile) { storage = this.storageMainService.profileStorage(profile); } else { - storage = this.storageMainService.globalStorage; + storage = this.storageMainService.applicationStorage; } try { await storage.init(); } catch (error) { - this.logService.error(`StorageIPC#init: Unable to init ${workspace ? 'workspace' : profile ? 'profile' : 'global'} storage due to ${error}`); + this.logService.error(`StorageIPC#init: Unable to init ${workspace ? 'workspace' : profile ? 'profile' : 'application'} storage due to ${error}`); } return storage; diff --git a/src/vs/platform/storage/electron-main/storageMain.ts b/src/vs/platform/storage/electron-main/storageMain.ts index d4aa023cd21..adc96240b6f 100644 --- a/src/vs/platform/storage/electron-main/storageMain.ts +++ b/src/vs/platform/storage/electron-main/storageMain.ts @@ -31,7 +31,7 @@ export interface IStorageMainOptions { } /** - * Provides access to global, profile and workspace storage from + * Provides access to application, profile and workspace storage from * the electron-main side that is the owner of all storage connections. */ export interface IStorageMain extends IDisposable { @@ -295,7 +295,7 @@ export class ProfileStorageMain extends BaseProfileAwareStorageMain { } } -export class GlobalStorageMain extends BaseProfileAwareStorageMain { +export class ApplicationStorageMain extends BaseProfileAwareStorageMain { constructor( options: IStorageMainOptions, @@ -309,7 +309,7 @@ export class GlobalStorageMain extends BaseProfileAwareStorageMain { protected override async doInit(storage: IStorage): Promise { await super.doInit(storage); - // Apply telemetry values as part of the global storage initialization + // Apply telemetry values as part of the application storage initialization this.updateTelemetryState(storage); } diff --git a/src/vs/platform/storage/electron-main/storageMainService.ts b/src/vs/platform/storage/electron-main/storageMainService.ts index 2a37d96ba75..34effaba035 100644 --- a/src/vs/platform/storage/electron-main/storageMainService.ts +++ b/src/vs/platform/storage/electron-main/storageMainService.ts @@ -12,12 +12,12 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' import { ILifecycleMainService, LifecycleMainPhase, ShutdownReason } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { ILogService } from 'vs/platform/log/common/log'; import { AbstractStorageService, IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; -import { GlobalStorageMain, ProfileStorageMain, InMemoryStorageMain, IStorageMain, IStorageMainOptions, WorkspaceStorageMain } from 'vs/platform/storage/electron-main/storageMain'; +import { ApplicationStorageMain, ProfileStorageMain, InMemoryStorageMain, IStorageMain, IStorageMainOptions, WorkspaceStorageMain } from 'vs/platform/storage/electron-main/storageMain'; import { IUserDataProfile, IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile'; import { IUserDataProfilesMainService } from 'vs/platform/userDataProfile/electron-main/userDataProfile'; import { IEmptyWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace'; -//#region Storage Main Service (intent: make global, profile and workspace storage accessible to windows from main process) +//#region Storage Main Service (intent: make application, profile and workspace storage accessible to windows from main process) export const IStorageMainService = createDecorator('storageMainService'); @@ -26,13 +26,13 @@ export interface IStorageMainService { readonly _serviceBrand: undefined; /** - * Provides access to the global storage shared across all + * Provides access to the application storage shared across all * windows and all profiles. * * Note: DO NOT use this for reading/writing from the main process! - * Rather use `IGlobalStorageMainService` for that purpose. + * Rather use `IApplicationStorageMainService` for that purpose. */ - globalStorage: IStorageMain; + applicationStorage: IStorageMain; /** * Provides access to the profile storage shared across all windows @@ -78,11 +78,11 @@ export class StorageMainService extends Disposable implements IStorageMainServic private registerListeners(): void { - // Global Storage: Warmup when any window opens + // Application Storage: Warmup when any window opens (async () => { await this.lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen); - this.globalStorage.init(); + this.applicationStorage.init(); })(); this._register(this.lifecycleMainService.onWillLoadWindow(e => { @@ -105,8 +105,8 @@ export class StorageMainService extends Disposable implements IStorageMainServic // Remember shutdown reason this.shutdownReason = e.reason; - // Global Storage - e.join(this.globalStorage.close()); + // Application Storage + e.join(this.applicationStorage.close()); // Profile Storage(s) for (const [, profileStorage] of this.mapProfileToStorage) { @@ -137,20 +137,20 @@ export class StorageMainService extends Disposable implements IStorageMainServic })); } - //#region Global Storage + //#region Application Storage - readonly globalStorage = this.createGlobalStorage(); + readonly applicationStorage = this.createApplicationStorage(); - private createGlobalStorage(): IStorageMain { - this.logService.trace(`StorageMainService: creating global storage`); + private createApplicationStorage(): IStorageMain { + this.logService.trace(`StorageMainService: creating application storage`); - const globalStorage = new GlobalStorageMain(this.getStorageOptions(), this.userDataProfilesService, this.logService, this.fileService); + const applicationStorage = new ApplicationStorageMain(this.getStorageOptions(), this.userDataProfilesService, this.logService, this.fileService); - once(globalStorage.onDidCloseStorage)(() => { - this.logService.trace(`StorageMainService: closed global storage`); + once(applicationStorage.onDidCloseStorage)(() => { + this.logService.trace(`StorageMainService: closed application storage`); }); - return globalStorage; + return applicationStorage; } //#endregion @@ -161,7 +161,7 @@ export class StorageMainService extends Disposable implements IStorageMainServic profileStorage(profile: IUserDataProfile): IStorageMain { if (profile.isDefault) { - return this.globalStorage; // for default profile, use global storage + return this.applicationStorage; // for default profile, use application storage } let profileStorage = this.mapProfileToStorage.get(profile.id); @@ -238,15 +238,15 @@ export class StorageMainService extends Disposable implements IStorageMainServic //#endregion -//#region Global Main Storage Service (intent: use global storage from main process) +//#region Application Main Storage Service (intent: use application storage from main process) -export const IGlobalStorageMainService = createDecorator('globalStorageMainService'); +export const IApplicationStorageMainService = createDecorator('applicationStorageMainService'); /** * A specialized `IStorageService` interface that only allows - * access to the `StorageScope.GLOBAL` scope. + * access to the `StorageScope.APPLICATION` scope. */ -export interface IGlobalStorageMainService extends IStorageService { +export interface IApplicationStorageMainService extends IStorageService { /** * Important: unlike other storage services in the renderer, the @@ -254,38 +254,38 @@ export interface IGlobalStorageMainService extends IStorageService { * storage is being initialized while a window opens to reduce * pressure on startup. * - * As such, any client wanting to access global storage from the + * As such, any client wanting to access application storage from the * main process needs to wait for `whenReady`, otherwise there is * a chance that the service operates on an in-memory store that * is not backed by any persistent DB. */ readonly whenReady: Promise; - get(key: string, scope: StorageScope.GLOBAL, fallbackValue: string): string; - get(key: string, scope: StorageScope.GLOBAL, fallbackValue?: string): string | undefined; + get(key: string, scope: StorageScope.APPLICATION, fallbackValue: string): string; + get(key: string, scope: StorageScope.APPLICATION, fallbackValue?: string): string | undefined; - getBoolean(key: string, scope: StorageScope.GLOBAL, fallbackValue: boolean): boolean; - getBoolean(key: string, scope: StorageScope.GLOBAL, fallbackValue?: boolean): boolean | undefined; + getBoolean(key: string, scope: StorageScope.APPLICATION, fallbackValue: boolean): boolean; + getBoolean(key: string, scope: StorageScope.APPLICATION, fallbackValue?: boolean): boolean | undefined; - getNumber(key: string, scope: StorageScope.GLOBAL, fallbackValue: number): number; - getNumber(key: string, scope: StorageScope.GLOBAL, fallbackValue?: number): number | undefined; + getNumber(key: string, scope: StorageScope.APPLICATION, fallbackValue: number): number; + getNumber(key: string, scope: StorageScope.APPLICATION, fallbackValue?: number): number | undefined; - store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope.GLOBAL, target: StorageTarget): void; + store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope.APPLICATION, target: StorageTarget): void; - remove(key: string, scope: StorageScope.GLOBAL): void; + remove(key: string, scope: StorageScope.APPLICATION): void; - keys(scope: StorageScope.GLOBAL, target: StorageTarget): string[]; + keys(scope: StorageScope.APPLICATION, target: StorageTarget): string[]; switch(): never; - isNew(scope: StorageScope.GLOBAL): boolean; + isNew(scope: StorageScope.APPLICATION): boolean; } -export class GlobalStorageMainService extends AbstractStorageService implements IGlobalStorageMainService { +export class ApplicationStorageMainService extends AbstractStorageService implements IApplicationStorageMainService { declare readonly _serviceBrand: undefined; - readonly whenReady = this.storageMainService.globalStorage.whenInit; + readonly whenReady = this.storageMainService.applicationStorage.whenInit; constructor( @IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService, @@ -296,22 +296,22 @@ export class GlobalStorageMainService extends AbstractStorageService implements protected doInitialize(): Promise { - // global storage is being initialized as part + // application storage is being initialized as part // of the first window opening, so we do not trigger // it here but can join it - return this.storageMainService.globalStorage.whenInit; + return this.storageMainService.applicationStorage.whenInit; } protected getStorage(scope: StorageScope): IStorage | undefined { - if (scope === StorageScope.GLOBAL) { - return this.storageMainService.globalStorage.storage; + if (scope === StorageScope.APPLICATION) { + return this.storageMainService.applicationStorage.storage; } return undefined; // any other scope is unsupported from main process } protected getLogDetails(scope: StorageScope): string | undefined { - if (scope === StorageScope.GLOBAL) { + if (scope === StorageScope.APPLICATION) { return this.userDataProfilesService.defaultProfile.globalStorageHome.fsPath; } diff --git a/src/vs/platform/storage/electron-sandbox/storageService.ts b/src/vs/platform/storage/electron-sandbox/storageService.ts index 1fa304cf8cb..8d82451d937 100644 --- a/src/vs/platform/storage/electron-sandbox/storageService.ts +++ b/src/vs/platform/storage/electron-sandbox/storageService.ts @@ -10,14 +10,14 @@ import { IStorage, Storage } from 'vs/base/parts/storage/common/storage'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/services'; import { AbstractStorageService, StorageScope, WillSaveStateReason } from 'vs/platform/storage/common/storage'; -import { GlobalStorageDatabaseClient, ProfileStorageDatabaseClient, WorkspaceStorageDatabaseClient } from 'vs/platform/storage/common/storageIpc'; +import { ApplicationStorageDatabaseClient, ProfileStorageDatabaseClient, WorkspaceStorageDatabaseClient } from 'vs/platform/storage/common/storageIpc'; import { IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile'; import { IAnyWorkspaceIdentifier, IEmptyWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace'; export class NativeStorageService extends AbstractStorageService { - private readonly globalStorage: IStorage; - private readonly globalStorageProfile: IUserDataProfile; + private readonly applicationStorage: IStorage; + private readonly applicationStorageProfile: IUserDataProfile; private profileStorage: IStorage; private profileStorageProfile: IUserDataProfile | undefined = undefined; @@ -35,20 +35,20 @@ export class NativeStorageService extends AbstractStorageService { ) { super(); - this.globalStorageProfile = defaultProfile; + this.applicationStorageProfile = defaultProfile; - this.globalStorage = this.createGlobalStorage(); + this.applicationStorage = this.createApplicationStorage(); this.profileStorage = this.createProfileStorage(currentProfile); this.workspaceStorage = this.createWorkspaceStorage(workspace); } - private createGlobalStorage(): IStorage { - const storageDataBaseClient = this._register(new GlobalStorageDatabaseClient(this.mainProcessService.getChannel('storage'))); - const globalStorage = this._register(new Storage(storageDataBaseClient)); + private createApplicationStorage(): IStorage { + const storageDataBaseClient = this._register(new ApplicationStorageDatabaseClient(this.mainProcessService.getChannel('storage'))); + const applicationStorage = this._register(new Storage(storageDataBaseClient)); - this._register(globalStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.GLOBAL, key))); + this._register(applicationStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.APPLICATION, key))); - return globalStorage; + return applicationStorage; } private createProfileStorage(profile: IUserDataProfile): IStorage { @@ -63,11 +63,11 @@ export class NativeStorageService extends AbstractStorageService { if (profile.isDefault) { // If we are in default profile, the profile storage is - // actually the same as global storage. As such we + // actually the same as application storage. As such we // avoid creating the storage library a second time on // the same DB. - profileStorage = this.globalStorage; + profileStorage = this.applicationStorage; } else { const storageDataBaseClient = this.profileStorageDisposables.add(new ProfileStorageDatabaseClient(this.mainProcessService.getChannel('storage'), profile)); profileStorage = this.profileStorageDisposables.add(new Storage(storageDataBaseClient)); @@ -103,7 +103,7 @@ export class NativeStorageService extends AbstractStorageService { // Init all storage locations await Promises.settled([ - this.globalStorage.init(), + this.applicationStorage.init(), this.profileStorage.init(), this.workspaceStorage?.init() ?? Promise.resolve() ]); @@ -111,8 +111,8 @@ export class NativeStorageService extends AbstractStorageService { protected getStorage(scope: StorageScope): IStorage | undefined { switch (scope) { - case StorageScope.GLOBAL: - return this.globalStorage; + case StorageScope.APPLICATION: + return this.applicationStorage; case StorageScope.PROFILE: return this.profileStorage; default: @@ -122,8 +122,8 @@ export class NativeStorageService extends AbstractStorageService { protected getLogDetails(scope: StorageScope): string | undefined { switch (scope) { - case StorageScope.GLOBAL: - return this.globalStorageProfile.globalStorageHome.fsPath; + case StorageScope.APPLICATION: + return this.applicationStorageProfile.globalStorageHome.fsPath; case StorageScope.PROFILE: return this.profileStorageProfile?.globalStorageHome.fsPath; default: @@ -141,7 +141,7 @@ export class NativeStorageService extends AbstractStorageService { // Do it await Promises.settled([ - this.globalStorage.close(), + this.applicationStorage.close(), this.profileStorage.close(), this.workspaceStorage?.close() ?? Promise.resolve() ]); @@ -152,8 +152,8 @@ export class NativeStorageService extends AbstractStorageService { const oldItems = oldProfileStorage.items; // Close old profile storage but only if this is - // different from global storage! - if (oldProfileStorage !== this.globalStorage) { + // different from application storage! + if (oldProfileStorage !== this.applicationStorage) { await oldProfileStorage.close(); } diff --git a/src/vs/platform/storage/test/common/storageService.test.ts b/src/vs/platform/storage/test/common/storageService.test.ts index e1bc7f83c08..f30977bceb5 100644 --- a/src/vs/platform/storage/test/common/storageService.test.ts +++ b/src/vs/platform/storage/test/common/storageService.test.ts @@ -18,8 +18,8 @@ export function createSuite(params: { setup: () => Pr return params.teardown(storageService); }); - test('Get Data, Integer, Boolean (global)', () => { - storeData(StorageScope.GLOBAL); + test('Get Data, Integer, Boolean (application)', () => { + storeData(StorageScope.APPLICATION); }); test('Get Data, Integer, Boolean (profile)', () => { @@ -71,8 +71,8 @@ export function createSuite(params: { setup: () => Pr strictEqual(storageService.getBoolean('test.getBooleanDefault', scope, true), true); } - test('Remove Data (global)', () => { - removeData(StorageScope.GLOBAL); + test('Remove Data (application)', () => { + removeData(StorageScope.APPLICATION); }); test('Remove Data (profile)', () => { @@ -105,14 +105,14 @@ export function createSuite(params: { setup: () => Pr storageService.onDidChangeValue(e => storageValueChangeEvent = e); // Empty - for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.GLOBAL]) { + for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.APPLICATION]) { for (const target of [StorageTarget.MACHINE, StorageTarget.USER]) { strictEqual(storageService.keys(scope, target).length, 0); } } // Add values - for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.GLOBAL]) { + for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.APPLICATION]) { for (const target of [StorageTarget.MACHINE, StorageTarget.USER]) { storageTargetEvent = Object.create(null); storageValueChangeEvent = Object.create(null); @@ -142,7 +142,7 @@ export function createSuite(params: { setup: () => Pr } // Remove values - for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.GLOBAL]) { + for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.APPLICATION]) { for (const target of [StorageTarget.MACHINE, StorageTarget.USER]) { const keysLength = storageService.keys(scope, target).length; @@ -161,7 +161,7 @@ export function createSuite(params: { setup: () => Pr } // Remove all - for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.GLOBAL]) { + for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.APPLICATION]) { for (const target of [StorageTarget.MACHINE, StorageTarget.USER]) { const keys = storageService.keys(scope, target); @@ -174,7 +174,7 @@ export function createSuite(params: { setup: () => Pr } // Adding undefined or null removes value - for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.GLOBAL]) { + for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.APPLICATION]) { for (const target of [StorageTarget.MACHINE, StorageTarget.USER]) { storageService.store('test.target1', 'value1', scope, target); strictEqual(storageService.keys(scope, target).length, 1); @@ -194,7 +194,7 @@ export function createSuite(params: { setup: () => Pr } // Target change - for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.GLOBAL]) { + for (const scope of [StorageScope.WORKSPACE, StorageScope.PROFILE, StorageScope.APPLICATION]) { storageTargetEvent = undefined; storageService.store('test.target5', 'value1', scope, StorageTarget.MACHINE); ok(storageTargetEvent); diff --git a/src/vs/platform/storage/test/electron-main/storageMainService.test.ts b/src/vs/platform/storage/test/electron-main/storageMainService.test.ts index 3359c28c7d5..b4269d5ec3d 100644 --- a/src/vs/platform/storage/test/electron-main/storageMainService.test.ts +++ b/src/vs/platform/storage/test/electron-main/storageMainService.test.ts @@ -97,7 +97,7 @@ suite('StorageMainService', function () { async function testStorage(storage: IStorageMain, scope: StorageScope): Promise { // Telemetry: added after init unless workspace/profile scoped - if (scope === StorageScope.GLOBAL) { + if (scope === StorageScope.APPLICATION) { strictEqual(storage.items.size, 0); await storage.init(); strictEqual(typeof storage.get(firstSessionDateStorageKey), 'string'); @@ -151,10 +151,10 @@ suite('StorageMainService', function () { return new TestStorageMainService(new NullLogService(), environmentService, new UserDataProfilesMainService(new StateMainService(environmentService, new NullLogService(), fileService), new UriIdentityService(fileService), environmentService, fileService, new NullLogService()), lifecycleMainService, fileService); } - test('basics (global)', function () { + test('basics (application)', function () { const storageMainService = createStorageService(); - return testStorage(storageMainService.globalStorage, StorageScope.GLOBAL); + return testStorage(storageMainService.applicationStorage, StorageScope.APPLICATION); }); test('basics (profile)', function () { @@ -190,23 +190,23 @@ suite('StorageMainService', function () { didCloseProfileStorage = true; }); - const globalStorage = storageMainService.globalStorage; - let didCloseGlobalStorage = false; - globalStorage.onDidCloseStorage(() => { - didCloseGlobalStorage = true; + const applicationStorage = storageMainService.applicationStorage; + let didCloseApplicationStorage = false; + applicationStorage.onDidCloseStorage(() => { + didCloseApplicationStorage = true; }); - strictEqual(globalStorage, storageMainService.globalStorage); // same instance as long as not closed + strictEqual(applicationStorage, storageMainService.applicationStorage); // same instance as long as not closed strictEqual(profileStorage, storageMainService.profileStorage(profile)); // same instance as long as not closed strictEqual(workspaceStorage, storageMainService.workspaceStorage(workspace)); // same instance as long as not closed - await globalStorage.init(); + await applicationStorage.init(); await profileStorage.init(); await workspaceStorage.init(); await lifecycleMainService.fireOnWillShutdown(); - strictEqual(didCloseGlobalStorage, true); + strictEqual(didCloseApplicationStorage, true); strictEqual(didCloseProfileStorage, true); strictEqual(didCloseWorkspaceStorage, true); @@ -236,17 +236,17 @@ suite('StorageMainService', function () { didCloseProfileStorage = true; }); - const globalStorage = storageMainService.globalStorage; - let didCloseGlobalStorage = false; - globalStorage.onDidCloseStorage(() => { - didCloseGlobalStorage = true; + const applicationStorage = storageMainService.applicationStorage; + let didCloseApplicationStorage = false; + applicationStorage.onDidCloseStorage(() => { + didCloseApplicationStorage = true; }); - await globalStorage.close(); + await applicationStorage.close(); await profileStorage.close(); await workspaceStorage.close(); - strictEqual(didCloseGlobalStorage, true); + strictEqual(didCloseApplicationStorage, true); strictEqual(didCloseProfileStorage, true); strictEqual(didCloseWorkspaceStorage, true); }); @@ -268,21 +268,21 @@ suite('StorageMainService', function () { didCloseProfileStorage = true; }); - const globalStorage = storageMainService.globalStorage; - let didCloseGlobalStorage = false; - globalStorage.onDidCloseStorage(() => { - didCloseGlobalStorage = true; + const applicationtorage = storageMainService.applicationStorage; + let didCloseApplicationStorage = false; + applicationtorage.onDidCloseStorage(() => { + didCloseApplicationStorage = true; }); - globalStorage.init(); + applicationtorage.init(); profileStorage.init(); workspaceStorage.init(); - await globalStorage.close(); + await applicationtorage.close(); await profileStorage.close(); await workspaceStorage.close(); - strictEqual(didCloseGlobalStorage, true); + strictEqual(didCloseApplicationStorage, true); strictEqual(didCloseProfileStorage, true); strictEqual(didCloseWorkspaceStorage, true); }); diff --git a/src/vs/platform/userDataSync/common/userDataAutoSyncService.ts b/src/vs/platform/userDataSync/common/userDataAutoSyncService.ts index 19db5e01a89..bf59598603b 100644 --- a/src/vs/platform/userDataSync/common/userDataAutoSyncService.ts +++ b/src/vs/platform/userDataSync/common/userDataAutoSyncService.ts @@ -54,26 +54,26 @@ export class UserDataAutoSyncService extends Disposable implements IUserDataAuto private lastSyncUrl: URI | undefined; private get syncUrl(): URI | undefined { - const value = this.storageService.get(storeUrlKey, StorageScope.GLOBAL); + const value = this.storageService.get(storeUrlKey, StorageScope.APPLICATION); return value ? URI.parse(value) : undefined; } private set syncUrl(syncUrl: URI | undefined) { if (syncUrl) { - this.storageService.store(storeUrlKey, syncUrl.toString(), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(storeUrlKey, syncUrl.toString(), StorageScope.APPLICATION, StorageTarget.MACHINE); } else { - this.storageService.remove(storeUrlKey, StorageScope.GLOBAL); + this.storageService.remove(storeUrlKey, StorageScope.APPLICATION); } } private previousProductQuality: string | undefined; private get productQuality(): string | undefined { - return this.storageService.get(productQualityKey, StorageScope.GLOBAL); + return this.storageService.get(productQualityKey, StorageScope.APPLICATION); } private set productQuality(productQuality: string | undefined) { if (productQuality) { - this.storageService.store(productQualityKey, productQuality, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(productQualityKey, productQuality, StorageScope.APPLICATION, StorageTarget.MACHINE); } else { - this.storageService.remove(productQualityKey, StorageScope.GLOBAL); + this.storageService.remove(productQualityKey, StorageScope.APPLICATION); } } @@ -194,7 +194,7 @@ export class UserDataAutoSyncService extends Disposable implements IUserDataAuto this.updateEnablement(false); // Reset Session - this.storageService.remove(sessionIdKey, StorageScope.GLOBAL); + this.storageService.remove(sessionIdKey, StorageScope.APPLICATION); // Reset if (everywhere) { @@ -315,7 +315,7 @@ export class UserDataAutoSyncService extends Disposable implements IUserDataAuto } private async disableMachineEventually(): Promise { - this.storageService.store(disableMachineEventuallyKey, true, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(disableMachineEventuallyKey, true, StorageScope.APPLICATION, StorageTarget.MACHINE); await timeout(1000 * 60 * 10); // Return if got stopped meanwhile. @@ -332,11 +332,11 @@ export class UserDataAutoSyncService extends Disposable implements IUserDataAuto } private hasToDisableMachineEventually(): boolean { - return this.storageService.getBoolean(disableMachineEventuallyKey, StorageScope.GLOBAL, false); + return this.storageService.getBoolean(disableMachineEventuallyKey, StorageScope.APPLICATION, false); } private stopDisableMachineEventually(): void { - this.storageService.remove(disableMachineEventuallyKey, StorageScope.GLOBAL); + this.storageService.remove(disableMachineEventuallyKey, StorageScope.APPLICATION); } private sources: string[] = []; @@ -481,7 +481,7 @@ class AutoSync extends Disposable { } } - const sessionId = this.storageService.get(sessionIdKey, StorageScope.GLOBAL); + const sessionId = this.storageService.get(sessionIdKey, StorageScope.APPLICATION); // Server session is different from client session if (sessionId && this.manifest && sessionId !== this.manifest.session) { if (this.hasSyncServiceChanged()) { @@ -521,7 +521,7 @@ class AutoSync extends Disposable { // Update local session id if (this.manifest && this.manifest.session !== sessionId) { - this.storageService.store(sessionIdKey, this.manifest.session, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(sessionIdKey, this.manifest.session, StorageScope.APPLICATION, StorageTarget.MACHINE); } // Return if cancellation is requested diff --git a/src/vs/platform/userDataSync/common/userDataSyncEnablementService.ts b/src/vs/platform/userDataSync/common/userDataSyncEnablementService.ts index ac12a674403..dfb2cccaea1 100644 --- a/src/vs/platform/userDataSync/common/userDataSyncEnablementService.ts +++ b/src/vs/platform/userDataSync/common/userDataSyncEnablementService.ts @@ -46,7 +46,7 @@ export class UserDataSyncEnablementService extends Disposable implements IUserDa case 'off': return false; } - return this.storageService.getBoolean(enablementKey, StorageScope.GLOBAL, false); + return this.storageService.getBoolean(enablementKey, StorageScope.APPLICATION, false); } canToggleEnablement(): boolean { @@ -58,11 +58,11 @@ export class UserDataSyncEnablementService extends Disposable implements IUserDa return; } this.telemetryService.publicLog2<{ enabled: boolean }, SyncEnablementClassification>(enablementKey, { enabled }); - this.storageService.store(enablementKey, enabled, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(enablementKey, enabled, StorageScope.APPLICATION, StorageTarget.MACHINE); } isResourceEnabled(resource: SyncResource): boolean { - return this.storageService.getBoolean(getEnablementKey(resource), StorageScope.GLOBAL, true); + return this.storageService.getBoolean(getEnablementKey(resource), StorageScope.APPLICATION, true); } setResourceEnablement(resource: SyncResource, enabled: boolean): void { @@ -77,11 +77,11 @@ export class UserDataSyncEnablementService extends Disposable implements IUserDa } private storeResourceEnablement(resourceEnablementKey: string, enabled: boolean): void { - this.storageService.store(resourceEnablementKey, enabled, StorageScope.GLOBAL, isWeb ? StorageTarget.USER /* sync in web */ : StorageTarget.MACHINE); + this.storageService.store(resourceEnablementKey, enabled, StorageScope.APPLICATION, isWeb ? StorageTarget.USER /* sync in web */ : StorageTarget.MACHINE); } private onDidStorageChange(storageChangeEvent: IStorageValueChangeEvent): void { - if (storageChangeEvent.scope !== StorageScope.GLOBAL) { + if (storageChangeEvent.scope !== StorageScope.APPLICATION) { return; } diff --git a/src/vs/platform/userDataSync/common/userDataSyncMachines.ts b/src/vs/platform/userDataSync/common/userDataSyncMachines.ts index 43b71b2ab05..1158727d42c 100644 --- a/src/vs/platform/userDataSync/common/userDataSyncMachines.ts +++ b/src/vs/platform/userDataSync/common/userDataSyncMachines.ts @@ -132,7 +132,7 @@ export class UserDataSyncMachinesService extends Disposable implements IUserData await this.writeMachinesData(machineData); const currentMachineId = await this.currentMachineIdPromise; if (machineId === currentMachineId) { - this.storageService.store(currentMachineNameKey, name, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(currentMachineNameKey, name, StorageScope.APPLICATION, StorageTarget.MACHINE); } } } @@ -149,7 +149,7 @@ export class UserDataSyncMachinesService extends Disposable implements IUserData } private computeCurrentMachineName(machines: IMachineData[]): string { - const previousName = this.storageService.get(currentMachineNameKey, StorageScope.GLOBAL); + const previousName = this.storageService.get(currentMachineNameKey, StorageScope.APPLICATION); if (previousName) { return previousName; } diff --git a/src/vs/platform/userDataSync/common/userDataSyncService.ts b/src/vs/platform/userDataSync/common/userDataSyncService.ts index 4845ad05da6..d5e5b74cb7f 100644 --- a/src/vs/platform/userDataSync/common/userDataSyncService.ts +++ b/src/vs/platform/userDataSync/common/userDataSyncService.ts @@ -85,7 +85,7 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ ) { super(); this.updateStatus([]); - this._lastSyncTime = this.storageService.getNumber(LAST_SYNC_TIME_KEY, StorageScope.GLOBAL, undefined); + this._lastSyncTime = this.storageService.getNumber(LAST_SYNC_TIME_KEY, StorageScope.APPLICATION, undefined); } async createSyncTask(manifest: IUserDataManifest | null, disableCache?: boolean): Promise { @@ -372,7 +372,7 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ async resetLocal(): Promise { this.checkEnablement(); - this.storageService.remove(LAST_SYNC_TIME_KEY, StorageScope.GLOBAL); + this.storageService.remove(LAST_SYNC_TIME_KEY, StorageScope.APPLICATION); if (this.synchronizers.value) { for (const synchroniser of this.synchronizers.value.enabled) { try { @@ -451,7 +451,7 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ private updateLastSyncTime(): void { if (this.status === SyncStatus.Idle) { this._lastSyncTime = new Date().getTime(); - this.storageService.store(LAST_SYNC_TIME_KEY, this._lastSyncTime, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(LAST_SYNC_TIME_KEY, this._lastSyncTime, StorageScope.APPLICATION, StorageTarget.MACHINE); this._onDidChangeLastSyncTime.fire(this._lastSyncTime); } } diff --git a/src/vs/platform/userDataSync/common/userDataSyncStoreService.ts b/src/vs/platform/userDataSync/common/userDataSyncStoreService.ts index 8ae695baae4..5d926223d60 100644 --- a/src/vs/platform/userDataSync/common/userDataSyncStoreService.ts +++ b/src/vs/platform/userDataSync/common/userDataSyncStoreService.ts @@ -44,10 +44,10 @@ export abstract class AbstractUserDataSyncStoreManagementService extends Disposa get userDataSyncStore(): UserDataSyncStore | undefined { return this._userDataSyncStore; } protected get userDataSyncStoreType(): UserDataSyncStoreType | undefined { - return this.storageService.get(SYNC_SERVICE_URL_TYPE, StorageScope.GLOBAL) as UserDataSyncStoreType; + return this.storageService.get(SYNC_SERVICE_URL_TYPE, StorageScope.APPLICATION) as UserDataSyncStoreType; } protected set userDataSyncStoreType(type: UserDataSyncStoreType | undefined) { - this.storageService.store(SYNC_SERVICE_URL_TYPE, type, StorageScope.GLOBAL, isWeb ? StorageTarget.USER /* sync in web */ : StorageTarget.MACHINE); + this.storageService.store(SYNC_SERVICE_URL_TYPE, type, StorageScope.APPLICATION, isWeb ? StorageTarget.USER /* sync in web */ : StorageTarget.MACHINE); } constructor( @@ -57,7 +57,7 @@ export abstract class AbstractUserDataSyncStoreManagementService extends Disposa ) { super(); this.updateUserDataSyncStore(); - this._register(Event.filter(storageService.onDidChangeValue, e => e.key === SYNC_SERVICE_URL_TYPE && e.scope === StorageScope.GLOBAL && this.userDataSyncStoreType !== this.userDataSyncStore?.type)(() => this.updateUserDataSyncStore())); + this._register(Event.filter(storageService.onDidChangeValue, e => e.key === SYNC_SERVICE_URL_TYPE && e.scope === StorageScope.APPLICATION && this.userDataSyncStoreType !== this.userDataSyncStore?.type)(() => this.updateUserDataSyncStore())); } protected updateUserDataSyncStore(): void { @@ -115,16 +115,16 @@ export class UserDataSyncStoreManagementService extends AbstractUserDataSyncStor ) { super(productService, configurationService, storageService); - const previousConfigurationSyncStore = this.storageService.get(SYNC_PREVIOUS_STORE, StorageScope.GLOBAL); + const previousConfigurationSyncStore = this.storageService.get(SYNC_PREVIOUS_STORE, StorageScope.APPLICATION); if (previousConfigurationSyncStore) { this.previousConfigurationSyncStore = JSON.parse(previousConfigurationSyncStore); } const syncStore = this.productService[CONFIGURATION_SYNC_STORE_KEY]; if (syncStore) { - this.storageService.store(SYNC_PREVIOUS_STORE, JSON.stringify(syncStore), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(SYNC_PREVIOUS_STORE, JSON.stringify(syncStore), StorageScope.APPLICATION, StorageTarget.MACHINE); } else { - this.storageService.remove(SYNC_PREVIOUS_STORE, StorageScope.GLOBAL); + this.storageService.remove(SYNC_PREVIOUS_STORE, StorageScope.APPLICATION); } } @@ -202,7 +202,7 @@ export class UserDataSyncStoreClient extends Disposable implements IUserDataSync } private initDonotMakeRequestsUntil(): void { - const donotMakeRequestsUntil = this.storageService.getNumber(DONOT_MAKE_REQUESTS_UNTIL_KEY, StorageScope.GLOBAL); + const donotMakeRequestsUntil = this.storageService.getNumber(DONOT_MAKE_REQUESTS_UNTIL_KEY, StorageScope.APPLICATION); if (donotMakeRequestsUntil && Date.now() < donotMakeRequestsUntil) { this.setDonotMakeRequestsUntil(new Date(donotMakeRequestsUntil)); } @@ -219,11 +219,11 @@ export class UserDataSyncStoreClient extends Disposable implements IUserDataSync } if (this._donotMakeRequestsUntil) { - this.storageService.store(DONOT_MAKE_REQUESTS_UNTIL_KEY, this._donotMakeRequestsUntil.getTime(), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(DONOT_MAKE_REQUESTS_UNTIL_KEY, this._donotMakeRequestsUntil.getTime(), StorageScope.APPLICATION, StorageTarget.MACHINE); this.resetDonotMakeRequestsUntilPromise = createCancelablePromise(token => timeout(this._donotMakeRequestsUntil!.getTime() - Date.now(), token).then(() => this.setDonotMakeRequestsUntil(undefined))); this.resetDonotMakeRequestsUntilPromise.then(null, e => null /* ignore error */); } else { - this.storageService.remove(DONOT_MAKE_REQUESTS_UNTIL_KEY, StorageScope.GLOBAL); + this.storageService.remove(DONOT_MAKE_REQUESTS_UNTIL_KEY, StorageScope.APPLICATION); } this._onDidChangeDonotMakeRequestsUntil.fire(); @@ -362,7 +362,7 @@ export class UserDataSyncStoreClient extends Disposable implements IUserDataSync } } - const currentSessionId = this.storageService.get(USER_SESSION_ID_KEY, StorageScope.GLOBAL); + const currentSessionId = this.storageService.get(USER_SESSION_ID_KEY, StorageScope.APPLICATION); if (currentSessionId && manifest && currentSessionId !== manifest.session) { // Server session is different from client session so clear cached session. @@ -376,7 +376,7 @@ export class UserDataSyncStoreClient extends Disposable implements IUserDataSync if (manifest) { // update session - this.storageService.store(USER_SESSION_ID_KEY, manifest.session, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(USER_SESSION_ID_KEY, manifest.session, StorageScope.APPLICATION, StorageTarget.MACHINE); } return manifest; @@ -397,8 +397,8 @@ export class UserDataSyncStoreClient extends Disposable implements IUserDataSync } private clearSession(): void { - this.storageService.remove(USER_SESSION_ID_KEY, StorageScope.GLOBAL); - this.storageService.remove(MACHINE_SESSION_ID_KEY, StorageScope.GLOBAL); + this.storageService.remove(USER_SESSION_ID_KEY, StorageScope.APPLICATION); + this.storageService.remove(MACHINE_SESSION_ID_KEY, StorageScope.APPLICATION); } private async request(url: string, options: IRequestOptions, successCodes: number[], token: CancellationToken): Promise { @@ -518,14 +518,14 @@ export class UserDataSyncStoreClient extends Disposable implements IUserDataSync } private addSessionHeaders(headers: IHeaders): void { - let machineSessionId = this.storageService.get(MACHINE_SESSION_ID_KEY, StorageScope.GLOBAL); + let machineSessionId = this.storageService.get(MACHINE_SESSION_ID_KEY, StorageScope.APPLICATION); if (machineSessionId === undefined) { machineSessionId = generateUuid(); - this.storageService.store(MACHINE_SESSION_ID_KEY, machineSessionId, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(MACHINE_SESSION_ID_KEY, machineSessionId, StorageScope.APPLICATION, StorageTarget.MACHINE); } headers['X-Machine-Session-Id'] = machineSessionId; - const userSessionId = this.storageService.get(USER_SESSION_ID_KEY, StorageScope.GLOBAL); + const userSessionId = this.storageService.get(USER_SESSION_ID_KEY, StorageScope.APPLICATION); if (userSessionId !== undefined) { headers['X-User-Session-Id'] = userSessionId; } diff --git a/src/vs/platform/windows/electron-main/window.ts b/src/vs/platform/windows/electron-main/window.ts index 827290138bc..6fcf7095136 100644 --- a/src/vs/platform/windows/electron-main/window.ts +++ b/src/vs/platform/windows/electron-main/window.ts @@ -29,7 +29,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import { IProductService } from 'vs/platform/product/common/productService'; import { IProtocolMainService } from 'vs/platform/protocol/electron-main/protocol'; import { resolveMarketplaceHeaders } from 'vs/platform/externalServices/common/marketplace'; -import { IGlobalStorageMainService, IStorageMainService } from 'vs/platform/storage/electron-main/storageMainService'; +import { IApplicationStorageMainService, IStorageMainService } from 'vs/platform/storage/electron-main/storageMainService'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ThemeIcon } from 'vs/platform/theme/common/themeService'; import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService'; @@ -158,7 +158,7 @@ export class CodeWindow extends Disposable implements ICodeWindow { @IPolicyService private readonly policyService: IPolicyService, @IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService, @IFileService private readonly fileService: IFileService, - @IGlobalStorageMainService private readonly globalStorageMainService: IGlobalStorageMainService, + @IApplicationStorageMainService private readonly applicationStorageMainService: IApplicationStorageMainService, @IStorageMainService private readonly storageMainService: IStorageMainService, @IConfigurationService private readonly configurationService: IConfigurationService, @IThemeMainService private readonly themeMainService: IThemeMainService, @@ -542,7 +542,7 @@ export class CodeWindow extends Disposable implements ICodeWindow { private marketplaceHeadersPromise: Promise | undefined; private getMarketplaceHeaders(): Promise { if (!this.marketplaceHeadersPromise) { - this.marketplaceHeadersPromise = resolveMarketplaceHeaders(this.productService.version, this.productService, this.environmentMainService, this.configurationService, this.fileService, this.globalStorageMainService); + this.marketplaceHeadersPromise = resolveMarketplaceHeaders(this.productService.version, this.productService, this.environmentMainService, this.configurationService, this.fileService, this.applicationStorageMainService); } return this.marketplaceHeadersPromise; diff --git a/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts b/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts index c4247ff6b0e..3801775bee0 100644 --- a/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts +++ b/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts @@ -19,7 +19,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { ILogService } from 'vs/platform/log/common/log'; import { StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; -import { IGlobalStorageMainService } from 'vs/platform/storage/electron-main/storageMainService'; +import { IApplicationStorageMainService } from 'vs/platform/storage/electron-main/storageMainService'; import { ICodeWindow } from 'vs/platform/window/electron-main/window'; import { IRecent, IRecentFile, IRecentFolder, IRecentlyOpened, IRecentWorkspace, isRecentFile, isRecentFolder, isRecentWorkspace, restoreRecentlyOpened, toStoreData } from 'vs/platform/workspaces/common/workspaces'; import { isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, IWorkspaceIdentifier, WORKSPACE_EXTENSION } from 'vs/platform/workspace/common/workspace'; @@ -54,7 +54,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa @ILogService private readonly logService: ILogService, @IWorkspacesManagementMainService private readonly workspacesManagementMainService: IWorkspacesManagementMainService, @ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService, - @IGlobalStorageMainService private readonly globalStorageMainService: IGlobalStorageMainService + @IApplicationStorageMainService private readonly applicationStorageMainService: IApplicationStorageMainService ) { super(); @@ -218,12 +218,12 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa private async getRecentlyOpenedFromStorage(): Promise { // Wait for global storage to be ready - await this.globalStorageMainService.whenReady; + await this.applicationStorageMainService.whenReady; let storedRecentlyOpened: object | undefined = undefined; // First try with storage service - const storedRecentlyOpenedRaw = this.globalStorageMainService.get(WorkspacesHistoryMainService.RECENTLY_OPENED_STORAGE_KEY, StorageScope.GLOBAL); + const storedRecentlyOpenedRaw = this.applicationStorageMainService.get(WorkspacesHistoryMainService.RECENTLY_OPENED_STORAGE_KEY, StorageScope.APPLICATION); if (typeof storedRecentlyOpenedRaw === 'string') { try { storedRecentlyOpened = JSON.parse(storedRecentlyOpenedRaw); @@ -238,10 +238,10 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa private async saveRecentlyOpened(recent: IRecentlyOpened): Promise { // Wait for global storage to be ready - await this.globalStorageMainService.whenReady; + await this.applicationStorageMainService.whenReady; // Store in global storage (but do not sync since this is mainly local paths) - this.globalStorageMainService.store(WorkspacesHistoryMainService.RECENTLY_OPENED_STORAGE_KEY, JSON.stringify(toStoreData(recent)), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.applicationStorageMainService.store(WorkspacesHistoryMainService.RECENTLY_OPENED_STORAGE_KEY, JSON.stringify(toStoreData(recent)), StorageScope.APPLICATION, StorageTarget.MACHINE); } private location(recent: IRecent): URI { diff --git a/src/vs/workbench/common/memento.ts b/src/vs/workbench/common/memento.ts index 795ca739e52..4c6cea09123 100644 --- a/src/vs/workbench/common/memento.ts +++ b/src/vs/workbench/common/memento.ts @@ -11,7 +11,7 @@ export type MementoObject = { [key: string]: any }; export class Memento { - private static readonly globalMementos = new Map(); + private static readonly applicationMementos = new Map(); private static readonly profileMementos = new Map(); private static readonly workspaceMementos = new Map(); @@ -48,15 +48,15 @@ export class Memento { return profileMemento.getMemento(); } - // Scope Global - case StorageScope.GLOBAL: { - let globalMemento = Memento.globalMementos.get(this.id); - if (!globalMemento) { - globalMemento = new ScopedMemento(this.id, scope, target, this.storageService); - Memento.globalMementos.set(this.id, globalMemento); + // Scope Application + case StorageScope.APPLICATION: { + let applicationMemento = Memento.applicationMementos.get(this.id); + if (!applicationMemento) { + applicationMemento = new ScopedMemento(this.id, scope, target, this.storageService); + Memento.applicationMementos.set(this.id, applicationMemento); } - return globalMemento.getMemento(); + return applicationMemento.getMemento(); } } } @@ -64,7 +64,7 @@ export class Memento { saveMemento(): void { Memento.workspaceMementos.get(this.id)?.save(); Memento.profileMementos.get(this.id)?.save(); - Memento.globalMementos.get(this.id)?.save(); + Memento.applicationMementos.get(this.id)?.save(); } static clear(scope: StorageScope): void { @@ -75,8 +75,8 @@ export class Memento { case StorageScope.PROFILE: Memento.profileMementos.clear(); break; - case StorageScope.GLOBAL: - Memento.globalMementos.clear(); + case StorageScope.APPLICATION: + Memento.applicationMementos.clear(); break; } } diff --git a/src/vs/workbench/contrib/experiments/common/experimentService.ts b/src/vs/workbench/contrib/experiments/common/experimentService.ts index 07741ba7717..235217dbc64 100644 --- a/src/vs/workbench/contrib/experiments/common/experimentService.ts +++ b/src/vs/workbench/contrib/experiments/common/experimentService.ts @@ -223,9 +223,9 @@ export class ExperimentService extends Disposable implements IExperimentService public markAsCompleted(experimentId: string): void { const storageKey = 'experiments.' + experimentId; - const experimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.GLOBAL), {}); + const experimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.APPLICATION), {}); experimentState.state = ExperimentState.Complete; - this.storageService.store(storageKey, JSON.stringify(experimentState), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(storageKey, JSON.stringify(experimentState), StorageScope.APPLICATION, StorageTarget.MACHINE); } protected async getExperiments(): Promise { @@ -255,11 +255,11 @@ export class ExperimentService extends Disposable implements IExperimentService return this.getExperiments().then(rawExperiments => { // Offline mode if (!rawExperiments) { - const allExperimentIdsFromStorage = safeParse(this.storageService.get('allExperiments', StorageScope.GLOBAL), []); + const allExperimentIdsFromStorage = safeParse(this.storageService.get('allExperiments', StorageScope.APPLICATION), []); if (Array.isArray(allExperimentIdsFromStorage)) { allExperimentIdsFromStorage.forEach(experimentId => { const storageKey = 'experiments.' + experimentId; - const experimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.GLOBAL), null); + const experimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.APPLICATION), null); if (experimentState) { this._experiments.push({ id: experimentId, @@ -278,19 +278,19 @@ export class ExperimentService extends Disposable implements IExperimentService rawExperiments = rawExperiments.filter(e => (e.schemaVersion || 0) <= currentSchemaVersion); // Clear disbaled/deleted experiments from storage - const allExperimentIdsFromStorage = safeParse(this.storageService.get('allExperiments', StorageScope.GLOBAL), []); + const allExperimentIdsFromStorage = safeParse(this.storageService.get('allExperiments', StorageScope.APPLICATION), []); const enabledExperiments = rawExperiments.filter(experiment => !!experiment.enabled).map(experiment => experiment.id.toLowerCase()); if (Array.isArray(allExperimentIdsFromStorage)) { allExperimentIdsFromStorage.forEach(experiment => { if (enabledExperiments.indexOf(experiment) === -1) { - this.storageService.remove(`experiments.${experiment}`, StorageScope.GLOBAL); + this.storageService.remove(`experiments.${experiment}`, StorageScope.APPLICATION); } }); } if (enabledExperiments.length) { - this.storageService.store('allExperiments', JSON.stringify(enabledExperiments), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store('allExperiments', JSON.stringify(enabledExperiments), StorageScope.APPLICATION, StorageTarget.MACHINE); } else { - this.storageService.remove('allExperiments', StorageScope.GLOBAL); + this.storageService.remove('allExperiments', StorageScope.APPLICATION); } const activationEvents = new Set(rawExperiments.map(exp => exp.condition?.activationEvent?.event) @@ -348,7 +348,7 @@ export class ExperimentService extends Disposable implements IExperimentService } const storageKey = 'experiments.' + experiment.id; - const experimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.GLOBAL), {}); + const experimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.APPLICATION), {}); if (!experimentState.hasOwnProperty('enabled')) { experimentState.enabled = processedExperiment.enabled; } @@ -360,7 +360,7 @@ export class ExperimentService extends Disposable implements IExperimentService return this.shouldRunExperiment(experiment, processedExperiment).then((state: ExperimentState) => { experimentState.state = processedExperiment.state = state; - this.storageService.store(storageKey, JSON.stringify(experimentState), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(storageKey, JSON.stringify(experimentState), StorageScope.APPLICATION, StorageTarget.MACHINE); if (state === ExperimentState.Run) { this.fireRunExperiment(processedExperiment); @@ -372,7 +372,7 @@ export class ExperimentService extends Disposable implements IExperimentService private fireRunExperiment(experiment: IExperiment) { this._onExperimentEnabled.fire(experiment); - const runExperimentIdsFromStorage: string[] = safeParse(this.storageService.get('currentOrPreviouslyRunExperiments', StorageScope.GLOBAL), []); + const runExperimentIdsFromStorage: string[] = safeParse(this.storageService.get('currentOrPreviouslyRunExperiments', StorageScope.APPLICATION), []); if (runExperimentIdsFromStorage.indexOf(experiment.id) === -1) { runExperimentIdsFromStorage.push(experiment.id); } @@ -380,14 +380,14 @@ export class ExperimentService extends Disposable implements IExperimentService // Ensure we dont store duplicates const distinctExperiments = distinct(runExperimentIdsFromStorage); if (runExperimentIdsFromStorage.length !== distinctExperiments.length) { - this.storageService.store('currentOrPreviouslyRunExperiments', JSON.stringify(distinctExperiments), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store('currentOrPreviouslyRunExperiments', JSON.stringify(distinctExperiments), StorageScope.APPLICATION, StorageTarget.MACHINE); } } private checkExperimentDependencies(experiment: IRawExperiment): boolean { const experimentsPreviouslyRun = experiment.condition?.experimentsPreviouslyRun; if (experimentsPreviouslyRun) { - const runExperimentIdsFromStorage: string[] = safeParse(this.storageService.get('currentOrPreviouslyRunExperiments', StorageScope.GLOBAL), []); + const runExperimentIdsFromStorage: string[] = safeParse(this.storageService.get('currentOrPreviouslyRunExperiments', StorageScope.APPLICATION), []); let includeCheck = true; let excludeCheck = true; const includes = experimentsPreviouslyRun.includes; @@ -407,9 +407,9 @@ export class ExperimentService extends Disposable implements IExperimentService private recordActivatedEvent(event: string) { const key = experimentEventStorageKey(event); - const record = getCurrentActivationRecord(safeParse(this.storageService.get(key, StorageScope.GLOBAL), undefined)); + const record = getCurrentActivationRecord(safeParse(this.storageService.get(key, StorageScope.APPLICATION), undefined)); record.count[0]++; - this.storageService.store(key, JSON.stringify(record), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(key, JSON.stringify(record), StorageScope.APPLICATION, StorageTarget.MACHINE); this._experiments .filter(e => { @@ -434,7 +434,7 @@ export class ExperimentService extends Disposable implements IExperimentService const events = typeof setting.event === 'string' ? [setting.event] : setting.event; for (const event of events) { - const { count } = getCurrentActivationRecord(safeParse(this.storageService.get(experimentEventStorageKey(event), StorageScope.GLOBAL), undefined)); + const { count } = getCurrentActivationRecord(safeParse(this.storageService.get(experimentEventStorageKey(event), StorageScope.APPLICATION), undefined)); for (const entry of count) { if (entry > 0) { @@ -483,7 +483,7 @@ export class ExperimentService extends Disposable implements IExperimentService return Promise.resolve(ExperimentState.NoRun); } - const isNewUser = !this.storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL); + const isNewUser = !this.storageService.get(lastSessionDateStorageKey, StorageScope.APPLICATION); if ((condition.newUser === true && !isNewUser) || (condition.newUser === false && isNewUser)) { return Promise.resolve(ExperimentState.NoRun); @@ -532,7 +532,7 @@ export class ExperimentService extends Disposable implements IExperimentService } const storageKey = 'experiments.' + experiment.id; - const experimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.GLOBAL), {}); + const experimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.APPLICATION), {}); return extensionsCheckPromise.then(success => { const fileEdits = condition.fileEdits; @@ -549,7 +549,7 @@ export class ExperimentService extends Disposable implements IExperimentService // Process model-save event every 250ms to reduce load const onModelsSavedWorker = this._register(new RunOnceWorker(models => { const date = new Date().toDateString(); - const latestExperimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.GLOBAL), {}); + const latestExperimentState: IExperimentStorageState = safeParse(this.storageService.get(storageKey, StorageScope.APPLICATION), {}); if (latestExperimentState.state !== ExperimentState.Evaluating) { onSaveHandler.dispose(); onModelsSavedWorker.dispose(); @@ -579,12 +579,12 @@ export class ExperimentService extends Disposable implements IExperimentService if (filePathCheck && workspaceCheck) { latestExperimentState.editCount = (latestExperimentState.editCount || 0) + 1; latestExperimentState.lastEditedDate = date; - this.storageService.store(storageKey, JSON.stringify(latestExperimentState), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(storageKey, JSON.stringify(latestExperimentState), StorageScope.APPLICATION, StorageTarget.MACHINE); } }); if (typeof latestExperimentState.editCount === 'number' && latestExperimentState.editCount >= fileEdits.minEditCount) { processedExperiment.state = latestExperimentState.state = (typeof condition.userProbability === 'number' && Math.random() < condition.userProbability && this.checkExperimentDependencies(experiment)) ? ExperimentState.Run : ExperimentState.NoRun; - this.storageService.store(storageKey, JSON.stringify(latestExperimentState), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(storageKey, JSON.stringify(latestExperimentState), StorageScope.APPLICATION, StorageTarget.MACHINE); if (latestExperimentState.state === ExperimentState.Run && processedExperiment.action && ExperimentActionType[processedExperiment.action.type] === ExperimentActionType.Prompt) { this.fireRunExperiment(processedExperiment); } diff --git a/src/vs/workbench/contrib/experiments/test/electron-browser/experimentService.test.ts b/src/vs/workbench/contrib/experiments/test/electron-browser/experimentService.test.ts index a97d0ace12a..2dbfdafd694 100644 --- a/src/vs/workbench/contrib/experiments/test/electron-browser/experimentService.test.ts +++ b/src/vs/workbench/contrib/experiments/test/electron-browser/experimentService.test.ts @@ -535,7 +535,7 @@ suite('Experiment Service', () => { didGetCall = true; assert.strictEqual(key, 'experimentEventRecord-my-event'); assert.deepStrictEqual(JSON.parse(value).count, [1, 0, 10, 0, 0, 0, 0]); - assert.strictEqual(scope, StorageScope.GLOBAL); + assert.strictEqual(scope, StorageScope.APPLICATION); } }); diff --git a/src/vs/workbench/contrib/extensions/electron-sandbox/remoteExtensionsInit.ts b/src/vs/workbench/contrib/extensions/electron-sandbox/remoteExtensionsInit.ts index aa4a1d19536..7209af8ccaf 100644 --- a/src/vs/workbench/contrib/extensions/electron-sandbox/remoteExtensionsInit.ts +++ b/src/vs/workbench/contrib/extensions/electron-sandbox/remoteExtensionsInit.ts @@ -57,11 +57,11 @@ export class RemoteExtensionsInitializerContribution implements IWorkbenchContri } const newRemoteConnectionKey = `${IS_NEW_KEY}.${connection.remoteAuthority}`; // Skip: Not a new remote connection - if (!this.storageService.getBoolean(newRemoteConnectionKey, StorageScope.GLOBAL, true)) { + if (!this.storageService.getBoolean(newRemoteConnectionKey, StorageScope.APPLICATION, true)) { this.logService.trace(`Skipping initializing remote extensions because the window with this remote authority was opened before.`); return; } - this.storageService.store(newRemoteConnectionKey, false, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(newRemoteConnectionKey, false, StorageScope.APPLICATION, StorageTarget.MACHINE); // Skip: Not a new workspace if (!this.storageService.isNew(StorageScope.WORKSPACE)) { this.logService.trace(`Skipping initializing remote extensions because this workspace was opened before.`); diff --git a/src/vs/workbench/contrib/localization/electron-sandbox/localization.contribution.ts b/src/vs/workbench/contrib/localization/electron-sandbox/localization.contribution.ts index 2d79b34e440..d5d97b9de49 100644 --- a/src/vs/workbench/contrib/localization/electron-sandbox/localization.contribution.ts +++ b/src/vs/workbench/contrib/localization/electron-sandbox/localization.contribution.ts @@ -88,7 +88,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo private checkAndInstall(): void { const language = platform.language; const locale = platform.locale; - const languagePackSuggestionIgnoreList = JSON.parse(this.storageService.get(LANGUAGEPACK_SUGGESTION_IGNORE_STORAGE_KEY, StorageScope.GLOBAL, '[]')); + const languagePackSuggestionIgnoreList = JSON.parse(this.storageService.get(LANGUAGEPACK_SUGGESTION_IGNORE_STORAGE_KEY, StorageScope.APPLICATION, '[]')); if (!this.galleryService.isEnabled()) { return; @@ -182,7 +182,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo this.storageService.store( LANGUAGEPACK_SUGGESTION_IGNORE_STORAGE_KEY, JSON.stringify(languagePackSuggestionIgnoreList), - StorageScope.GLOBAL, + StorageScope.APPLICATION, StorageTarget.USER ); logUserReaction('neverShowAgain'); diff --git a/src/vs/workbench/contrib/surveys/browser/ces.contribution.ts b/src/vs/workbench/contrib/surveys/browser/ces.contribution.ts index a2c5a2beaf7..3320a020843 100644 --- a/src/vs/workbench/contrib/surveys/browser/ces.contribution.ts +++ b/src/vs/workbench/contrib/surveys/browser/ces.contribution.ts @@ -48,7 +48,7 @@ class CESContribution extends Disposable implements IWorkbenchContribution { return; } - const skipSurvey = storageService.get(SKIP_SURVEY_KEY, StorageScope.GLOBAL, ''); + const skipSurvey = storageService.get(SKIP_SURVEY_KEY, StorageScope.APPLICATION, ''); if (skipSurvey) { return; } @@ -89,7 +89,7 @@ class CESContribution extends Disposable implements IWorkbenchContribution { const usedParams = this.productService.surveys ?.filter(surveyData => surveyData.surveyId && surveyData.languageId) // Counts provided by contrib/surveys/browser/languageSurveys - .filter(surveyData => this.storageService.getNumber(`${surveyData.surveyId}.editedCount`, StorageScope.GLOBAL, 0) > 0) + .filter(surveyData => this.storageService.getNumber(`${surveyData.surveyId}.editedCount`, StorageScope.APPLICATION, 0) > 0) .map(surveyData => `${encodeURIComponent(surveyData.languageId)}Lang=1`) .join('&'); if (usedParams) { @@ -103,7 +103,7 @@ class CESContribution extends Disposable implements IWorkbenchContribution { label: nls.localize('remindLater', "Remind Me later"), run: () => { sendTelemetry('remindLater'); - this.storageService.store(REMIND_LATER_DATE_KEY, new Date().toUTCString(), StorageScope.GLOBAL, StorageTarget.USER); + this.storageService.store(REMIND_LATER_DATE_KEY, new Date().toUTCString(), StorageScope.APPLICATION, StorageTarget.USER); this.schedulePrompt(); } }], @@ -121,7 +121,7 @@ class CESContribution extends Disposable implements IWorkbenchContribution { private async schedulePrompt(): Promise { let waitTimeToShowSurvey = 0; - const remindLaterDate = this.storageService.get(REMIND_LATER_DATE_KEY, StorageScope.GLOBAL, ''); + const remindLaterDate = this.storageService.get(REMIND_LATER_DATE_KEY, StorageScope.APPLICATION, ''); if (remindLaterDate) { const timeToRemind = new Date(remindLaterDate).getTime() + REMIND_LATER_DELAY - Date.now(); if (timeToRemind > 0) { @@ -154,7 +154,7 @@ class CESContribution extends Disposable implements IWorkbenchContribution { } private skipSurvey(): void { - this.storageService.store(SKIP_SURVEY_KEY, this.productService.version, StorageScope.GLOBAL, StorageTarget.USER); + this.storageService.store(SKIP_SURVEY_KEY, this.productService.version, StorageScope.APPLICATION, StorageTarget.USER); } } diff --git a/src/vs/workbench/contrib/surveys/browser/languageSurveys.contribution.ts b/src/vs/workbench/contrib/surveys/browser/languageSurveys.contribution.ts index 75d75f97b34..ae6e3b498bc 100644 --- a/src/vs/workbench/contrib/surveys/browser/languageSurveys.contribution.ts +++ b/src/vs/workbench/contrib/surveys/browser/languageSurveys.contribution.ts @@ -43,22 +43,22 @@ class LanguageSurvey extends Disposable { const EDITED_LANGUAGE_COUNT_KEY = `${data.surveyId}.editedCount`; const EDITED_LANGUAGE_DATE_KEY = `${data.surveyId}.editedDate`; - const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.GLOBAL, ''); + const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.APPLICATION, ''); if (skipVersion) { return; } const date = new Date().toDateString(); - if (storageService.getNumber(EDITED_LANGUAGE_COUNT_KEY, StorageScope.GLOBAL, 0) < data.editCount) { + if (storageService.getNumber(EDITED_LANGUAGE_COUNT_KEY, StorageScope.APPLICATION, 0) < data.editCount) { // Process model-save event every 250ms to reduce load const onModelsSavedWorker = this._register(new RunOnceWorker(models => { models.forEach(m => { - if (m.getLanguageId() === data.languageId && date !== storageService.get(EDITED_LANGUAGE_DATE_KEY, StorageScope.GLOBAL)) { - const editedCount = storageService.getNumber(EDITED_LANGUAGE_COUNT_KEY, StorageScope.GLOBAL, 0) + 1; - storageService.store(EDITED_LANGUAGE_COUNT_KEY, editedCount, StorageScope.GLOBAL, StorageTarget.USER); - storageService.store(EDITED_LANGUAGE_DATE_KEY, date, StorageScope.GLOBAL, StorageTarget.USER); + if (m.getLanguageId() === data.languageId && date !== storageService.get(EDITED_LANGUAGE_DATE_KEY, StorageScope.APPLICATION)) { + const editedCount = storageService.getNumber(EDITED_LANGUAGE_COUNT_KEY, StorageScope.APPLICATION, 0) + 1; + storageService.store(EDITED_LANGUAGE_COUNT_KEY, editedCount, StorageScope.APPLICATION, StorageTarget.USER); + storageService.store(EDITED_LANGUAGE_DATE_KEY, date, StorageScope.APPLICATION, StorageTarget.USER); } }); }, 250)); @@ -66,30 +66,30 @@ class LanguageSurvey extends Disposable { this._register(textFileService.files.onDidSave(e => onModelsSavedWorker.work(e.model))); } - const lastSessionDate = storageService.get(LAST_SESSION_DATE_KEY, StorageScope.GLOBAL, new Date(0).toDateString()); + const lastSessionDate = storageService.get(LAST_SESSION_DATE_KEY, StorageScope.APPLICATION, new Date(0).toDateString()); if (date === lastSessionDate) { return; } - const sessionCount = storageService.getNumber(SESSION_COUNT_KEY, StorageScope.GLOBAL, 0) + 1; - storageService.store(LAST_SESSION_DATE_KEY, date, StorageScope.GLOBAL, StorageTarget.USER); - storageService.store(SESSION_COUNT_KEY, sessionCount, StorageScope.GLOBAL, StorageTarget.USER); + const sessionCount = storageService.getNumber(SESSION_COUNT_KEY, StorageScope.APPLICATION, 0) + 1; + storageService.store(LAST_SESSION_DATE_KEY, date, StorageScope.APPLICATION, StorageTarget.USER); + storageService.store(SESSION_COUNT_KEY, sessionCount, StorageScope.APPLICATION, StorageTarget.USER); if (sessionCount < 9) { return; } - if (storageService.getNumber(EDITED_LANGUAGE_COUNT_KEY, StorageScope.GLOBAL, 0) < data.editCount) { + if (storageService.getNumber(EDITED_LANGUAGE_COUNT_KEY, StorageScope.APPLICATION, 0) < data.editCount) { return; } - const isCandidate = storageService.getBoolean(IS_CANDIDATE_KEY, StorageScope.GLOBAL, false) + const isCandidate = storageService.getBoolean(IS_CANDIDATE_KEY, StorageScope.APPLICATION, false) || Math.random() < data.userProbability; - storageService.store(IS_CANDIDATE_KEY, isCandidate, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store(IS_CANDIDATE_KEY, isCandidate, StorageScope.APPLICATION, StorageTarget.USER); if (!isCandidate) { - storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.APPLICATION, StorageTarget.USER); return; } @@ -102,23 +102,23 @@ class LanguageSurvey extends Disposable { telemetryService.publicLog(`${data.surveyId}.survey/takeShortSurvey`); telemetryService.getTelemetryInfo().then(info => { openerService.open(URI.parse(`${data.surveyUrl}?o=${encodeURIComponent(platform)}&v=${encodeURIComponent(productService.version)}&m=${encodeURIComponent(info.machineId)}`)); - storageService.store(IS_CANDIDATE_KEY, false, StorageScope.GLOBAL, StorageTarget.USER); - storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store(IS_CANDIDATE_KEY, false, StorageScope.APPLICATION, StorageTarget.USER); + storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.APPLICATION, StorageTarget.USER); }); } }, { label: localize('remindLater', "Remind Me later"), run: () => { telemetryService.publicLog(`${data.surveyId}.survey/remindMeLater`); - storageService.store(SESSION_COUNT_KEY, sessionCount - 3, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store(SESSION_COUNT_KEY, sessionCount - 3, StorageScope.APPLICATION, StorageTarget.USER); } }, { label: localize('neverAgain', "Don't Show Again"), isSecondary: true, run: () => { telemetryService.publicLog(`${data.surveyId}.survey/dontShowAgain`); - storageService.store(IS_CANDIDATE_KEY, false, StorageScope.GLOBAL, StorageTarget.USER); - storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store(IS_CANDIDATE_KEY, false, StorageScope.APPLICATION, StorageTarget.USER); + storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.APPLICATION, StorageTarget.USER); } }], { sticky: true } diff --git a/src/vs/workbench/contrib/surveys/browser/nps.contribution.ts b/src/vs/workbench/contrib/surveys/browser/nps.contribution.ts index 243eb7500b6..bb1e79f25e4 100644 --- a/src/vs/workbench/contrib/surveys/browser/nps.contribution.ts +++ b/src/vs/workbench/contrib/surveys/browser/nps.contribution.ts @@ -35,33 +35,33 @@ class NPSContribution implements IWorkbenchContribution { return; } - const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.GLOBAL, ''); + const skipVersion = storageService.get(SKIP_VERSION_KEY, StorageScope.APPLICATION, ''); if (skipVersion) { return; } const date = new Date().toDateString(); - const lastSessionDate = storageService.get(LAST_SESSION_DATE_KEY, StorageScope.GLOBAL, new Date(0).toDateString()); + const lastSessionDate = storageService.get(LAST_SESSION_DATE_KEY, StorageScope.APPLICATION, new Date(0).toDateString()); if (date === lastSessionDate) { return; } - const sessionCount = (storageService.getNumber(SESSION_COUNT_KEY, StorageScope.GLOBAL, 0) || 0) + 1; - storageService.store(LAST_SESSION_DATE_KEY, date, StorageScope.GLOBAL, StorageTarget.USER); - storageService.store(SESSION_COUNT_KEY, sessionCount, StorageScope.GLOBAL, StorageTarget.USER); + const sessionCount = (storageService.getNumber(SESSION_COUNT_KEY, StorageScope.APPLICATION, 0) || 0) + 1; + storageService.store(LAST_SESSION_DATE_KEY, date, StorageScope.APPLICATION, StorageTarget.USER); + storageService.store(SESSION_COUNT_KEY, sessionCount, StorageScope.APPLICATION, StorageTarget.USER); if (sessionCount < 9) { return; } - const isCandidate = storageService.getBoolean(IS_CANDIDATE_KEY, StorageScope.GLOBAL, false) + const isCandidate = storageService.getBoolean(IS_CANDIDATE_KEY, StorageScope.APPLICATION, false) || Math.random() < PROBABILITY; - storageService.store(IS_CANDIDATE_KEY, isCandidate, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store(IS_CANDIDATE_KEY, isCandidate, StorageScope.APPLICATION, StorageTarget.USER); if (!isCandidate) { - storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.APPLICATION, StorageTarget.USER); return; } @@ -73,18 +73,18 @@ class NPSContribution implements IWorkbenchContribution { run: () => { telemetryService.getTelemetryInfo().then(info => { openerService.open(URI.parse(`${productService.npsSurveyUrl}?o=${encodeURIComponent(platform)}&v=${encodeURIComponent(productService.version)}&m=${encodeURIComponent(info.machineId)}`)); - storageService.store(IS_CANDIDATE_KEY, false, StorageScope.GLOBAL, StorageTarget.USER); - storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store(IS_CANDIDATE_KEY, false, StorageScope.APPLICATION, StorageTarget.USER); + storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.APPLICATION, StorageTarget.USER); }); } }, { label: nls.localize('remindLater', "Remind Me later"), - run: () => storageService.store(SESSION_COUNT_KEY, sessionCount - 3, StorageScope.GLOBAL, StorageTarget.USER) + run: () => storageService.store(SESSION_COUNT_KEY, sessionCount - 3, StorageScope.APPLICATION, StorageTarget.USER) }, { label: nls.localize('neverAgain', "Don't Show Again"), run: () => { - storageService.store(IS_CANDIDATE_KEY, false, StorageScope.GLOBAL, StorageTarget.USER); - storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store(IS_CANDIDATE_KEY, false, StorageScope.APPLICATION, StorageTarget.USER); + storageService.store(SKIP_VERSION_KEY, productService.version, StorageScope.APPLICATION, StorageTarget.USER); } }], { sticky: true } diff --git a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts index 736ead6c5bb..05d341c2206 100644 --- a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts +++ b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts @@ -190,7 +190,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo if (requiresInitialization && !this.userDataSyncEnablementService.isEnabled()) { this.updateSyncAfterInitializationContext(true); } else { - this.updateSyncAfterInitializationContext(this.storageService.getBoolean(CONTEXT_SYNC_AFTER_INITIALIZATION.key, StorageScope.GLOBAL, false)); + this.updateSyncAfterInitializationContext(this.storageService.getBoolean(CONTEXT_SYNC_AFTER_INITIALIZATION.key, StorageScope.APPLICATION, false)); } const disposable = this._register(this.userDataSyncEnablementService.onDidChangeEnablement(() => { if (this.userDataSyncEnablementService.isEnabled()) { @@ -201,7 +201,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo } private async updateSyncAfterInitializationContext(value: boolean): Promise { - this.storageService.store(CONTEXT_SYNC_AFTER_INITIALIZATION.key, value, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(CONTEXT_SYNC_AFTER_INITIALIZATION.key, value, StorageScope.APPLICATION, StorageTarget.MACHINE); this.syncAfterInitializationContext.set(value); this.updateGlobalActivityBadge(); } diff --git a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts index 38e30b6fb26..8e4e3cac915 100644 --- a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts +++ b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts @@ -815,7 +815,7 @@ export class GettingStartedPage extends EditorPane { this.buildTelemetryFooter(telemetryNotice); footer.appendChild(telemetryNotice); } else if (!this.productService.openToWelcomeMainPage && !someStepsComplete && !this.hasScrolledToFirstCategory) { - const firstSessionDateString = this.storageService.get(firstSessionDateStorageKey, StorageScope.GLOBAL) || new Date().toUTCString(); + const firstSessionDateString = this.storageService.get(firstSessionDateStorageKey, StorageScope.APPLICATION) || new Date().toUTCString(); const daysSinceFirstSession = ((+new Date()) - (+new Date(firstSessionDateString))) / 1000 / 60 / 60 / 24; const fistContentBehaviour = daysSinceFirstSession < 1 ? 'openToFirstCategory' : 'index'; diff --git a/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts b/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts index e19fdd2509b..7209305803b 100644 --- a/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts +++ b/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.ts @@ -218,7 +218,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten } const result: IScannedExtension[] = []; try { - const useCache = this.storageService.get('additionalBuiltinExtensions', StorageScope.GLOBAL, '[]') === JSON.stringify(extensions); + const useCache = this.storageService.get('additionalBuiltinExtensions', StorageScope.APPLICATION, '[]') === JSON.stringify(extensions); const webExtensions = await (useCache ? this.getCustomBuiltinExtensionsFromCache() : this.updateCustomBuiltinExtensionsCache()); if (webExtensions.length) { await Promise.all(webExtensions.map(async webExtension => { @@ -232,7 +232,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten } })); } - this.storageService.store('additionalBuiltinExtensions', JSON.stringify(extensions), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store('additionalBuiltinExtensions', JSON.stringify(extensions), StorageScope.APPLICATION, StorageTarget.MACHINE); } catch (error) { this.logService.info('Ignoring following additional builtin extensions as there is an error while fetching them from gallery', extensions.map(({ id }) => id), getErrorMessage(error)); } diff --git a/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts b/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts index a65bbfcf09e..0e630dc4ce8 100644 --- a/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts +++ b/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts @@ -186,7 +186,7 @@ export class BrowserKeyboardMapperFactoryBase { // we shoud avoid yielding the false error. // if (keymap && score < 0) { // const donotAskUpdateKey = 'missing.keyboardlayout.donotask'; - // if (this._storageService.getBoolean(donotAskUpdateKey, StorageScope.GLOBAL)) { + // if (this._storageService.getBoolean(donotAskUpdateKey, StorageScope.APPLICATION)) { // return; // } @@ -200,7 +200,7 @@ export class BrowserKeyboardMapperFactoryBase { // }, { // label: nls.localize('neverAgain', "Don't Show Again"), // isSecondary: true, - // run: () => this._storageService.store(donotAskUpdateKey, true, StorageScope.GLOBAL) + // run: () => this._storageService.store(donotAskUpdateKey, true, StorageScope.APPLICATION) // }] // ); diff --git a/src/vs/workbench/services/notification/common/notificationService.ts b/src/vs/workbench/services/notification/common/notificationService.ts index 9e58c1354fb..66ffe727f6f 100644 --- a/src/vs/workbench/services/notification/common/notificationService.ts +++ b/src/vs/workbench/services/notification/common/notificationService.ts @@ -145,13 +145,13 @@ export class NotificationService extends Disposable implements INotificationServ private toStorageScope(options: INeverShowAgainOptions): StorageScope { switch (options.scope) { case NeverShowAgainScope.GLOBAL: - return StorageScope.GLOBAL; + return StorageScope.APPLICATION; case NeverShowAgainScope.PROFILE: return StorageScope.PROFILE; case NeverShowAgainScope.WORKSPACE: return StorageScope.WORKSPACE; default: - return StorageScope.GLOBAL; + return StorageScope.APPLICATION; } } diff --git a/src/vs/workbench/services/storage/browser/storageService.ts b/src/vs/workbench/services/storage/browser/storageService.ts index 07de9723e2a..57940c27cc6 100644 --- a/src/vs/workbench/services/storage/browser/storageService.ts +++ b/src/vs/workbench/services/storage/browser/storageService.ts @@ -21,9 +21,9 @@ export class BrowserStorageService extends AbstractStorageService { private static BROWSER_DEFAULT_FLUSH_INTERVAL = 5 * 1000; // every 5s because async operations are not permitted on shutdown - private globalStorage: IStorage | undefined; - private globalStorageDatabase: IIndexedDBStorageDatabase | undefined; - private readonly globalStoragePromise = new DeferredPromise<{ indededDb: IIndexedDBStorageDatabase; storage: IStorage }>(); + private applicationStorage: IStorage | undefined; + private applicationStorageDatabase: IIndexedDBStorageDatabase | undefined; + private readonly applicationStoragePromise = new DeferredPromise<{ indededDb: IIndexedDBStorageDatabase; storage: IStorage }>(); private profileStorage: IStorage | undefined; private profileStorageDatabase: IIndexedDBStorageDatabase | undefined; @@ -35,7 +35,7 @@ export class BrowserStorageService extends AbstractStorageService { get hasPendingUpdate(): boolean { return Boolean( - this.globalStorageDatabase?.hasPendingUpdate || + this.applicationStorageDatabase?.hasPendingUpdate || this.profileStorageDatabase?.hasPendingUpdate || this.workspaceStorageDatabase?.hasPendingUpdate ); @@ -57,8 +57,8 @@ export class BrowserStorageService extends AbstractStorageService { private getId(scope: StorageScope): string { switch (scope) { - case StorageScope.GLOBAL: - return 'global'; // use the default profile global DB for global scope + case StorageScope.APPLICATION: + return 'global'; // use the default profile application DB for application scope case StorageScope.PROFILE: if (this.profileStorageProfile.isDefault) { return 'global'; // default profile DB has a fixed name for backwards compatibility @@ -74,25 +74,25 @@ export class BrowserStorageService extends AbstractStorageService { // Init storages await Promises.settled([ - this.createGlobalStorage(), + this.createApplicationStorage(), this.createProfileStorage(this.profileStorageProfile), this.createWorkspaceStorage() ]); } - private async createGlobalStorage(): Promise { - const globalStorageIndexedDB = await IndexedDBStorageDatabase.create({ id: this.getId(StorageScope.GLOBAL), broadcastChanges: true }, this.logService); + private async createApplicationStorage(): Promise { + const applicationStorageIndexedDB = await IndexedDBStorageDatabase.create({ id: this.getId(StorageScope.APPLICATION), broadcastChanges: true }, this.logService); - this.globalStorageDatabase = this._register(globalStorageIndexedDB); - this.globalStorage = this._register(new Storage(this.globalStorageDatabase)); + this.applicationStorageDatabase = this._register(applicationStorageIndexedDB); + this.applicationStorage = this._register(new Storage(this.applicationStorageDatabase)); - this._register(this.globalStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.GLOBAL, key))); + this._register(this.applicationStorage.onDidChangeStorage(key => this.emitDidChangeValue(StorageScope.APPLICATION, key))); - await this.globalStorage.init(); + await this.applicationStorage.init(); - this.updateIsNew(this.globalStorage); + this.updateIsNew(this.applicationStorage); - this.globalStoragePromise.complete({ indededDb: globalStorageIndexedDB, storage: this.globalStorage }); + this.applicationStoragePromise.complete({ indededDb: applicationStorageIndexedDB, storage: this.applicationStorage }); } private async createProfileStorage(profile: IUserDataProfile): Promise { @@ -106,14 +106,14 @@ export class BrowserStorageService extends AbstractStorageService { if (this.profileStorageProfile.isDefault) { // If we are in default profile, the profile storage is - // actually the same as global storage. As such we + // actually the same as application storage. As such we // avoid creating the storage library a second time on // the same DB. - const { indededDb: globalStorageIndexedDB, storage: globalStorage } = await this.globalStoragePromise.p; + const { indededDb: applicationStorageIndexedDB, storage: applicationStorage } = await this.applicationStoragePromise.p; - this.profileStorageDatabase = globalStorageIndexedDB; - this.profileStorage = globalStorage; + this.profileStorageDatabase = applicationStorageIndexedDB; + this.profileStorage = applicationStorage; } else { const profileStorageIndexedDB = await IndexedDBStorageDatabase.create({ id: this.getId(StorageScope.PROFILE), broadcastChanges: true }, this.logService); @@ -152,8 +152,8 @@ export class BrowserStorageService extends AbstractStorageService { protected getStorage(scope: StorageScope): IStorage | undefined { switch (scope) { - case StorageScope.GLOBAL: - return this.globalStorage; + case StorageScope.APPLICATION: + return this.applicationStorage; case StorageScope.PROFILE: return this.profileStorage; default: @@ -170,8 +170,8 @@ export class BrowserStorageService extends AbstractStorageService { const oldItems = oldProfileStorage.items; // Close old profile storage but only if this is - // different from global storage! - if (oldProfileStorage !== this.globalStorage) { + // different from application storage! + if (oldProfileStorage !== this.applicationStorage) { await oldProfileStorage.close(); } @@ -209,7 +209,7 @@ export class BrowserStorageService extends AbstractStorageService { // On all other browsers, we keep the databases opened because // we expect data to be written when the unload happens. if (isSafari) { - this.globalStorage?.close(); + this.applicationStorage?.close(); this.profileStorageDatabase?.close(); this.workspaceStorageDatabase?.close(); } @@ -222,7 +222,7 @@ export class BrowserStorageService extends AbstractStorageService { async clear(): Promise { // Clear key/values - for (const scope of [StorageScope.GLOBAL, StorageScope.PROFILE, StorageScope.WORKSPACE]) { + for (const scope of [StorageScope.APPLICATION, StorageScope.PROFILE, StorageScope.WORKSPACE]) { for (const target of [StorageTarget.USER, StorageTarget.MACHINE]) { for (const key of this.keys(scope, target)) { this.remove(key, scope); @@ -234,7 +234,7 @@ export class BrowserStorageService extends AbstractStorageService { // Clear databases await Promises.settled([ - this.globalStorageDatabase?.clear() ?? Promise.resolve(), + this.applicationStorageDatabase?.clear() ?? Promise.resolve(), this.profileStorageDatabase?.clear() ?? Promise.resolve(), this.workspaceStorageDatabase?.clear() ?? Promise.resolve() ]); diff --git a/src/vs/workbench/services/storage/test/browser/storageService.test.ts b/src/vs/workbench/services/storage/test/browser/storageService.test.ts index 700c4ecdfb4..dfd3644e172 100644 --- a/src/vs/workbench/services/storage/test/browser/storageService.test.ts +++ b/src/vs/workbench/services/storage/test/browser/storageService.test.ts @@ -89,8 +89,8 @@ flakySuite('StorageService (browser specific)', () => { test('clear', () => { return runWithFakedTimers({ useFakeTimers: true }, async () => { - storageService.store('bar', 'foo', StorageScope.GLOBAL, StorageTarget.MACHINE); - storageService.store('bar', 3, StorageScope.GLOBAL, StorageTarget.USER); + storageService.store('bar', 'foo', StorageScope.APPLICATION, StorageTarget.MACHINE); + storageService.store('bar', 3, StorageScope.APPLICATION, StorageTarget.USER); storageService.store('bar', 'foo', StorageScope.PROFILE, StorageTarget.MACHINE); storageService.store('bar', 3, StorageScope.PROFILE, StorageTarget.USER); storageService.store('bar', 'foo', StorageScope.WORKSPACE, StorageTarget.MACHINE); @@ -98,7 +98,7 @@ flakySuite('StorageService (browser specific)', () => { await storageService.clear(); - for (const scope of [StorageScope.GLOBAL, StorageScope.PROFILE, StorageScope.WORKSPACE]) { + for (const scope of [StorageScope.APPLICATION, StorageScope.PROFILE, StorageScope.WORKSPACE]) { for (const target of [StorageTarget.USER, StorageTarget.MACHINE]) { strictEqual(storageService.get('bar', scope), undefined); strictEqual(storageService.keys(scope, target).length, 0); diff --git a/src/vs/workbench/services/telemetry/browser/workbenchCommonProperties.ts b/src/vs/workbench/services/telemetry/browser/workbenchCommonProperties.ts index 69116d9a458..16bce794a23 100644 --- a/src/vs/workbench/services/telemetry/browser/workbenchCommonProperties.ts +++ b/src/vs/workbench/services/telemetry/browser/workbenchCommonProperties.ts @@ -30,15 +30,15 @@ export async function resolveWorkbenchCommonProperties( resolveAdditionalProperties?: () => { [key: string]: any } ): Promise<{ [name: string]: string | undefined }> { const result: { [name: string]: string | undefined } = Object.create(null); - const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.GLOBAL)!; - const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL)!; + const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.APPLICATION)!; + const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.APPLICATION)!; let machineId: string | undefined; if (!removeMachineId) { - machineId = storageService.get(machineIdKey, StorageScope.GLOBAL); + machineId = storageService.get(machineIdKey, StorageScope.APPLICATION); if (!machineId) { machineId = uuid.generateUuid(); - storageService.store(machineIdKey, machineId, StorageScope.GLOBAL, StorageTarget.MACHINE); + storageService.store(machineIdKey, machineId, StorageScope.APPLICATION, StorageTarget.MACHINE); } } else { machineId = `Redacted-${productIdentifier ?? 'web'}`; diff --git a/src/vs/workbench/services/telemetry/electron-sandbox/workbenchCommonProperties.ts b/src/vs/workbench/services/telemetry/electron-sandbox/workbenchCommonProperties.ts index ff36a5231e6..9d5b4282308 100644 --- a/src/vs/workbench/services/telemetry/electron-sandbox/workbenchCommonProperties.ts +++ b/src/vs/workbench/services/telemetry/electron-sandbox/workbenchCommonProperties.ts @@ -23,8 +23,8 @@ export async function resolveWorkbenchCommonProperties( remoteAuthority?: string ): Promise<{ [name: string]: string | boolean | undefined }> { const result = await resolveCommonProperties(fileService, release, hostname, process.arch, commit, version, machineId, msftInternalDomains, installSourcePath); - const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.GLOBAL)!; - const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL)!; + const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.APPLICATION)!; + const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.APPLICATION)!; // __GDPR__COMMON__ "common.version.shell" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" } result['common.version.shell'] = process.versions['electron']; diff --git a/src/vs/workbench/services/telemetry/test/electron-browser/commonProperties.test.ts b/src/vs/workbench/services/telemetry/test/electron-browser/commonProperties.test.ts index ac596534940..8ae51addd3e 100644 --- a/src/vs/workbench/services/telemetry/test/electron-browser/commonProperties.test.ts +++ b/src/vs/workbench/services/telemetry/test/electron-browser/commonProperties.test.ts @@ -72,7 +72,7 @@ suite('Telemetry - common properties', function () { test('lastSessionDate when available', async function () { - testStorageService.store('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.GLOBAL, StorageTarget.MACHINE); + testStorageService.store('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.APPLICATION, StorageTarget.MACHINE); const props = await resolveWorkbenchCommonProperties(testStorageService, testFileService, release(), hostname(), commit, version, 'someMachineId', undefined, installSource); assert.ok('common.lastSessionDate' in props); // conditional, see below diff --git a/src/vs/workbench/services/userData/browser/userDataInit.ts b/src/vs/workbench/services/userData/browser/userDataInit.ts index 404c963b5ff..1d7504a2656 100644 --- a/src/vs/workbench/services/userData/browser/userDataInit.ts +++ b/src/vs/workbench/services/userData/browser/userDataInit.ts @@ -87,7 +87,7 @@ export class UserDataInitializationService implements IUserDataInitializationSer return; } - if (!this.storageService.isNew(StorageScope.GLOBAL)) { + if (!this.storageService.isNew(StorageScope.APPLICATION)) { this.logService.trace(`Skipping initializing user data as application was opened before`); return; } diff --git a/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts b/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts index f0b94a22f71..78c27df5d0c 100644 --- a/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts +++ b/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts @@ -631,7 +631,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat } private onDidChangeStorage(e: IStorageValueChangeEvent): void { - if (e.key === UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY && e.scope === StorageScope.GLOBAL + if (e.key === UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY && e.scope === StorageScope.APPLICATION && this.currentSessionId !== this.getStoredCachedSessionId() /* This checks if current window changed the value or not */) { this._cachedCurrentSessionId = null; this.update(); @@ -651,24 +651,24 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat this._cachedCurrentSessionId = cachedSessionId; if (cachedSessionId === undefined) { this.logService.info('Settings Sync: Reset current session'); - this.storageService.remove(UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY, StorageScope.GLOBAL); + this.storageService.remove(UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY, StorageScope.APPLICATION); } else { this.logService.info('Settings Sync: Updated current session', cachedSessionId); - this.storageService.store(UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY, cachedSessionId, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY, cachedSessionId, StorageScope.APPLICATION, StorageTarget.MACHINE); } } } private getStoredCachedSessionId(): string | undefined { - return this.storageService.get(UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY, StorageScope.GLOBAL); + return this.storageService.get(UserDataSyncWorkbenchService.CACHED_SESSION_STORAGE_KEY, StorageScope.APPLICATION); } private get useWorkbenchSessionId(): boolean { - return !this.storageService.getBoolean(UserDataSyncWorkbenchService.DONOT_USE_WORKBENCH_SESSION_STORAGE_KEY, StorageScope.GLOBAL, false); + return !this.storageService.getBoolean(UserDataSyncWorkbenchService.DONOT_USE_WORKBENCH_SESSION_STORAGE_KEY, StorageScope.APPLICATION, false); } private set useWorkbenchSessionId(useWorkbenchSession: boolean) { - this.storageService.store(UserDataSyncWorkbenchService.DONOT_USE_WORKBENCH_SESSION_STORAGE_KEY, !useWorkbenchSession, StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(UserDataSyncWorkbenchService.DONOT_USE_WORKBENCH_SESSION_STORAGE_KEY, !useWorkbenchSession, StorageScope.APPLICATION, StorageTarget.MACHINE); } } diff --git a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts index e5039e9bc04..e464de637ee 100644 --- a/src/vs/workbench/services/workspaces/common/workspaceTrust.ts +++ b/src/vs/workbench/services/workspaces/common/workspaceTrust.ts @@ -244,7 +244,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork } private loadTrustInfo(): IWorkspaceTrustInfo { - const infoAsString = this.storageService.get(this.storageKey, StorageScope.GLOBAL); + const infoAsString = this.storageService.get(this.storageKey, StorageScope.APPLICATION); let result: IWorkspaceTrustInfo | undefined; try { @@ -270,7 +270,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork } private async saveTrustInfo(): Promise { - this.storageService.store(this.storageKey, JSON.stringify(this._trustStateInfo), StorageScope.GLOBAL, StorageTarget.MACHINE); + this.storageService.store(this.storageKey, JSON.stringify(this._trustStateInfo), StorageScope.APPLICATION, StorageTarget.MACHINE); this._onDidChangeTrustedFolders.fire(); await this.updateWorkspaceTrust(); diff --git a/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts b/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts index cb8808efc50..ab6f9d78a7d 100644 --- a/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts +++ b/src/vs/workbench/services/workspaces/test/common/workspaceTrust.test.ts @@ -109,7 +109,7 @@ suite('Workspace Trust', () => { test('empty workspace - trusted, open trusted file', async () => { await configurationService.setUserConfiguration('security', getUserSettings(true, true)); const trustInfo: IWorkspaceTrustInfo = { uriTrustInfo: [{ uri: URI.parse('file:///Folder'), trusted: true }] }; - storageService.store(WORKSPACE_TRUST_STORAGE_KEY, JSON.stringify(trustInfo), StorageScope.GLOBAL, StorageTarget.MACHINE); + storageService.store(WORKSPACE_TRUST_STORAGE_KEY, JSON.stringify(trustInfo), StorageScope.APPLICATION, StorageTarget.MACHINE); (environmentService as any).filesToOpenOrCreate = [{ fileUri: URI.parse('file:///Folder/file.txt') }]; instantiationService.stub(IWorkbenchEnvironmentService, { ...environmentService }); diff --git a/src/vs/workbench/test/browser/workbenchTestServices.ts b/src/vs/workbench/test/browser/workbenchTestServices.ts index f047e71ecac..17e24745944 100644 --- a/src/vs/workbench/test/browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/browser/workbenchTestServices.ts @@ -1662,9 +1662,9 @@ export class TestEditorPart extends EditorPart { delete workspaceMemento[key]; } - const globalMemento = this.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE); - for (const key of Object.keys(globalMemento)) { - delete globalMemento[key]; + const profileMemento = this.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE); + for (const key of Object.keys(profileMemento)) { + delete profileMemento[key]; } } } diff --git a/src/vs/workbench/test/common/memento.test.ts b/src/vs/workbench/test/common/memento.test.ts index 18016034a54..e523402f4bd 100644 --- a/src/vs/workbench/test/common/memento.test.ts +++ b/src/vs/workbench/test/common/memento.test.ts @@ -13,7 +13,7 @@ suite('Memento', () => { setup(() => { storage = new TestStorageService(); - Memento.clear(StorageScope.GLOBAL); + Memento.clear(StorageScope.APPLICATION); Memento.clear(StorageScope.PROFILE); Memento.clear(StorageScope.WORKSPACE); }); @@ -21,11 +21,11 @@ suite('Memento', () => { test('Loading and Saving Memento with Scopes', () => { const myMemento = new Memento('memento.test', storage); - // Global - let memento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE); + // Application + let memento = myMemento.getMemento(StorageScope.APPLICATION, StorageTarget.MACHINE); memento.foo = [1, 2, 3]; - let globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE); - assert.deepStrictEqual(globalMemento, memento); + let applicationMemento = myMemento.getMemento(StorageScope.APPLICATION, StorageTarget.MACHINE); + assert.deepStrictEqual(applicationMemento, memento); // Profile memento = myMemento.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE); @@ -40,11 +40,11 @@ suite('Memento', () => { myMemento.saveMemento(); - // Global - memento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE); + // Application + memento = myMemento.getMemento(StorageScope.APPLICATION, StorageTarget.MACHINE); assert.deepStrictEqual(memento, { foo: [1, 2, 3] }); - globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE); - assert.deepStrictEqual(globalMemento, memento); + applicationMemento = myMemento.getMemento(StorageScope.APPLICATION, StorageTarget.MACHINE); + assert.deepStrictEqual(applicationMemento, memento); // Profile memento = myMemento.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE); @@ -57,12 +57,12 @@ suite('Memento', () => { assert.deepStrictEqual(memento, { foo: 'Hello World' }); // Assert the Mementos are stored properly in storage - assert.deepStrictEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.GLOBAL)!), { foo: [1, 2, 3] }); + assert.deepStrictEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.APPLICATION)!), { foo: [1, 2, 3] }); assert.deepStrictEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.PROFILE)!), { foo: [4, 5, 6] }); assert.deepStrictEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.WORKSPACE)!), { foo: 'Hello World' }); - // Delete Global - memento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE); + // Delete Application + memento = myMemento.getMemento(StorageScope.APPLICATION, StorageTarget.MACHINE); delete memento.foo; // Delete Profile @@ -75,8 +75,8 @@ suite('Memento', () => { myMemento.saveMemento(); - // Global - memento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE); + // Application + memento = myMemento.getMemento(StorageScope.APPLICATION, StorageTarget.MACHINE); assert.deepStrictEqual(memento, {}); // Profile @@ -88,7 +88,7 @@ suite('Memento', () => { assert.deepStrictEqual(memento, {}); // Assert the Mementos are also removed from storage - assert.strictEqual(storage.get('memento/memento.test', StorageScope.GLOBAL, null!), null); + assert.strictEqual(storage.get('memento/memento.test', StorageScope.APPLICATION, null!), null); assert.strictEqual(storage.get('memento/memento.test', StorageScope.PROFILE, null!), null); assert.strictEqual(storage.get('memento/memento.test', StorageScope.WORKSPACE, null!), null); });