Move IRemoteAgentConnection to AbstractRemoteAgentService

This commit is contained in:
Alex Dima 2020-07-30 11:37:49 +02:00
parent 3271cfd9f4
commit a584933a77
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
3 changed files with 23 additions and 32 deletions

View file

@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IRemoteAgentConnection, IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { AbstractRemoteAgentService, RemoteAgentConnection } from 'vs/workbench/services/remote/common/abstractRemoteAgentService';
import { AbstractRemoteAgentService } from 'vs/workbench/services/remote/common/abstractRemoteAgentService';
import { IProductService } from 'vs/platform/product/common/productService';
import { IWebSocketFactory, BrowserSocketFactory } from 'vs/platform/remote/browser/browserSocketFactory';
import { ISignService } from 'vs/platform/sign/common/sign';
@ -14,8 +14,6 @@ import { ILogService } from 'vs/platform/log/common/log';
export class RemoteAgentService extends AbstractRemoteAgentService implements IRemoteAgentService {
private readonly _connection: IRemoteAgentConnection | null = null;
constructor(
webSocketFactory: IWebSocketFactory | null | undefined,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@ -24,15 +22,6 @@ export class RemoteAgentService extends AbstractRemoteAgentService implements IR
@ISignService signService: ISignService,
@ILogService logService: ILogService
) {
super(new BrowserSocketFactory(webSocketFactory), environmentService, remoteAuthorityResolverService);
const remoteAuthority = environmentService.configuration.remoteAuthority;
if (remoteAuthority) {
this._connection = this._register(new RemoteAgentConnection(remoteAuthority, productService.commit, this.socketFactory, remoteAuthorityResolverService, signService, logService));
}
}
getConnection(): IRemoteAgentConnection | null {
return this._connection;
super(new BrowserSocketFactory(webSocketFactory), environmentService, productService, remoteAuthorityResolverService, signService, logService);
}
}

View file

@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
import { Disposable } from 'vs/base/common/lifecycle';
import { IChannel, IServerChannel, getDelayedChannel, IPCLogger } from 'vs/base/parts/ipc/common/ipc';
import { Client } from 'vs/base/parts/ipc/common/ipc.net';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { connectRemoteAgentManagement, IConnectionOptions, ISocketFactory, PersistenConnectionEvent } from 'vs/platform/remote/common/remoteAgentConnection';
import { IRemoteAgentConnection, IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IRemoteAuthorityResolverService, RemoteAuthorityResolverError } from 'vs/platform/remote/common/remoteAuthorityResolver';
@ -23,25 +23,37 @@ import { ISignService } from 'vs/platform/sign/common/sign';
import { ILogService } from 'vs/platform/log/common/log';
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { IProductService } from 'vs/platform/product/common/productService';
export abstract class AbstractRemoteAgentService extends Disposable implements IRemoteAgentService {
declare readonly _serviceBrand: undefined;
public readonly socketFactory: ISocketFactory;
private readonly _connection: IRemoteAgentConnection | null;
private _environment: Promise<IRemoteAgentEnvironment | null> | null;
constructor(
socketFactory: ISocketFactory,
@IEnvironmentService protected readonly _environmentService: IEnvironmentService,
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService
@IWorkbenchEnvironmentService protected readonly _environmentService: IWorkbenchEnvironmentService,
@IProductService productService: IProductService,
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@ISignService signService: ISignService,
@ILogService logService: ILogService
) {
super();
this.socketFactory = socketFactory;
if (this._environmentService.configuration.remoteAuthority) {
this._connection = this._register(new RemoteAgentConnection(this._environmentService.configuration.remoteAuthority, productService.commit, this.socketFactory, this._remoteAuthorityResolverService, signService, logService));
} else {
this._connection = null;
}
this._environment = null;
}
abstract getConnection(): IRemoteAgentConnection | null;
getConnection(): IRemoteAgentConnection | null {
return this._connection;
}
getEnvironment(): Promise<IRemoteAgentEnvironment | null> {
return this.getRawEnvironment().then(undefined, () => null);

View file

@ -3,33 +3,23 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IRemoteAgentConnection, IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IProductService } from 'vs/platform/product/common/productService';
import { nodeSocketFactory } from 'vs/platform/remote/node/nodeSocketFactory';
import { AbstractRemoteAgentService, RemoteAgentConnection } from 'vs/workbench/services/remote/common/abstractRemoteAgentService';
import { AbstractRemoteAgentService } from 'vs/workbench/services/remote/common/abstractRemoteAgentService';
import { ISignService } from 'vs/platform/sign/common/sign';
import { ILogService } from 'vs/platform/log/common/log';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
export class RemoteAgentService extends AbstractRemoteAgentService implements IRemoteAgentService {
private readonly _connection: IRemoteAgentConnection | null = null;
constructor(
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IProductService productService: IProductService,
@IRemoteAuthorityResolverService remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@ISignService signService: ISignService,
@ILogService logService: ILogService,
@IProductService productService: IProductService
) {
super(nodeSocketFactory, environmentService, remoteAuthorityResolverService);
if (environmentService.configuration.remoteAuthority) {
this._connection = this._register(new RemoteAgentConnection(environmentService.configuration.remoteAuthority, productService.commit, nodeSocketFactory, remoteAuthorityResolverService, signService, logService));
}
}
getConnection(): IRemoteAgentConnection | null {
return this._connection;
super(nodeSocketFactory, environmentService, productService, remoteAuthorityResolverService, signService, logService);
}
}