diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 734c3ea458d..dd906ac9c49 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1020,7 +1020,7 @@ declare module 'vscode' { export namespace window { - export function registerUserDataProvider(name: string, userDataProvider: UserDataProvider): Disposable; + export function registerUserDataSyncProvider(name: string, userDataProvider: UserDataSyncProvider): Disposable; } @@ -1034,7 +1034,7 @@ declare module 'vscode' { constructor(); } - export interface UserDataProvider { + export interface UserDataSyncProvider { read(key: string): Promise<{ content: string, ref: string } | null>; diff --git a/src/vs/workbench/api/browser/mainThreadUserData.ts b/src/vs/workbench/api/browser/mainThreadUserData.ts index 5d797fa7098..4a95b0fa253 100644 --- a/src/vs/workbench/api/browser/mainThreadUserData.ts +++ b/src/vs/workbench/api/browser/mainThreadUserData.ts @@ -6,7 +6,7 @@ import { Disposable, toDisposable } from 'vs/base/common/lifecycle'; import { MainContext, ExtHostContext, IExtHostContext, MainThreadUserDataShape, ExtHostUserDataShape } from '../common/extHost.protocol'; import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; -import { IRemoteUserDataService, IUserData } from 'vs/workbench/services/userData/common/userData'; +import { IUserDataSyncStoreService, IUserData } from 'vs/workbench/services/userData/common/userData'; @extHostNamedCustomer(MainContext.MainThreadUserData) export class MainThreadUserData extends Disposable implements MainThreadUserDataShape { @@ -15,16 +15,16 @@ export class MainThreadUserData extends Disposable implements MainThreadUserData constructor( extHostContext: IExtHostContext, - @IRemoteUserDataService private readonly remoteUserDataService: IRemoteUserDataService + @IUserDataSyncStoreService private readonly userDataSyncStoreService: IUserDataSyncStoreService ) { super(); this.proxy = extHostContext.getProxy(ExtHostContext.ExtHostUserData); - this._register(toDisposable(() => this.remoteUserDataService.deregisterRemoteUserDataProvider())); + this._register(toDisposable(() => this.userDataSyncStoreService.deregisterUserDataSyncStore())); } $registerUserDataProvider(name: string): void { const proxy = this.proxy; - this.remoteUserDataService.registerRemoteUserDataProvider(name, { + this.userDataSyncStoreService.registerUserDataSyncStore(name, { read(key: string): Promise { return proxy.$read(key); }, @@ -35,7 +35,7 @@ export class MainThreadUserData extends Disposable implements MainThreadUserData } $deregisterUserDataProvider(): void { - this.remoteUserDataService.deregisterRemoteUserDataProvider(); + this.userDataSyncStoreService.deregisterUserDataSyncStore(); } } diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 0d3124b4a61..5c0b7e82bb8 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -542,7 +542,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I createInputBox(): vscode.InputBox { return extHostQuickOpen.createInputBox(extension.identifier); }, - registerUserDataProvider: (identity: string, userDataProvider: vscode.UserDataProvider): vscode.Disposable => { + registerUserDataSyncProvider: (identity: string, userDataProvider: vscode.UserDataSyncProvider): vscode.Disposable => { checkProposedApiEnabled(extension); return extHostUserData.registerUserDataProvider(identity, userDataProvider); } diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 562f353bf06..6161dbb8667 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -14,7 +14,7 @@ import { generateUuid } from 'vs/base/common/uuid'; import * as vscode from 'vscode'; import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from 'vs/platform/files/common/files'; import { RemoteAuthorityResolverErrorCode } from 'vs/platform/remote/common/remoteAuthorityResolver'; -import { RemoteUserDataErrorCode, markAsUserDataError } from 'vs/workbench/services/userData/common/userData'; +import { UserDataSyncStoreErrorCode, markAsUserDataSyncStoreError } from 'vs/workbench/services/userData/common/userData'; function es5ClassCompat(target: Function): any { ///@ts-ignore @@ -2373,15 +2373,15 @@ export class Decoration { export class UserDataError extends Error { static Rejected(message?: string): UserDataError { - return new UserDataError(message, RemoteUserDataErrorCode.Rejected); + return new UserDataError(message, UserDataSyncStoreErrorCode.Rejected); } - constructor(message?: string, code: RemoteUserDataErrorCode = RemoteUserDataErrorCode.Unknown) { + constructor(message?: string, code: UserDataSyncStoreErrorCode = UserDataSyncStoreErrorCode.Unknown) { super(message); // mark the error as user data provider error so that // we can extract the error code on the receiving side - markAsUserDataError(this, code); + markAsUserDataSyncStoreError(this, code); // workaround when extending builtin objects and when compiling to ES5, see: // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work diff --git a/src/vs/workbench/api/common/extHostUserData.ts b/src/vs/workbench/api/common/extHostUserData.ts index a8029eaebc5..6a654a874ea 100644 --- a/src/vs/workbench/api/common/extHostUserData.ts +++ b/src/vs/workbench/api/common/extHostUserData.ts @@ -12,7 +12,7 @@ import { IUserData } from 'vs/workbench/services/userData/common/userData'; export class ExtHostUserData implements ExtHostUserDataShape { private name: string | null = null; - private userDataProvider: vscode.UserDataProvider | null = null; + private userDataProvider: vscode.UserDataSyncProvider | null = null; constructor( private readonly proxy: MainThreadUserDataShape, @@ -20,7 +20,7 @@ export class ExtHostUserData implements ExtHostUserDataShape { ) { } - registerUserDataProvider(name: string, userDataProvider: vscode.UserDataProvider): vscode.Disposable { + registerUserDataProvider(name: string, userDataProvider: vscode.UserDataSyncProvider): vscode.Disposable { if (this.userDataProvider) { this.logService.warn(`A user data provider '${this.name}' already exists hence ignoring the remote user data provider '${name}'.`); return Disposable.None; diff --git a/src/vs/workbench/contrib/userData/browser/userData.contribution.ts b/src/vs/workbench/contrib/userData/browser/userData.contribution.ts index 0df9ffb18a1..8891eb61b82 100644 --- a/src/vs/workbench/contrib/userData/browser/userData.contribution.ts +++ b/src/vs/workbench/contrib/userData/browser/userData.contribution.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions'; -import { IUserDataSyncService, SyncStatus, USER_DATA_PREVIEW_SCHEME, IRemoteUserDataService } from 'vs/workbench/services/userData/common/userData'; +import { IUserDataSyncService, SyncStatus, USER_DATA_PREVIEW_SCHEME, IUserDataSyncStoreService } from 'vs/workbench/services/userData/common/userData'; import { localize } from 'vs/nls'; import { Disposable, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; @@ -48,13 +48,13 @@ class UserDataSyncContribution extends Disposable implements IWorkbenchContribut constructor( @IConfigurationService private readonly configurationService: IConfigurationService, @IUserDataSyncService private readonly userDataSyncService: IUserDataSyncService, - @IRemoteUserDataService private readonly remoteUserDataService: IRemoteUserDataService, + @IUserDataSyncStoreService private readonly userDataSyncStoreService: IUserDataSyncStoreService, ) { super(); this.sync(true); this._register(Event.any( Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('userConfiguration.enableSync') && this.configurationService.getValue('userConfiguration.enableSync')), - this.remoteUserDataService.onDidChangeEnablement) + this.userDataSyncStoreService.onDidChangeEnablement) (() => this.sync(true))); // Sync immediately if there is a local change. @@ -62,7 +62,7 @@ class UserDataSyncContribution extends Disposable implements IWorkbenchContribut } private async sync(loop: boolean): Promise { - if (this.configurationService.getValue('userConfiguration.enableSync') && this.remoteUserDataService.isEnabled()) { + if (this.configurationService.getValue('userConfiguration.enableSync') && this.userDataSyncStoreService.isEnabled()) { try { await this.userDataSyncService.sync(); } catch (e) { diff --git a/src/vs/workbench/services/userData/common/remoteUserDataService.ts b/src/vs/workbench/services/userData/common/remoteUserDataService.ts deleted file mode 100644 index 2a007edc5f0..00000000000 --- a/src/vs/workbench/services/userData/common/remoteUserDataService.ts +++ /dev/null @@ -1,70 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { Disposable, } from 'vs/base/common/lifecycle'; -import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; -import { Emitter, Event } from 'vs/base/common/event'; -import { IRemoteUserDataService, IRemoteUserDataProvider, IUserData, RemoteUserDataError, toUserDataErrorCode } from 'vs/workbench/services/userData/common/userData'; -import { ILogService } from 'vs/platform/log/common/log'; - -export class RemoteUserDataService extends Disposable implements IRemoteUserDataService { - - _serviceBrand: any; - - private remoteUserDataProvider: IRemoteUserDataProvider | null = null; - private name: string | null = null; - - private readonly _onDidChangeEnablement: Emitter = this._register(new Emitter()); - readonly onDidChangeEnablement: Event = this._onDidChangeEnablement.event; - - constructor( - @ILogService private logService: ILogService - ) { - super(); - } - - registerRemoteUserDataProvider(name: string, remoteUserDataProvider: IRemoteUserDataProvider): void { - if (this.remoteUserDataProvider) { - this.logService.warn(`A remote user data provider '${this.name}' already exists hence ignoring the remote user data provider '${name}'.`); - return; - } - this.remoteUserDataProvider = remoteUserDataProvider; - this.name = name; - this._onDidChangeEnablement.fire(true); - } - - deregisterRemoteUserDataProvider(): void { - this.remoteUserDataProvider = null; - this.name = null; - this._onDidChangeEnablement.fire(false); - } - - getName(): string | null { - return this.name; - } - - isEnabled(): boolean { - return !!this.remoteUserDataProvider; - } - - read(key: string): Promise { - if (!this.remoteUserDataProvider) { - throw new Error('No remote user data provider exists.'); - } - return this.remoteUserDataProvider.read(key) - .then(null, error => Promise.reject(new RemoteUserDataError(error.message, toUserDataErrorCode(error)))); - } - - write(key: string, content: string, ref: string | null): Promise { - if (!this.remoteUserDataProvider) { - throw new Error('No remote user data provider exists.'); - } - return this.remoteUserDataProvider.write(key, content, ref) - .then(null, error => Promise.reject(new RemoteUserDataError(error.message, toUserDataErrorCode(error)))); - } - -} - -registerSingleton(IRemoteUserDataService, RemoteUserDataService); diff --git a/src/vs/workbench/services/userData/common/settingsSync.ts b/src/vs/workbench/services/userData/common/settingsSync.ts index ab4e5ddd448..76ee09a2b3e 100644 --- a/src/vs/workbench/services/userData/common/settingsSync.ts +++ b/src/vs/workbench/services/userData/common/settingsSync.ts @@ -8,7 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { IFileService, FileSystemProviderErrorCode, FileSystemProviderError, IFileContent } from 'vs/platform/files/common/files'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; -import { IRemoteUserDataService, IUserData, RemoteUserDataError, RemoteUserDataErrorCode, ISynchroniser, SyncStatus, SETTINGS_PREVIEW_RESOURCE } from 'vs/workbench/services/userData/common/userData'; +import { IUserDataSyncStoreService, IUserData, UserDataSyncStoreError, UserDataSyncStoreErrorCode, ISynchroniser, SyncStatus, SETTINGS_PREVIEW_RESOURCE } from 'vs/workbench/services/userData/common/userData'; import { VSBuffer } from 'vs/base/common/buffer'; import { parse, findNodeAtLocation, parseTree, ParseError } from 'vs/base/common/json'; import { ITextModel } from 'vs/editor/common/model'; @@ -54,7 +54,7 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser { @IFileService private readonly fileService: IFileService, @IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService, @IStorageService private readonly storageService: IStorageService, - @IRemoteUserDataService private readonly remoteUserDataService: IRemoteUserDataService, + @IUserDataSyncStoreService private readonly userDataSyncStoreService: IUserDataSyncStoreService, @IModelService private readonly modelService: IModelService, @IModeService private readonly modeService: IModeService, @IEditorService private readonly editorService: IEditorService, @@ -107,7 +107,7 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser { } catch (e) { this.syncPreviewResultPromise = null; this.setStatus(SyncStatus.Idle); - if (e instanceof RemoteUserDataError && e.code === RemoteUserDataErrorCode.Rejected) { + if (e instanceof UserDataSyncStoreError && e.code === UserDataSyncStoreErrorCode.Rejected) { // Rejected as there is a new remote version. Syncing again, this.logService.info('Failed to Synchronise settings as there is a new remote version available. Synchronising again...'); return this.sync(); @@ -193,7 +193,7 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser { } private async generatePreview(): Promise { - const remoteUserData = await this.remoteUserDataService.read(SettingsSynchroniser.EXTERNAL_USER_DATA_SETTINGS_KEY); + const remoteUserData = await this.userDataSyncStoreService.read(SettingsSynchroniser.EXTERNAL_USER_DATA_SETTINGS_KEY); // Get file content last to get the latest const fileContent = await this.getLocalFileContent(); const { settingsPreview, hasLocalChanged, hasRemoteChanged, hasConflicts } = this.computeChanges(fileContent, remoteUserData); @@ -433,7 +433,7 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser { } private async writeToRemote(content: string, ref: string | null): Promise { - return this.remoteUserDataService.write(SettingsSynchroniser.EXTERNAL_USER_DATA_SETTINGS_KEY, content, ref); + return this.userDataSyncStoreService.write(SettingsSynchroniser.EXTERNAL_USER_DATA_SETTINGS_KEY, content, ref); } private async writeToLocal(newContent: string, oldContent: IFileContent | null): Promise { diff --git a/src/vs/workbench/services/userData/common/userData.ts b/src/vs/workbench/services/userData/common/userData.ts index 911c9c6f11d..4667aa42b60 100644 --- a/src/vs/workbench/services/userData/common/userData.ts +++ b/src/vs/workbench/services/userData/common/userData.ts @@ -12,52 +12,52 @@ export interface IUserData { content: string; } -export enum RemoteUserDataErrorCode { +export enum UserDataSyncStoreErrorCode { Rejected = 'Rejected', Unknown = 'Unknown' } -export function markAsUserDataError(error: Error, code: RemoteUserDataErrorCode): Error { - error.name = code ? `${code} (UserDataError)` : `UserDataError`; +export function markAsUserDataSyncStoreError(error: Error, code: UserDataSyncStoreErrorCode): Error { + error.name = code ? `${code} (UserDataSyncStoreError)` : `UserDataSyncStoreError`; return error; } -export function toUserDataErrorCode(error: Error | undefined | null): RemoteUserDataErrorCode { +export function toUserDataSyncStoreErrorCode(error: Error | undefined | null): UserDataSyncStoreErrorCode { // Guard against abuse if (!error) { - return RemoteUserDataErrorCode.Unknown; + return UserDataSyncStoreErrorCode.Unknown; } // FileSystemProviderError comes with the code - if (error instanceof RemoteUserDataError) { + if (error instanceof UserDataSyncStoreError) { return error.code; } // Any other error, check for name match by assuming that the error - // went through the markAsFileSystemProviderError() method - const match = /^(.+) \(UserDataError\)$/.exec(error.name); + // went through the markAsUserDataSyncStoreError() method + const match = /^(.+) \(UserDataSyncStoreError\)$/.exec(error.name); if (!match) { - return RemoteUserDataErrorCode.Unknown; + return UserDataSyncStoreErrorCode.Unknown; } switch (match[1]) { - case RemoteUserDataErrorCode.Rejected: return RemoteUserDataErrorCode.Rejected; + case UserDataSyncStoreErrorCode.Rejected: return UserDataSyncStoreErrorCode.Rejected; } - return RemoteUserDataErrorCode.Unknown; + return UserDataSyncStoreErrorCode.Unknown; } -export class RemoteUserDataError extends Error { +export class UserDataSyncStoreError extends Error { - constructor(message: string, public readonly code: RemoteUserDataErrorCode) { + constructor(message: string, public readonly code: UserDataSyncStoreErrorCode) { super(message); } } -export interface IRemoteUserDataProvider { +export interface IUserDataSyncStore { read(key: string): Promise; @@ -65,9 +65,9 @@ export interface IRemoteUserDataProvider { } -export const IRemoteUserDataService = createDecorator('IRemoteUserDataService'); +export const IUserDataSyncStoreService = createDecorator('IUserDataSyncStoreService'); -export interface IRemoteUserDataService { +export interface IUserDataSyncStoreService { _serviceBrand: undefined; @@ -75,9 +75,9 @@ export interface IRemoteUserDataService { isEnabled(): boolean; - registerRemoteUserDataProvider(name: string, remoteUserDataProvider: IRemoteUserDataProvider): void; + registerUserDataSyncStore(name: string, userDataSyncStore: IUserDataSyncStore): void; - deregisterRemoteUserDataProvider(): void; + deregisterUserDataSyncStore(): void; getName(): string | null; diff --git a/src/vs/workbench/services/userData/common/userDataSyncService.ts b/src/vs/workbench/services/userData/common/userDataSyncService.ts index c9222289ac2..5facccf5897 100644 --- a/src/vs/workbench/services/userData/common/userDataSyncService.ts +++ b/src/vs/workbench/services/userData/common/userDataSyncService.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { IUserDataSyncService, SyncStatus, IRemoteUserDataService, ISynchroniser, USER_DATA_PREVIEW_SCHEME } from 'vs/workbench/services/userData/common/userData'; +import { IUserDataSyncService, SyncStatus, IUserDataSyncStoreService, ISynchroniser, USER_DATA_PREVIEW_SCHEME } from 'vs/workbench/services/userData/common/userData'; import { Disposable } from 'vs/base/common/lifecycle'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -27,7 +27,7 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ constructor( @IFileService fileService: IFileService, - @IRemoteUserDataService private readonly remoteUserDataService: IRemoteUserDataService, + @IUserDataSyncStoreService private readonly userDataSyncStoreService: IUserDataSyncStoreService, @IInstantiationService private readonly instantiationService: IInstantiationService, ) { super(); @@ -36,12 +36,12 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ this.instantiationService.createInstance(SettingsSynchroniser) ]; this.updateStatus(); - this._register(Event.any(this.remoteUserDataService.onDidChangeEnablement, ...this.synchronisers.map(s => Event.map(s.onDidChangeStatus, () => undefined)))(() => this.updateStatus())); + this._register(Event.any(this.userDataSyncStoreService.onDidChangeEnablement, ...this.synchronisers.map(s => Event.map(s.onDidChangeStatus, () => undefined)))(() => this.updateStatus())); this.onDidChangeLocal = Event.any(...this.synchronisers.map(s => s.onDidChangeLocal)); } async sync(): Promise { - if (!this.remoteUserDataService.isEnabled()) { + if (!this.userDataSyncStoreService.isEnabled()) { throw new Error('Not enabled'); } for (const synchroniser of this.synchronisers) { @@ -53,7 +53,7 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ } async continueSync(): Promise { - if (!this.remoteUserDataService.isEnabled()) { + if (!this.userDataSyncStoreService.isEnabled()) { throw new Error('Not enabled'); } for (const synchroniser of this.synchronisers) { @@ -65,7 +65,7 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ } handleConflicts(): boolean { - if (!this.remoteUserDataService.isEnabled()) { + if (!this.userDataSyncStoreService.isEnabled()) { throw new Error('Not enabled'); } for (const synchroniser of this.synchronisers) { @@ -88,7 +88,7 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ } private computeStatus(): SyncStatus { - if (!this.remoteUserDataService.isEnabled()) { + if (!this.userDataSyncStoreService.isEnabled()) { return SyncStatus.Uninitialized; } if (this.synchronisers.some(s => s.status === SyncStatus.HasConflicts)) { diff --git a/src/vs/workbench/services/userData/common/userDataSyncStoreService.ts b/src/vs/workbench/services/userData/common/userDataSyncStoreService.ts new file mode 100644 index 00000000000..408ecb437e9 --- /dev/null +++ b/src/vs/workbench/services/userData/common/userDataSyncStoreService.ts @@ -0,0 +1,70 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Disposable, } from 'vs/base/common/lifecycle'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { Emitter, Event } from 'vs/base/common/event'; +import { IUserDataSyncStoreService, IUserDataSyncStore, IUserData, UserDataSyncStoreError, toUserDataSyncStoreErrorCode } from 'vs/workbench/services/userData/common/userData'; +import { ILogService } from 'vs/platform/log/common/log'; + +export class UserDataSyncStoreService extends Disposable implements IUserDataSyncStoreService { + + _serviceBrand: any; + + private userDataSyncStore: IUserDataSyncStore | null = null; + private name: string | null = null; + + private readonly _onDidChangeEnablement: Emitter = this._register(new Emitter()); + readonly onDidChangeEnablement: Event = this._onDidChangeEnablement.event; + + constructor( + @ILogService private logService: ILogService + ) { + super(); + } + + registerUserDataSyncStore(name: string, userDataSyncStore: IUserDataSyncStore): void { + if (this.userDataSyncStore) { + this.logService.warn(`A user data sync store '${this.name}' already registered. Hence ignoring the newly registered '${name}' store.`); + return; + } + this.userDataSyncStore = userDataSyncStore; + this.name = name; + this._onDidChangeEnablement.fire(true); + } + + deregisterUserDataSyncStore(): void { + this.userDataSyncStore = null; + this.name = null; + this._onDidChangeEnablement.fire(false); + } + + getName(): string | null { + return this.name; + } + + isEnabled(): boolean { + return !!this.userDataSyncStore; + } + + read(key: string): Promise { + if (!this.userDataSyncStore) { + throw new Error('No user sync store exists.'); + } + return this.userDataSyncStore.read(key) + .then(null, error => Promise.reject(new UserDataSyncStoreError(error.message, toUserDataSyncStoreErrorCode(error)))); + } + + write(key: string, content: string, ref: string | null): Promise { + if (!this.userDataSyncStore) { + throw new Error('No user sync store exists.'); + } + return this.userDataSyncStore.write(key, content, ref) + .then(null, error => Promise.reject(new UserDataSyncStoreError(error.message, toUserDataSyncStoreErrorCode(error)))); + } + +} + +registerSingleton(IUserDataSyncStoreService, UserDataSyncStoreService); diff --git a/src/vs/workbench/workbench.common.main.ts b/src/vs/workbench/workbench.common.main.ts index f00a7229599..b8d297a476c 100644 --- a/src/vs/workbench/workbench.common.main.ts +++ b/src/vs/workbench/workbench.common.main.ts @@ -75,7 +75,7 @@ import 'vs/workbench/services/label/common/labelService'; import 'vs/workbench/services/extensionManagement/common/extensionEnablementService'; import 'vs/workbench/services/notification/common/notificationService'; import 'vs/workbench/services/extensions/common/staticExtensions'; -import 'vs/workbench/services/userData/common/remoteUserDataService'; +import 'vs/workbench/services/userData/common/userDataSyncStoreService'; import 'vs/workbench/services/userData/common/userDataSyncService'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions';