Enable syncing extensions storage

- Implement logic to sync extension storage
- Register keys to sync provided by extension
This commit is contained in:
Sandeep Somavarapu
2020-10-24 21:15:33 +02:00
parent 9b507d2bad
commit 20601293fe
8 changed files with 156 additions and 17 deletions

View File

@@ -7,6 +7,7 @@ import { MainContext, MainThreadStorageShape, ExtHostStorageShape } from './extH
import { Emitter } from 'vs/base/common/event';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionIdWithVersion } from 'vs/platform/userDataSync/common/storageKeys';
export interface IStorageChangeEvent {
shared: boolean;
@@ -27,6 +28,10 @@ export class ExtHostStorage implements ExtHostStorageShape {
this._proxy = mainContext.getProxy(MainContext.MainThreadStorage);
}
registerExtensionStorageKeysToSync(extension: IExtensionIdWithVersion, keys: string[]): void {
this._proxy.$registerExtensionStorageKeysToSync(extension, keys);
}
getValue<T>(shared: boolean, key: string, defaultValue?: T): Promise<T | undefined> {
return this._proxy.$getValue<T>(shared, key).then(value => value || defaultValue);
}