userDataProfileStorageService.ts ×8

Frontier kind: Code frontier

unlabeled · c_274635235b6f

91 tests · 14103 LOC · 65 files · introduces 0 tests · 94 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges94 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2031 ranges14103 lines · 65 files · Browse complete extent
All tests (intent)
91 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 94 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/parts/storage/common/storage.ts 36 introduced LOC · 7 ranges

Open complete file

198
199 async init(): Promise<void> {
200 > if (this.state !== StorageState.None) { storage.ts
201 return; // either closed or already initialized
202 }
203 > storage.ts
204 > this.state = StorageState.Initialized;
205 >
206 > if (this.options.hint === StorageHint.STORAGE_DOES_NOT_EXIST) {
207 // return early if we know the storage file does not exist. this is a performance
208 // optimization to not load all items of the underlying storage if we know that
210 return;
211 }
212 > storage.ts
213 > this.cache = await this.database.getItems();
214 > }
215
216 get(key: string, fallbackValue: string): string;
330
331 async close(): Promise<void> {
332 > if (!this.pendingClose) { storage.ts
333 > this.pendingClose = this.doClose();
334 > }
335 >
336 > return this.pendingClose;
337 > }
338
339 private async doClose(): Promise<void> {
340 > storage.ts
341 > // Update state
342 > this.state = StorageState.Closed;
343 >
344 > // Trigger new flush to ensure data is persisted and then close
345 > // even if there is an error flushing. We must always ensure
346 > // the DB is closed to avoid corruption.
347 > //
348 > // Recovery: we pass our cache over as recovery option in case
349 > // the DB is not healthy.
350 > try {
351 > await this.doFlush(0 /* as soon as possible */);
352 > } catch {
353 > // Ignore
354 > }
355 >
356 > await this.database.close(() => this.cache);
357 > }
358
359 private get hasPending() {
399 return this.flushPending(); // return early if in-memory
400 }
401 > storage.ts
402 > return this.flushDelayer.trigger(() => this.flushPending(), delay);
403 }
404
423
424 async getItems(): Promise<Map<string, string>> {
425 > return this.items; storage.ts
426 > }
427
428 async updateItems(request: IUpdateRequest): Promise<void> {
src/vs/platform/userDataProfile/common/userDataProfileStorageService.ts 33 introduced LOC · 8 ranges

Open complete file

90 return fn(this.storageService);
91 }
93 let storageService = this.storageServicesMap?.get(profile.id);
94 if (!storageService) {
95 > storageService = new StorageService(this.createStorageDatabase(profile)); userDataProfileStorageService.ts
96 > this.storageServicesMap?.set(profile.id, storageService);
97 >
98 > try {
99 > await storageService.initialize();
100 > } catch (error) {
101 if (this.storageServicesMap?.has(profile.id)) {
102 this.storageServicesMap.deleteAndDispose(profile.id);
106 throw error;
107 }
109 > try {
110 > const result = await fn(storageService);
111 > await storageService.flush();
112 > return result;
113 > } finally {
114 > if (!this.storageServicesMap?.has(profile.id)) {
115 > storageService.dispose();
116 > }
117 > }
118 }
119
185
186 constructor(private readonly profileStorageDatabase: Promise<IStorageDatabase>) {
187 > super({ flushInterval: 100 }); userDataProfileStorageService.ts
188 > }
189
190 protected async doInitialize(): Promise<void> {
191 > const profileStorageDatabase = await this.profileStorageDatabase; userDataProfileStorageService.ts
192 > const profileStorage = new Storage(profileStorageDatabase);
193 > this._register(profileStorage.onDidChangeStorage(e => {
194 this.emitDidChangeValue(StorageScope.PROFILE, e);
196 > this._register(toDisposable(() => {
197 > profileStorage.close();
198 > profileStorage.dispose();
199 > if (isDisposable(profileStorageDatabase)) {
200 profileStorageDatabase.dispose();
201 }
203 > this.profileStorage = profileStorage;
204 > return this.profileStorage.init();
205 > }
206
207 protected getStorage(scope: StorageScope): IStorage | undefined {
208 > return scope === StorageScope.PROFILE ? this.profileStorage : undefined; userDataProfileStorageService.ts
209 > }
210
211 protected getLogDetails(): string | undefined { return undefined; }
src/vs/platform/storage/common/storage.ts 25 introduced LOC · 1 range

Open complete file

377
378 initialize(): Promise<void> {
379 > if (!this.initializationPromise) { storage.ts
380 > this.initializationPromise = (async () => {
381 >
382 > // Init all storage locations
383 > mark('code/willInitStorage');
384 > try {
385 > await this.doInitialize(); // Ask subclasses to initialize storage
386 > } finally {
387 > mark('code/didInitStorage');
388 > }
389 >
390 > // On some OS we do not get enough time to persist state on shutdown (e.g. when
391 > // Windows restarts after applying updates). In other cases, VSCode might crash,
392 > // so we periodically save state to reduce the chance of loosing any state.
393 > // In the browser we do not have support for long running unload sequences. As such,
394 > // we cannot ask for saving state in that moment, because that would result in a
395 > // long running operation.
396 > // Instead, periodically ask customers to save save. The library will be clever enough
397 > // to only save state that has actually changed.
398 > this.flushWhenIdleScheduler.schedule();
399 > })();
400 > }
401 >
402 > return this.initializationPromise;
403 > }
404
405 protected emitDidChangeValue(scope: StorageScope, event: IStorageChangeEvent): void {