From 44cf9c9144eb8e16bbde99ebc53d7af62b3bf653 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Fri, 13 Dec 2019 09:06:00 +0100 Subject: [PATCH] Make worker ExtHostTunnelService and remove dependency in ExtHostExtensionService --- .../platform/remote/common/remoteAuthorityResolver.ts | 5 +++++ .../workbench/api/browser/mainThreadTunnelService.ts | 4 ---- src/vs/workbench/api/common/extHost.protocol.ts | 1 - .../workbench/api/common/extHostExtensionService.ts | 11 +++-------- src/vs/workbench/api/common/extHostTunnelService.ts | 11 ++++++++++- src/vs/workbench/api/node/extHostTunnelService.ts | 6 ------ .../extensions/electron-browser/extensionService.ts | 5 ++++- .../services/extensions/worker/extHost.services.ts | 4 ++-- 8 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/vs/platform/remote/common/remoteAuthorityResolver.ts b/src/vs/platform/remote/common/remoteAuthorityResolver.ts index 98a7f550d13..8d0e2617a34 100644 --- a/src/vs/platform/remote/common/remoteAuthorityResolver.ts +++ b/src/vs/platform/remote/common/remoteAuthorityResolver.ts @@ -17,9 +17,14 @@ export interface ResolvedOptions { readonly extensionHostEnv?: { [key: string]: string | null }; } +export interface TunnelInformation { + detectedTunnels?: { remote: { port: number, host: string }, localAddress: string }[]; +} + export interface ResolverResult { authority: ResolvedAuthority; options?: ResolvedOptions; + tunnelInformation?: TunnelInformation; } export enum RemoteAuthorityResolverErrorCode { diff --git a/src/vs/workbench/api/browser/mainThreadTunnelService.ts b/src/vs/workbench/api/browser/mainThreadTunnelService.ts index 1e320448107..fd4118f5324 100644 --- a/src/vs/workbench/api/browser/mainThreadTunnelService.ts +++ b/src/vs/workbench/api/browser/mainThreadTunnelService.ts @@ -31,10 +31,6 @@ export class MainThreadTunnelService implements MainThreadTunnelServiceShape { return this.remoteExplorerService.close(remotePort); } - $addDetected(tunnels: { remote: { port: number, host: string }, localAddress: string }[]): Promise { - return Promise.resolve(this.remoteExplorerService.addDetected(tunnels)); - } - async $registerCandidateFinder(): Promise { this.remoteExplorerService.registerCandidateFinder(() => this._proxy.$findCandidatePorts()); } diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index c495895e331..b79e49ac355 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -776,7 +776,6 @@ export interface MainThreadWindowShape extends IDisposable { export interface MainThreadTunnelServiceShape extends IDisposable { $openTunnel(tunnelOptions: TunnelOptions): Promise; $closeTunnel(remotePort: number): Promise; - $addDetected(tunnels: { remote: { port: number, host: string }, localAddress: string }[]): Promise; $registerCandidateFinder(): Promise; } diff --git a/src/vs/workbench/api/common/extHostExtensionService.ts b/src/vs/workbench/api/common/extHostExtensionService.ts index a0c3aa4e086..2afac9ab652 100644 --- a/src/vs/workbench/api/common/extHostExtensionService.ts +++ b/src/vs/workbench/api/common/extHostExtensionService.ts @@ -32,7 +32,6 @@ import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitData import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePaths'; import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; -import { IExtHostTunnelService } from 'vs/workbench/api/common/extHostTunnelService'; interface ITestRunner { /** Old test runner API, as exported from `vscode/lib/testrunner` */ @@ -77,7 +76,6 @@ export abstract class AbstractExtHostExtensionService implements ExtHostExtensio protected readonly _extHostWorkspace: ExtHostWorkspace; protected readonly _extHostConfiguration: ExtHostConfiguration; protected readonly _logService: ILogService; - protected readonly _extHostTunnelService: IExtHostTunnelService; protected readonly _mainThreadWorkspaceProxy: MainThreadWorkspaceShape; protected readonly _mainThreadTelemetryProxy: MainThreadTelemetryShape; @@ -106,8 +104,7 @@ export abstract class AbstractExtHostExtensionService implements ExtHostExtensio @IExtHostConfiguration extHostConfiguration: IExtHostConfiguration, @ILogService logService: ILogService, @IExtHostInitDataService initData: IExtHostInitDataService, - @IExtensionStoragePaths storagePath: IExtensionStoragePaths, - @IExtHostTunnelService extHostTunnelService: IExtHostTunnelService + @IExtensionStoragePaths storagePath: IExtensionStoragePaths ) { this._hostUtils = hostUtils; this._extHostContext = extHostContext; @@ -116,7 +113,6 @@ export abstract class AbstractExtHostExtensionService implements ExtHostExtensio this._extHostWorkspace = extHostWorkspace; this._extHostConfiguration = extHostConfiguration; this._logService = logService; - this._extHostTunnelService = extHostTunnelService; this._disposables = new DisposableStore(); this._mainThreadWorkspaceProxy = this._extHostContext.getProxy(MainContext.MainThreadWorkspace); @@ -656,13 +652,12 @@ export abstract class AbstractExtHostExtensionService implements ExtHostExtensio extensionHostEnv: result.extensionHostEnv }; - await this._extHostTunnelService.addDetected(result.detectedTunnels); - return { type: 'ok', value: { authority, - options + options, + tunnelInformation: { detectedTunnels: result.detectedTunnels } } }; } catch (err) { diff --git a/src/vs/workbench/api/common/extHostTunnelService.ts b/src/vs/workbench/api/common/extHostTunnelService.ts index 55492233e43..bc5d17b76e0 100644 --- a/src/vs/workbench/api/common/extHostTunnelService.ts +++ b/src/vs/workbench/api/common/extHostTunnelService.ts @@ -22,7 +22,16 @@ export interface TunnelDto { export interface IExtHostTunnelService extends ExtHostTunnelServiceShape { readonly _serviceBrand: undefined; makeTunnel(forward: TunnelOptions): Promise; - addDetected(tunnels: { remote: { port: number, host: string }, localAddress: string }[] | undefined): Promise; } export const IExtHostTunnelService = createDecorator('IExtHostTunnelService'); + +export class ExtHostTunnelService implements IExtHostTunnelService { + _serviceBrand: undefined; + async makeTunnel(forward: TunnelOptions): Promise { + return undefined; + } + async $findCandidatePorts(): Promise<{ port: number; detail: string; }[]> { + return []; + } +} diff --git a/src/vs/workbench/api/node/extHostTunnelService.ts b/src/vs/workbench/api/node/extHostTunnelService.ts index 4cd66bcef67..73ac33d5823 100644 --- a/src/vs/workbench/api/node/extHostTunnelService.ts +++ b/src/vs/workbench/api/node/extHostTunnelService.ts @@ -45,12 +45,6 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe return undefined; } - async addDetected(tunnels: { remote: { port: number, host: string }, localAddress: string }[] | undefined): Promise { - if (tunnels) { - return this._proxy.$addDetected(tunnels); - } - } - registerCandidateFinder(): Promise { return this._proxy.$registerCandidateFinder(); } diff --git a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts index f4665c503b9..0ca576029c4 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts @@ -38,6 +38,7 @@ import { flatten } from 'vs/base/common/arrays'; import { IStaticExtensionsService } from 'vs/workbench/services/extensions/common/staticExtensions'; import { IElectronService } from 'vs/platform/electron/node/electron'; import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService'; +import { IRemoteExplorerService } from 'vs/workbench/services/remote/common/remoteExplorerService'; class DeltaExtensionsQueueItem { constructor( @@ -70,7 +71,8 @@ export class ExtensionService extends AbstractExtensionService implements IExten @IStaticExtensionsService private readonly _staticExtensions: IStaticExtensionsService, @IElectronService private readonly _electronService: IElectronService, @IHostService private readonly _hostService: IHostService, - @IElectronEnvironmentService private readonly _electronEnvironmentService: IElectronEnvironmentService + @IElectronEnvironmentService private readonly _electronEnvironmentService: IElectronEnvironmentService, + @IRemoteExplorerService private readonly _remoteExplorerService: IRemoteExplorerService ) { super( instantiationService, @@ -471,6 +473,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten // set the resolved authority this._remoteAuthorityResolverService.setResolvedAuthority(resolvedAuthority.authority, resolvedAuthority.options); + this._remoteExplorerService.addDetected(resolvedAuthority.tunnelInformation?.detectedTunnels); // monitor for breakage const connection = this._remoteAgentService.getConnection(); diff --git a/src/vs/workbench/services/extensions/worker/extHost.services.ts b/src/vs/workbench/services/extensions/worker/extHost.services.ts index e9ba7eb5525..168fd087270 100644 --- a/src/vs/workbench/services/extensions/worker/extHost.services.ts +++ b/src/vs/workbench/services/extensions/worker/extHost.services.ts @@ -21,7 +21,7 @@ import { ExtHostExtensionService } from 'vs/workbench/api/worker/extHostExtensio import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation'; import { ILogService } from 'vs/platform/log/common/log'; import { ExtHostLogService } from 'vs/workbench/api/worker/extHostLogService'; -import { IExtHostTunnelService } from 'vs/workbench/api/common/extHostTunnelService'; +import { IExtHostTunnelService, ExtHostTunnelService } from 'vs/workbench/api/common/extHostTunnelService'; // register singleton services registerSingleton(ILogService, ExtHostLogService); @@ -34,6 +34,7 @@ registerSingleton(IExtHostDocumentsAndEditors, ExtHostDocumentsAndEditors); registerSingleton(IExtHostStorage, ExtHostStorage); registerSingleton(IExtHostExtensionService, ExtHostExtensionService); registerSingleton(IExtHostSearch, ExtHostSearch); +registerSingleton(IExtHostTunnelService, ExtHostTunnelService); // register services that only throw errors function NotImplementedProxy(name: ServiceIdentifier): { new(): T } { @@ -54,4 +55,3 @@ registerSingleton(IExtHostTerminalService, WorkerExtHostTerminalService); registerSingleton(IExtHostTask, WorkerExtHostTask); registerSingleton(IExtHostDebugService, WorkerExtHostDebugService); registerSingleton(IExtensionStoragePaths, class extends NotImplementedProxy(IExtensionStoragePaths) { whenReady = Promise.resolve(); }); -registerSingleton(IExtHostTunnelService, class extends NotImplementedProxy(IExtHostTunnelService) { });