mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-17 22:00:59 +01:00
wip: url service
This commit is contained in:
@@ -16,6 +16,7 @@ import { ILifecycleService, LifecycleService } from 'vs/code/electron-main/lifec
|
||||
import { VSCodeMenu } from 'vs/code/electron-main/menus';
|
||||
import { ISettingsService, SettingsManager } from 'vs/code/electron-main/settings';
|
||||
import { IUpdateService, UpdateManager } from 'vs/code/electron-main/update-manager';
|
||||
import { Server as ElectronIPCServer } from 'vs/base/parts/ipc/common/ipc.electron';
|
||||
import { Server, serve, connect } from 'vs/base/parts/ipc/node/ipc.net';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { AskpassChannel } from 'vs/workbench/parts/git/common/gitIpc';
|
||||
@@ -31,6 +32,8 @@ import { ILogService, MainLogService } from 'vs/code/electron-main/log';
|
||||
import { IStorageService, StorageService } from 'vs/code/electron-main/storage';
|
||||
import * as cp from 'child_process';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { URLChannel } from 'vs/platform/url/common/urlIpc';
|
||||
import { URLService } from 'vs/platform/url/electron-main/urlService';
|
||||
|
||||
function quit(accessor: ServicesAccessor, error?: Error);
|
||||
function quit(accessor: ServicesAccessor, message?: string);
|
||||
@@ -52,7 +55,7 @@ function quit(accessor: ServicesAccessor, arg?: any) {
|
||||
process.exit(exitCode); // in main, process.exit === app.exit
|
||||
}
|
||||
|
||||
function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEnvironment): void {
|
||||
function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: IProcessEnvironment): void {
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
const logService = accessor.get(ILogService);
|
||||
const envService = accessor.get(IEnvironmentService);
|
||||
@@ -93,14 +96,22 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn
|
||||
// noop
|
||||
}
|
||||
|
||||
// Register IPC services
|
||||
// Register Main IPC services
|
||||
const launchService = instantiationService.createInstance(LaunchService);
|
||||
const launchChannel = new LaunchChannel(launchService);
|
||||
ipcServer.registerChannel('launch', launchChannel);
|
||||
mainIpcServer.registerChannel('launch', launchChannel);
|
||||
|
||||
const askpassService = new GitAskpassService();
|
||||
const askpassChannel = new AskpassChannel(askpassService);
|
||||
ipcServer.registerChannel('askpass', askpassChannel);
|
||||
mainIpcServer.registerChannel('askpass', askpassChannel);
|
||||
|
||||
// Create Electron IPC Server
|
||||
const electronIpcServer = new ElectronIPCServer(ipc);
|
||||
|
||||
// Register Electron IPC services
|
||||
const urlService = instantiationService.createInstance(URLService);
|
||||
const urlChannel = new URLChannel(urlService);
|
||||
electronIpcServer.registerChannel('url', urlChannel);
|
||||
|
||||
// Used by sub processes to communicate back to the main instance
|
||||
process.env['VSCODE_PID'] = '' + process.pid;
|
||||
@@ -125,9 +136,9 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn
|
||||
global.programStart = envService.cliArgs.programStart;
|
||||
|
||||
function dispose() {
|
||||
if (ipcServer) {
|
||||
ipcServer.dispose();
|
||||
ipcServer = null;
|
||||
if (mainIpcServer) {
|
||||
mainIpcServer.dispose();
|
||||
mainIpcServer = null;
|
||||
}
|
||||
|
||||
sharedProcess.dispose();
|
||||
@@ -144,12 +155,6 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn
|
||||
dispose();
|
||||
});
|
||||
|
||||
app.setAsDefaultProtocolClient('vscode');
|
||||
|
||||
app.on('open-url', url => {
|
||||
console.log(url);
|
||||
});
|
||||
|
||||
// Dispose on vscode:exit
|
||||
ipc.on('vscode:exit', (event, code: number) => {
|
||||
logService.log('IPC#vscode:exit', code);
|
||||
@@ -356,6 +361,6 @@ getUserEnvironment()
|
||||
|
||||
return instantiationService.invokeFunction(a => a.get(IEnvironmentService).createPaths())
|
||||
.then(() => instantiationService.invokeFunction(setupIPC))
|
||||
.then(ipcServer => instantiationService.invokeFunction(main, ipcServer, userEnv));
|
||||
.then(mainIpcServer => instantiationService.invokeFunction(main, mainIpcServer, userEnv));
|
||||
})
|
||||
.done(null, err => instantiationService.invokeFunction(quit, err));
|
||||
Reference in New Issue
Block a user