diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts index 96a0bc604d49aebe9e03fda350e170fd6e094796..6714a598967191c262c876729d33e0a740716721 100644 --- a/src/vs/editor/browser/config/configuration.ts +++ b/src/vs/editor/browser/config/configuration.ts @@ -13,7 +13,7 @@ import { FontInfo, BareFontInfo } from 'vs/editor/common/config/fontInfo'; import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver'; import { FastDomNode } from 'vs/base/browser/fastDomNode'; import { CharWidthRequest, CharWidthRequestType, readCharWidths } from 'vs/editor/browser/config/charWidthReader'; -import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; +import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; class CSSBasedConfigurationCache { @@ -57,8 +57,8 @@ export function readFontInfo(bareFontInfo: BareFontInfo): FontInfo { return CSSBasedConfiguration.INSTANCE.readConfiguration(bareFontInfo); } -export function restoreFontInfo(storageService: IStorageService): void { - let strStoredFontInfo = storageService.get('editorFontInfo', StorageScope.GLOBAL); +export function restoreFontInfo(nextStorage2Service: INextStorage2Service): void { + let strStoredFontInfo = nextStorage2Service.get('editorFontInfo', StorageScope.GLOBAL); if (typeof strStoredFontInfo !== 'string') { return; } @@ -74,9 +74,9 @@ export function restoreFontInfo(storageService: IStorageService): void { CSSBasedConfiguration.INSTANCE.restoreFontInfo(storedFontInfo); } -export function saveFontInfo(storageService: IStorageService): void { +export function saveFontInfo(nextStorage2Service: INextStorage2Service): void { let knownFontInfo = CSSBasedConfiguration.INSTANCE.saveFontInfo(); - storageService.store('editorFontInfo', JSON.stringify(knownFontInfo), StorageScope.GLOBAL); + nextStorage2Service.set('editorFontInfo', JSON.stringify(knownFontInfo), StorageScope.GLOBAL); } export interface ISerializedFontInfo { diff --git a/src/vs/editor/contrib/find/findController.ts b/src/vs/editor/contrib/find/findController.ts index 6f6b67791cbf5c14d440120dc31c13f68d63a827..de3de63405c0b422197f37b80e32827e6a0782d8 100644 --- a/src/vs/editor/contrib/find/findController.ts +++ b/src/vs/editor/contrib/find/findController.ts @@ -14,7 +14,7 @@ import { FIND_IDS, FindModelBoundToEditorModel, ToggleCaseSensitiveKeybinding, T import { FindReplaceState, FindReplaceStateChangedEvent, INewFindReplaceState } from 'vs/editor/contrib/find/findState'; import { Delayer } from 'vs/base/common/async'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; -import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; +import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; @@ -72,7 +72,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd protected _state: FindReplaceState; protected _updateHistoryDelayer: Delayer; private _model: FindModelBoundToEditorModel; - protected _storageService: IStorageService; + private _nextStorage2Service: INextStorage2Service; private _clipboardService: IClipboardService; protected readonly _contextKeyService: IContextKeyService; @@ -83,14 +83,14 @@ export class CommonFindController extends Disposable implements editorCommon.IEd constructor( editor: ICodeEditor, @IContextKeyService contextKeyService: IContextKeyService, - @IStorageService storageService: IStorageService, + @INextStorage2Service nextStorage2Service: INextStorage2Service, @IClipboardService clipboardService: IClipboardService ) { super(); this._editor = editor; this._findWidgetVisible = CONTEXT_FIND_WIDGET_VISIBLE.bindTo(contextKeyService); this._contextKeyService = contextKeyService; - this._storageService = storageService; + this._nextStorage2Service = nextStorage2Service; this._clipboardService = clipboardService; this._updateHistoryDelayer = new Delayer(500); @@ -107,9 +107,9 @@ export class CommonFindController extends Disposable implements editorCommon.IEd this._state.change({ searchScope: null, - matchCase: this._storageService.getBoolean('editor.matchCase', StorageScope.WORKSPACE, false), - wholeWord: this._storageService.getBoolean('editor.wholeWord', StorageScope.WORKSPACE, false), - isRegex: this._storageService.getBoolean('editor.isRegex', StorageScope.WORKSPACE, false) + matchCase: this._nextStorage2Service.getBoolean('editor.matchCase', StorageScope.WORKSPACE, false), + wholeWord: this._nextStorage2Service.getBoolean('editor.wholeWord', StorageScope.WORKSPACE, false), + isRegex: this._nextStorage2Service.getBoolean('editor.isRegex', StorageScope.WORKSPACE, false) }, false); if (shouldRestartFind) { @@ -159,21 +159,21 @@ export class CommonFindController extends Disposable implements editorCommon.IEd private saveQueryState(e: FindReplaceStateChangedEvent) { if (e.isRegex) { - this._storageService.store('editor.isRegex', this._state.actualIsRegex, StorageScope.WORKSPACE); + this._nextStorage2Service.set('editor.isRegex', this._state.actualIsRegex, StorageScope.WORKSPACE); } if (e.wholeWord) { - this._storageService.store('editor.wholeWord', this._state.actualWholeWord, StorageScope.WORKSPACE); + this._nextStorage2Service.set('editor.wholeWord', this._state.actualWholeWord, StorageScope.WORKSPACE); } if (e.matchCase) { - this._storageService.store('editor.matchCase', this._state.actualMatchCase, StorageScope.WORKSPACE); + this._nextStorage2Service.set('editor.matchCase', this._state.actualMatchCase, StorageScope.WORKSPACE); } } private loadQueryState() { this._state.change({ - matchCase: this._storageService.getBoolean('editor.matchCase', StorageScope.WORKSPACE, this._state.matchCase), - wholeWord: this._storageService.getBoolean('editor.wholeWord', StorageScope.WORKSPACE, this._state.wholeWord), - isRegex: this._storageService.getBoolean('editor.isRegex', StorageScope.WORKSPACE, this._state.isRegex) + matchCase: this._nextStorage2Service.getBoolean('editor.matchCase', StorageScope.WORKSPACE, this._state.matchCase), + wholeWord: this._nextStorage2Service.getBoolean('editor.wholeWord', StorageScope.WORKSPACE, this._state.wholeWord), + isRegex: this._nextStorage2Service.getBoolean('editor.isRegex', StorageScope.WORKSPACE, this._state.isRegex) }, false); } @@ -366,10 +366,10 @@ export class FindController extends CommonFindController implements IFindControl @IContextKeyService _contextKeyService: IContextKeyService, @IKeybindingService private readonly _keybindingService: IKeybindingService, @IThemeService private readonly _themeService: IThemeService, - @IStorageService storageService: IStorageService, + @INextStorage2Service nextStorage2Service: INextStorage2Service, @optional(IClipboardService) clipboardService: IClipboardService ) { - super(editor, _contextKeyService, storageService, clipboardService); + super(editor, _contextKeyService, nextStorage2Service, clipboardService); } protected _start(opts: IFindStartOptions): void { diff --git a/src/vs/editor/contrib/find/test/findController.test.ts b/src/vs/editor/contrib/find/test/findController.test.ts index 6e3b504dc764e0e6143ba17f537967a78da97cd8..df888a3f1c1b6f831c78f25ee2b09eb9a6f8a30d 100644 --- a/src/vs/editor/contrib/find/test/findController.test.ts +++ b/src/vs/editor/contrib/find/test/findController.test.ts @@ -14,7 +14,8 @@ import { CONTEXT_FIND_INPUT_FOCUSED } from 'vs/editor/contrib/find/findModel'; import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; -import { IStorageService } from 'vs/platform/storage/common/storage'; +import { INextStorage2Service } from 'vs/platform/storage2/common/storage2'; +import { Event } from 'vs/base/common/event'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { Delayer } from 'vs/base/common/async'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; @@ -30,10 +31,10 @@ export class TestFindController extends CommonFindController { constructor( editor: ICodeEditor, @IContextKeyService contextKeyService: IContextKeyService, - @IStorageService storageService: IStorageService, + @INextStorage2Service nextStorage2Service: INextStorage2Service, @IClipboardService clipboardService: IClipboardService ) { - super(editor, contextKeyService, storageService, clipboardService); + super(editor, contextKeyService, nextStorage2Service, clipboardService); this._findInputFocused = CONTEXT_FIND_INPUT_FOCUSED.bindTo(contextKeyService); this._updateHistoryDelayer = new Delayer(50); } @@ -58,11 +59,16 @@ suite('FindController', () => { let queryState: { [key: string]: any; } = {}; let clipboardState = ''; let serviceCollection = new ServiceCollection(); - serviceCollection.set(IStorageService, { + serviceCollection.set(INextStorage2Service, { + _serviceBrand: undefined, + onDidChangeStorage: Event.None, + onWillClose: Event.None, get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], - store: (key: string, value: any) => { queryState[key] = value; } - } as IStorageService); + getInteger: (key: string) => undefined, + set: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); }, + delete: (key) => void 0 + } as INextStorage2Service); if (platform.isMacintosh) { serviceCollection.set(IClipboardService, { @@ -428,11 +434,16 @@ suite('FindController query options persistence', () => { queryState['editor.matchCase'] = false; queryState['editor.wholeWord'] = false; let serviceCollection = new ServiceCollection(); - serviceCollection.set(IStorageService, { + serviceCollection.set(INextStorage2Service, { + _serviceBrand: undefined, + onDidChangeStorage: Event.None, + onWillClose: Event.None, get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], - store: (key: string, value: any) => { queryState[key] = value; } - } as IStorageService); + getInteger: (key: string) => undefined, + set: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); }, + delete: (key) => void 0 + } as INextStorage2Service); test('matchCase', () => { withTestCodeEditor([ diff --git a/src/vs/editor/contrib/multicursor/test/multicursor.test.ts b/src/vs/editor/contrib/multicursor/test/multicursor.test.ts index db2774a0bdccc996cde0e232c37ae6ef8e43c376..161a1dba13564f2b59a22ed960efa51775778fa6 100644 --- a/src/vs/editor/contrib/multicursor/test/multicursor.test.ts +++ b/src/vs/editor/contrib/multicursor/test/multicursor.test.ts @@ -9,7 +9,8 @@ import { Range } from 'vs/editor/common/core/range'; import { InsertCursorAbove, InsertCursorBelow, MultiCursorSelectionController, SelectHighlightsAction, AddSelectionToNextFindMatchAction } from 'vs/editor/contrib/multicursor/multicursor'; import { Handler } from 'vs/editor/common/editorCommon'; import { EndOfLineSequence } from 'vs/editor/common/model'; -import { IStorageService } from 'vs/platform/storage/common/storage'; +import { INextStorage2Service } from 'vs/platform/storage2/common/storage2'; +import { Event } from 'vs/base/common/event'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { CommonFindController } from 'vs/editor/contrib/find/findController'; @@ -58,11 +59,16 @@ function fromRange(rng: Range): number[] { suite('Multicursor selection', () => { let queryState: { [key: string]: any; } = {}; let serviceCollection = new ServiceCollection(); - serviceCollection.set(IStorageService, { + serviceCollection.set(INextStorage2Service, { + _serviceBrand: undefined, + onDidChangeStorage: Event.None, + onWillClose: Event.None, get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], - store: (key: string, value: any) => { queryState[key] = value; } - } as IStorageService); + getInteger: (key: string) => undefined, + set: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); }, + delete: (key) => void 0 + } as INextStorage2Service); test('issue #8817: Cursor position changes when you cancel multicursor', () => { withTestCodeEditor([ diff --git a/src/vs/editor/contrib/parameterHints/test/parameterHintsModel.test.ts b/src/vs/editor/contrib/parameterHints/test/parameterHintsModel.test.ts index 586e2063108f1b98376aed7298cc1e092541ced9..12d50cc23e1aa9d80906f698e42421f24e52493e 100644 --- a/src/vs/editor/contrib/parameterHints/test/parameterHintsModel.test.ts +++ b/src/vs/editor/contrib/parameterHints/test/parameterHintsModel.test.ts @@ -14,7 +14,7 @@ import { TextModel } from 'vs/editor/common/model/textModel'; import * as modes from 'vs/editor/common/modes'; import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; -import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage'; +import { INextStorage2Service, NullNextStorage2Service } from 'vs/platform/storage2/common/storage2'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { ParameterHintsModel } from '../parameterHintsWidget'; @@ -44,7 +44,7 @@ suite('ParameterHintsModel', () => { model: textModel, serviceCollection: new ServiceCollection( [ITelemetryService, NullTelemetryService], - [IStorageService, NullStorageService] + [INextStorage2Service, NullNextStorage2Service] ) }); disposables.push(textModel); diff --git a/src/vs/editor/contrib/referenceSearch/referencesController.ts b/src/vs/editor/contrib/referenceSearch/referencesController.ts index e6cf807b0f17d4352308bf88ded6bf0b96f67bcb..0993412bccd2b7264866c92284c7194d7e873cf9 100644 --- a/src/vs/editor/contrib/referenceSearch/referencesController.ts +++ b/src/vs/editor/contrib/referenceSearch/referencesController.ts @@ -10,7 +10,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IStorageService } from 'vs/platform/storage/common/storage'; +import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ReferencesModel } from './referencesModel'; @@ -52,7 +52,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri @ICodeEditorService private readonly _editorService: ICodeEditorService, @INotificationService private readonly _notificationService: INotificationService, @IInstantiationService private readonly _instantiationService: IInstantiationService, - @IStorageService private readonly _storageService: IStorageService, + @INextStorage2Service private readonly _nextStorage2Service: INextStorage2Service, @IConfigurationService private readonly _configurationService: IConfigurationService, ) { this._editor = editor; @@ -95,14 +95,14 @@ export abstract class ReferencesController implements editorCommon.IEditorContri } })); const storageKey = 'peekViewLayout'; - const data = JSON.parse(this._storageService.get(storageKey, undefined, '{}')); + const data = JSON.parse(this._nextStorage2Service.get(storageKey, StorageScope.GLOBAL, '{}')); this._widget = this._instantiationService.createInstance(ReferenceWidget, this._editor, this._defaultTreeKeyboardSupport, data); this._widget.setTitle(nls.localize('labelLoading', "Loading...")); this._widget.show(range); this._disposables.push(this._widget.onDidClose(() => { modelPromise.cancel(); - this._storageService.store(storageKey, JSON.stringify(this._widget.layoutData)); + this._nextStorage2Service.set(storageKey, JSON.stringify(this._widget.layoutData), StorageScope.GLOBAL); this._widget = null; this.closeWidget(); })); diff --git a/src/vs/editor/contrib/suggest/suggestMemory.ts b/src/vs/editor/contrib/suggest/suggestMemory.ts index c99f226fa631a39793cca28bacb231c8e45a50aa..bdf464451534f06892a4b5461a7ca4f97ff0ae58 100644 --- a/src/vs/editor/contrib/suggest/suggestMemory.ts +++ b/src/vs/editor/contrib/suggest/suggestMemory.ts @@ -5,7 +5,7 @@ import { ICompletionItem } from 'vs/editor/contrib/suggest/completionModel'; import { LRUCache, TernarySearchTree } from 'vs/base/common/map'; -import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; +import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2'; import { ITextModel } from 'vs/editor/common/model'; import { IPosition } from 'vs/editor/common/core/position'; import { RunOnceScheduler } from 'vs/base/common/async'; @@ -205,7 +205,7 @@ export class SuggestMemories { constructor( editor: ICodeEditor, - @IStorageService private readonly _storageService: IStorageService, + @INextStorage2Service private readonly _nextStorage2Service: INextStorage2Service, ) { this._persistSoon = new RunOnceScheduler(() => this._flush(), 3000); this._setMode(editor.getConfiguration().contribInfo.suggestSelection); @@ -224,7 +224,7 @@ export class SuggestMemories { this._strategy = mode === 'recentlyUsedByPrefix' ? new PrefixMemory() : mode === 'recentlyUsed' ? new LRUMemory() : new NoMemory(); try { - const raw = this._storageService.get(`${this._storagePrefix}/${this._mode}`, StorageScope.WORKSPACE); + const raw = this._nextStorage2Service.get(`${this._storagePrefix}/${this._mode}`, StorageScope.WORKSPACE); if (raw) { this._strategy.fromJSON(JSON.parse(raw)); } @@ -244,6 +244,6 @@ export class SuggestMemories { private _flush() { const raw = JSON.stringify(this._strategy); - this._storageService.store(`${this._storagePrefix}/${this._mode}`, raw, StorageScope.WORKSPACE); + this._nextStorage2Service.set(`${this._storagePrefix}/${this._mode}`, raw, StorageScope.WORKSPACE); } } diff --git a/src/vs/editor/contrib/suggest/suggestWidget.ts b/src/vs/editor/contrib/suggest/suggestWidget.ts index 803d95a7a58daab9c41989e6e522a23dc6852117..5e4e9db523504b962da4a5aaaf1e5cd025d52166 100644 --- a/src/vs/editor/contrib/suggest/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/suggestWidget.ts @@ -26,7 +26,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { attachListStyler } from 'vs/platform/theme/common/styler'; import { IThemeService, ITheme, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { registerColor, editorWidgetBackground, listFocusBackground, activeContrastBorder, listHighlightForeground, editorForeground, editorWidgetBorder, focusBorder, textLinkForeground, textCodeBlockBackground } from 'vs/platform/theme/common/colorRegistry'; -import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; +import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2'; import { MarkdownRenderer } from 'vs/editor/contrib/markdown/markdownRenderer'; import { IModeService } from 'vs/editor/common/services/modeService'; import { IOpenerService } from 'vs/platform/opener/common/opener'; @@ -397,13 +397,10 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate new SimpleProgressService()); + export const nextStorage2Service = define(INextStorage2Service, () => NullNextStorage2Service); + export const storageService = define(IStorageService, () => NullStorageService); export const logService = define(ILogService, () => new NullLogService()); diff --git a/src/vs/platform/storage2/electron-browser/nextStorage2Service.ts b/src/vs/platform/storage2/electron-browser/nextStorage2Service.ts index 9c7275ec64e5f4fb9df3994e0e20877aacd1de76..4df303e6fcc9155ace67169c20277e23df668023 100644 --- a/src/vs/platform/storage2/electron-browser/nextStorage2Service.ts +++ b/src/vs/platform/storage2/electron-browser/nextStorage2Service.ts @@ -94,7 +94,7 @@ export class NextStorage2Service extends Disposable implements INextStorage2Serv } } -export class NextDelegatingStorageService extends Disposable implements INextStorage2Service { +export class NextDelegatingStorage2Service extends Disposable implements INextStorage2Service { _serviceBrand: any; private _onDidChangeStorage: Emitter = this._register(new Emitter()); diff --git a/src/vs/platform/telemetry/node/workbenchCommonProperties.ts b/src/vs/platform/telemetry/node/workbenchCommonProperties.ts index 2636473a277b1e7f31c384c11c8c0a4e59ca53b5..517232aeb28dab560e39cde77906ad1411981f9c 100644 --- a/src/vs/platform/telemetry/node/workbenchCommonProperties.ts +++ b/src/vs/platform/telemetry/node/workbenchCommonProperties.ts @@ -5,37 +5,42 @@ import { TPromise } from 'vs/base/common/winjs.base'; import * as uuid from 'vs/base/common/uuid'; -import { IStorageService } from 'vs/platform/storage/common/storage'; -import { resolveCommonProperties } from '../node/commonProperties'; +import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2'; +import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties'; -export function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string, version: string, machineId: string, installSourcePath: string): TPromise<{ [name: string]: string }> { +export function resolveWorkbenchCommonProperties(nextStorage2Service: INextStorage2Service, commit: string, version: string, machineId: string, installSourcePath: string): TPromise<{ [name: string]: string }> { return resolveCommonProperties(commit, version, machineId, installSourcePath).then(result => { // __GDPR__COMMON__ "common.version.shell" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" } result['common.version.shell'] = process.versions && (process).versions['electron']; // __GDPR__COMMON__ "common.version.renderer" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" } result['common.version.renderer'] = process.versions && (process).versions['chrome']; - const lastSessionDate = storageService.get('telemetry.lastSessionDate'); - const firstSessionDate = storageService.get('telemetry.firstSessionDate') || new Date().toUTCString(); - storageService.store('telemetry.firstSessionDate', firstSessionDate); - storageService.store('telemetry.lastSessionDate', new Date().toUTCString()); + const lastSessionDate = nextStorage2Service.get('telemetry.lastSessionDate', StorageScope.GLOBAL); + nextStorage2Service.set('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.GLOBAL); // __GDPR__COMMON__ "common.firstSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } - result['common.firstSessionDate'] = firstSessionDate; + result['common.firstSessionDate'] = getOrCreateFirstSessionDate(nextStorage2Service); // __GDPR__COMMON__ "common.lastSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } result['common.lastSessionDate'] = lastSessionDate; // __GDPR__COMMON__ "common.isNewSession" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } result['common.isNewSession'] = !lastSessionDate ? '1' : '0'; // __GDPR__COMMON__ "common.instanceId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" } - result['common.instanceId'] = getOrCreateInstanceId(storageService); + result['common.instanceId'] = getOrCreateInstanceId(nextStorage2Service); return result; }); } -function getOrCreateInstanceId(storageService: IStorageService): string { - const result = storageService.get('telemetry.instanceId') || uuid.generateUuid(); - storageService.store('telemetry.instanceId', result); +function getOrCreateInstanceId(nextStorage2Service: INextStorage2Service): string { + const result = nextStorage2Service.get('telemetry.instanceId', StorageScope.GLOBAL, uuid.generateUuid()); + nextStorage2Service.set('telemetry.instanceId', result, StorageScope.GLOBAL); return result; +} + +function getOrCreateFirstSessionDate(nextStorage2Service: INextStorage2Service): string { + const firstSessionDate = nextStorage2Service.get('telemetry.firstSessionDate', StorageScope.GLOBAL, new Date().toUTCString()); + nextStorage2Service.set('telemetry.firstSessionDate', firstSessionDate, StorageScope.GLOBAL); + + return firstSessionDate; } \ No newline at end of file diff --git a/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts b/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts index 9acbf8db7c897ff6adb53375df29367840b37b24..771974014eb307ac64dab4d78254cc9643d075b4 100644 --- a/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts +++ b/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts @@ -7,9 +7,10 @@ import * as path from 'path'; import * as os from 'os'; import * as fs from 'fs'; import { resolveWorkbenchCommonProperties } from 'vs/platform/telemetry/node/workbenchCommonProperties'; -import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService'; -import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace'; -import { getRandomTestPath } from 'vs/workbench/test/workbenchTestServices'; +import { getRandomTestPath, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices'; +import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2'; +import { NextStorage2Service } from 'vs/platform/storage2/electron-browser/nextStorage2Service'; +import { NullLogService } from 'vs/platform/log/common/log'; import { del } from 'vs/base/node/extfs'; import { mkdirp } from 'vs/base/node/pfs'; import { timeout } from 'vs/base/common/async'; @@ -20,10 +21,10 @@ suite('Telemetry - common properties', function () { const commit: string = void 0; const version: string = void 0; - let storageService: StorageService; + let nestStorage2Service: INextStorage2Service; setup(() => { - storageService = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id); + nestStorage2Service = new NextStorage2Service(':memory:', new NullLogService(), TestEnvironmentService); }); teardown(done => { @@ -33,7 +34,7 @@ suite('Telemetry - common properties', function () { test('default', async function () { await mkdirp(parentDir); fs.writeFileSync(installSource, 'my.install.source'); - const props = await resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource); + const props = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource); assert.ok('commitHash' in props); assert.ok('sessionID' in props); assert.ok('timestamp' in props); @@ -54,22 +55,22 @@ suite('Telemetry - common properties', function () { assert.ok('common.instanceId' in props, 'instanceId'); assert.ok('common.machineId' in props, 'machineId'); fs.unlinkSync(installSource); - const props_1 = await resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource); + const props_1 = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource); assert.ok(!('common.source' in props_1)); }); test('lastSessionDate when aviablale', async function () { - storageService.store('telemetry.lastSessionDate', new Date().toUTCString()); + nestStorage2Service.set('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.GLOBAL); - const props = await resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource); + const props = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource); assert.ok('common.lastSessionDate' in props); // conditional, see below assert.ok('common.isNewSession' in props); assert.equal(props['common.isNewSession'], 0); }); test('values chance on ask', async function () { - const props = await resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource); + const props = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource); let value1 = props['common.sequence']; let value2 = props['common.sequence']; assert.ok(value1 !== value2, 'seq'); diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index f2b216b4b16f83cbb74cbaac6adee9851af7692b..778b6fb6f46ad761959c05f9064b4d56b1d5a8ff 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -36,7 +36,7 @@ import { IWorkspacesService, ISingleFolderWorkspaceIdentifier } from 'vs/platfor import { createSpdLogService } from 'vs/platform/log/node/spdlogService'; import * as fs from 'fs'; import { ConsoleLogService, MultiplexLogService, ILogService } from 'vs/platform/log/common/log'; -import { NextStorage2Service, NextDelegatingStorageService } from 'vs/platform/storage2/electron-browser/nextStorage2Service'; +import { NextStorage2Service, NextDelegatingStorage2Service } from 'vs/platform/storage2/electron-browser/nextStorage2Service'; import { IssueChannelClient } from 'vs/platform/issue/node/issueIpc'; import { IIssueService } from 'vs/platform/issue/common/issue'; import { LogLevelSetterChannelClient, FollowerLogService } from 'vs/platform/log/node/logIpc'; @@ -104,7 +104,7 @@ function openWorkbench(configuration: IWindowConfiguration): Promise { ]).then(services => { const workspaceService = services[0]; const storageService = createStorageService(workspaceService, environmentService); - const nextStorage2Service = new NextDelegatingStorageService(services[1], storageService, logService, environmentService); + const nextStorage2Service = new NextDelegatingStorage2Service(services[1], storageService, logService, environmentService); return domContentLoaded().then(() => { perf.mark('willStartWorkbench'); diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 65f933f4f59351f6708bedda3972904c74a4e562..73bdf81a9ac20fd8b7abff44e26e1e8dad547eec 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -75,7 +75,7 @@ import { IBroadcastService, BroadcastService } from 'vs/platform/broadcast/elect import { HashService } from 'vs/workbench/services/hash/node/hashService'; import { IHashService } from 'vs/workbench/services/hash/common/hashService'; import { ILogService } from 'vs/platform/log/common/log'; -import { INextStorage2Service } from 'vs/platform/storage2/common/storage2'; +import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2'; import { Event, Emitter } from 'vs/base/common/event'; import { WORKBENCH_BACKGROUND } from 'vs/workbench/common/theme'; import { stat } from 'fs'; @@ -170,8 +170,11 @@ export class WorkbenchShell extends Disposable { const [instantiationService, serviceCollection] = this.initServiceCollection(this.container); // Warm up font cache information before building up too many dom elements - restoreFontInfo(this.storageService); + restoreFontInfo(this.nextStorage2Service); readFontInfo(BareFontInfo.createFromRawSettings(this.configurationService.getValue('editor'), browser.getZoomLevel())); + this._register(this.nextStorage2Service.onWillClose(() => { + saveFontInfo(this.nextStorage2Service); // Keep font info for next startup around + })); // Workbench this.workbench = this.createWorkbench(instantiationService, serviceCollection, this.container); @@ -286,17 +289,17 @@ export class WorkbenchShell extends Disposable { } perf.mark('willReadLocalStorage'); - const readyToSend = this.storageService.getBoolean('localStorageMetricsReadyToSend2'); + const readyToSend = this.nextStorage2Service.getBoolean('localStorageMetricsReadyToSend2', StorageScope.GLOBAL); perf.mark('didReadLocalStorage'); if (!readyToSend) { - this.storageService.store('localStorageMetricsReadyToSend2', true); + this.nextStorage2Service.set('localStorageMetricsReadyToSend2', true, StorageScope.GLOBAL); return; // avoid logging localStorage metrics directly after the update, we prefer cold startup numbers } - if (!this.storageService.getBoolean('localStorageMetricsSent2')) { + if (!this.nextStorage2Service.getBoolean('localStorageMetricsSent2', StorageScope.GLOBAL)) { perf.mark('willWriteLocalStorage'); - this.storageService.store('localStorageMetricsSent2', true); + this.nextStorage2Service.set('localStorageMetricsSent2', true, StorageScope.GLOBAL); perf.mark('didWriteLocalStorage'); perf.mark('willStatLocalStorage'); @@ -366,7 +369,7 @@ export class WorkbenchShell extends Disposable { const channel = getDelayedChannel(sharedProcess.then(c => c.getChannel('telemetryAppender'))); const config: ITelemetryServiceConfig = { appender: combinedAppender(new TelemetryAppenderClient(channel), new LogAppender(this.logService)), - commonProperties: resolveWorkbenchCommonProperties(this.storageService, product.commit, pkg.version, this.configuration.machineId, this.environmentService.installSourcePath), + commonProperties: resolveWorkbenchCommonProperties(this.nextStorage2Service, product.commit, pkg.version, this.configuration.machineId, this.environmentService.installSourcePath), piiPaths: [this.environmentService.appRoot, this.environmentService.extensionsPath] }; @@ -517,9 +520,6 @@ export class WorkbenchShell extends Disposable { dispose(reason = ShutdownReason.QUIT): void { super.dispose(); - // Keep font info for next startup around - saveFontInfo(this.storageService); - // Dispose Workbench if (this.workbench) { this.workbench.dispose(reason); @@ -529,7 +529,6 @@ export class WorkbenchShell extends Disposable { } } - registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { // Foreground diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts b/src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts index 6600300211dd8c9b10fdffe7c90fdabb40cab13e..e37b47887d38d1e42053b2f15106d23c3125f679 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts @@ -6,7 +6,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IStorageService } from 'vs/platform/storage/common/storage'; +import { INextStorage2Service } from 'vs/platform/storage2/common/storage2'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { INotificationService } from 'vs/platform/notification/common/notification'; @@ -21,7 +21,7 @@ export class WorkbenchReferencesController extends ReferencesController { @ICodeEditorService editorService: ICodeEditorService, @INotificationService notificationService: INotificationService, @IInstantiationService instantiationService: IInstantiationService, - @IStorageService storageService: IStorageService, + @INextStorage2Service nextStorage2Service: INextStorage2Service, @IConfigurationService configurationService: IConfigurationService, ) { super( @@ -31,8 +31,8 @@ export class WorkbenchReferencesController extends ReferencesController { editorService, notificationService, instantiationService, - storageService, - configurationService, + nextStorage2Service, + configurationService ); } }