提交 783ed71a 编写于 作者: A Alex Dima

Tweaks

上级 e99b83dd
......@@ -43,6 +43,9 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { DownloadService } from 'vs/platform/download/node/downloadService';
import { IDownloadService } from 'vs/platform/download/common/download';
import { RemoteAuthorityResolverService } from 'vs/platform/remote/node/remoteAuthorityResolverService';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { RemoteAuthorityResolverChannel } from 'vs/platform/remote/node/remoteAuthorityResolverChannel';
export interface ISharedProcessConfiguration {
readonly machineId: string;
......@@ -126,10 +129,16 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I
services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService));
services.set(IRemoteAuthorityResolverService, new SyncDescriptor(RemoteAuthorityResolverService));
const instantiationService2 = instantiationService.createChild(services);
instantiationService2.invokeFunction(accessor => {
const remoteAuthorityResolverService = accessor.get(IRemoteAuthorityResolverService);
const remoteAuthorityResolverChannel = new RemoteAuthorityResolverChannel(remoteAuthorityResolverService);
server.registerChannel('remoteAuthorityResolver', remoteAuthorityResolverChannel);
const extensionManagementService = accessor.get(IExtensionManagementService);
const channel = new ExtensionManagementChannel(extensionManagementService);
server.registerChannel('extensions', channel);
......@@ -143,6 +152,7 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I
createSharedProcessContributions(instantiationService2);
disposables.push(extensionManagementService as ExtensionManagementService);
disposables.push(remoteAuthorityResolverService as RemoteAuthorityResolverService);
});
});
}
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing } from 'electron';
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol } from 'electron';
import * as platform from 'vs/base/common/platform';
import { WindowsManager } from 'vs/code/electron-main/windows';
import { IWindowsService, OpenContext, ActiveWindowManager } from 'vs/platform/windows/common/windows';
......@@ -57,6 +57,7 @@ import { LogLevelSetterChannel } from 'vs/platform/log/node/logIpc';
import * as errors from 'vs/base/common/errors';
import { ElectronURLListener } from 'vs/platform/url/electron-main/electronUrlListener';
import { serve as serveDriver } from 'vs/platform/driver/electron-main/driver';
import { connectRemoteAgentManagement } from 'vs/platform/remote/node/remoteAgentConnection';
import { IMenubarService } from 'vs/platform/menubar/common/menubar';
import { MenubarService } from 'vs/platform/menubar/electron-main/menubarService';
import { MenubarChannel } from 'vs/platform/menubar/node/menubarIpc';
......@@ -68,6 +69,10 @@ import { THEME_STORAGE_KEY, THEME_BG_STORAGE_KEY } from 'vs/code/electron-main/t
import { nativeSep, join } from 'vs/base/common/paths';
import { homedir } from 'os';
import { localize } from 'vs/nls';
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
import { IRemoteAuthorityResolverChannel, RemoteAuthorityResolverChannelClient } from 'vs/platform/remote/node/remoteAuthorityResolverChannel';
import { IRemoteAgentFileSystemChannel, REMOTE_FILE_SYSTEM_CHANNEL_NAME } from 'vs/platform/remote/node/remoteAgentFileSystemChannel';
import { ResolvedAuthority } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { SnapUpdateService } from 'vs/platform/update/electron-main/updateService.snap';
export class CodeApplication {
......@@ -165,6 +170,67 @@ export class CodeApplication {
});
});
const connectionPool: Map<string, ActiveConnection> = new Map<string, ActiveConnection>();
class ActiveConnection {
private _authority: string;
private _client: TPromise<Client>;
private _disposeRunner: RunOnceScheduler;
constructor(authority: string, connectionInfo: TPromise<ResolvedAuthority>) {
this._authority = authority;
this._client = connectionInfo.then(({ host, port }) => {
return connectRemoteAgentManagement(host, port, `main`);
});
this._disposeRunner = new RunOnceScheduler(() => this._dispose(), 5000);
}
private _dispose(): void {
this._disposeRunner.dispose();
connectionPool.delete(this._authority);
this._client.then((connection) => {
connection.dispose();
});
}
public getClient(): TPromise<Client> {
this._disposeRunner.schedule();
return this._client;
}
}
protocol.registerBufferProtocol(REMOTE_HOST_SCHEME, async (request, callback) => {
if (request.method !== 'GET') {
return callback(null);
}
const uri = URI.parse(request.url);
let activeConnection: ActiveConnection = null;
if (connectionPool.has(uri.authority)) {
activeConnection = connectionPool.get(uri.authority);
} else {
if (this.sharedProcessClient) {
const remoteAuthorityResolverChannel = getDelayedChannel<IRemoteAuthorityResolverChannel>(this.sharedProcessClient.then(c => c.getChannel('remoteAuthorityResolver')));
const remoteAuthorityResolverChannelClient = new RemoteAuthorityResolverChannelClient(remoteAuthorityResolverChannel);
activeConnection = new ActiveConnection(uri.authority, remoteAuthorityResolverChannelClient.resolveAuthority(uri.authority));
connectionPool.set(uri.authority, activeConnection);
}
}
try {
const rawClient = await activeConnection.getClient();
if (connectionPool.has(uri.authority)) { // not disposed in the meantime
const channel = rawClient.getChannel<IRemoteAgentFileSystemChannel>(REMOTE_FILE_SYSTEM_CHANNEL_NAME);
const fileContents = await channel.call('readFile', [uri.authority, uri]);
callback(Buffer.from(fileContents));
} else {
callback(null);
}
} catch (err) {
errors.onUnexpectedError(err);
callback(null);
}
});
let macOpenFileURIs: URI[] = [];
let runningTimeout: any = null;
app.on('open-file', (event: Event, path: string) => {
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { TPromise } from 'vs/base/common/winjs.base';
import { Client, Protocol } from 'vs/base/parts/ipc/node/ipc.net';
import { IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
export function connectRemoteAgentManagement(host: string, port: number, clientId: string): TPromise<Client> {
throw new Error(`Not implemented`);
}
export interface IExtensionHostConnectionResult {
protocol: Protocol;
debugPort?: number;
}
export function connectRemoteAgentExtensionHost(host: string, port: number, debugArguments: IExtensionHostDebugParams): TPromise<IExtensionHostConnectionResult> {
throw new Error(`Not implemented`);
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IRemoteAuthorityResolverService, ResolvedAuthority, IResolvingProgressEvent } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';
import { Disposable } from 'vs/base/common/lifecycle';
import { Emitter, Event } from 'vs/base/common/event';
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
export class RemoteAuthorityResolverService extends Disposable implements IRemoteAuthorityResolverService {
_serviceBrand: any;
private _onResolvingProgress: Emitter<IResolvingProgressEvent> = this._register(new Emitter<IResolvingProgressEvent>());
readonly onResolvingProgress: Event<IResolvingProgressEvent> = this._onResolvingProgress.event;
constructor(
@IEnvironmentService environmentService: IEnvironmentService,
@IConfigurationService configurationService: IConfigurationService,
@ILogService logService: ILogService,
@IExtensionManagementService extensionManagementService: IExtensionManagementService
) {
super();
}
async resolveAuthority(authority: string): Promise<ResolvedAuthority> {
throw new Error(`Not implemented`);
}
async getLabel(authority: string): Promise<string | null> {
throw new Error(`Not implemented`);
}
}
......@@ -10,6 +10,7 @@ import { IChannel, getDelayedChannel } from 'vs/base/parts/ipc/node/ipc';
import { Client } from 'vs/base/parts/ipc/node/ipc.net';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { connectRemoteAgentManagement } from 'vs/platform/remote/node/remoteAgentConnection';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { RemoteExtensionEnvironmentChannelClient } from 'vs/workbench/services/remote/node/remoteAgentEnvironmentChannel';
import { IRemoteAgentConnection, IRemoteAgentEnvironment, IRemoteAgentService } from 'vs/workbench/services/remote/node/remoteAgentService';
......@@ -77,7 +78,7 @@ class RemoteAgentConnection extends Disposable implements IRemoteAgentConnection
private _getOrCreateConnection(): TPromise<Client> {
if (!this._connection) {
this._connection = this._remoteAuthorityResolverService.resolveAuthority(this.remoteAuthority).then((resolvedAuthority) => {
throw new Error(`Not implemented`);
return connectRemoteAgentManagement(resolvedAuthority.host, resolvedAuthority.port, `renderer`);
});
}
return this._connection;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册