move auth token service from user data sync

This commit is contained in:
Sandeep Somavarapu
2020-02-20 15:04:33 +01:00
parent efc5b912ac
commit 5e5e709460
14 changed files with 84 additions and 69 deletions

View File

@@ -1,45 +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 { IUserDataAuthTokenService } from 'vs/platform/userDataSync/common/userDataSync';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { Disposable } from 'vs/base/common/lifecycle';
import { Emitter, Event } from 'vs/base/common/event';
export class UserDataAuthTokenService extends Disposable implements IUserDataAuthTokenService {
_serviceBrand: undefined;
private readonly channel: IChannel;
private _onDidChangeToken: Emitter<string | undefined> = this._register(new Emitter<string | undefined>());
readonly onDidChangeToken: Event<string | undefined> = this._onDidChangeToken.event;
private _onTokenFailed: Emitter<void> = this._register(new Emitter<void>());
readonly onTokenFailed: Event<void> = this._onTokenFailed.event;
constructor(
@ISharedProcessService sharedProcessService: ISharedProcessService,
) {
super();
this.channel = sharedProcessService.getChannel('authToken');
this._register(this.channel.listen<void[]>('onTokenFailed')(_ => this.sendTokenFailed()));
}
getToken(): Promise<string | undefined> {
return this.channel.call('getToken');
}
setToken(token: string | undefined): Promise<undefined> {
return this.channel.call('setToken', token);
}
sendTokenFailed(): void {
this._onTokenFailed.fire();
}
}
registerSingleton(IUserDataAuthTokenService, UserDataAuthTokenService);