parent
1f199ff778
commit
d7d4dac6c3
7 changed files with 48 additions and 77 deletions
|
@ -2,7 +2,7 @@
|
|||
"name": "code-oss-dev",
|
||||
"version": "1.8.0",
|
||||
"electronVersion": "1.3.8",
|
||||
"distro": "53e30f0e2907d30c579b0ef07de97c586e6750a4",
|
||||
"distro": "cc6a2710b81e898b8cde2b51ba29e178980009e8",
|
||||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
},
|
||||
|
|
|
@ -18,7 +18,7 @@ import { EventEmitter } from 'events';
|
|||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IStorageService } from 'vs/code/electron-main/storage';
|
||||
import { IPath, VSCodeWindow, ReadyState, IWindowConfiguration, IWindowState as ISingleWindowState, defaultWindowState, IWindowSettings } from 'vs/code/electron-main/window';
|
||||
import { ipcMain as ipc, app, screen, crashReporter, BrowserWindow, dialog } from 'electron';
|
||||
import { ipcMain as ipc, app, screen, BrowserWindow, dialog } from 'electron';
|
||||
import { IPathWithLineAndColumn, parseLineAndColumnAware } from 'vs/code/electron-main/paths';
|
||||
import { ILifecycleService } from 'vs/code/electron-main/lifecycle';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
@ -214,12 +214,6 @@ export class WindowsManager implements IWindowsMainService, IWindowEventService
|
|||
}, 100);
|
||||
});
|
||||
|
||||
ipc.on('vscode:startCrashReporter', (event: any, config: any) => {
|
||||
this.logService.log('IPC#vscode:startCrashReporter');
|
||||
|
||||
crashReporter.start(config);
|
||||
});
|
||||
|
||||
ipc.on('vscode:workbenchLoaded', (event, windowId: number) => {
|
||||
this.logService.log('IPC#vscode-workbenchLoaded');
|
||||
|
||||
|
|
|
@ -40,9 +40,12 @@ export interface IWindowsService {
|
|||
closeExtensionHostWindow(extensionDevelopmentPath: string): TPromise<void>;
|
||||
showItemInFolder(path: string): TPromise<void>;
|
||||
|
||||
// TODO: this needs to be handled from browser process to prevent
|
||||
// This needs to be handled from browser process to prevent
|
||||
// foreground ordering issues on Windows
|
||||
openExternal(url: string): TPromise<void>;
|
||||
|
||||
// TODO: this is a bit backwards
|
||||
startCrashReporter(config: Electron.CrashReporterStartOptions): TPromise<void>;
|
||||
}
|
||||
|
||||
export const IWindowService = createDecorator<IWindowService>('windowService');
|
||||
|
|
|
@ -30,6 +30,7 @@ export interface IWindowsChannel extends IChannel {
|
|||
call(command: 'closeExtensionHostWindow', arg: string): TPromise<void>;
|
||||
call(command: 'showItemInFolder', arg: string): TPromise<void>;
|
||||
call(command: 'openExternal', arg: string): TPromise<void>;
|
||||
call(command: 'startCrashReporter', arg: Electron.CrashReporterStartOptions): TPromise<void>;
|
||||
call(command: string, arg?: any): TPromise<any>;
|
||||
}
|
||||
|
||||
|
@ -60,6 +61,7 @@ export class WindowsChannel implements IWindowsChannel {
|
|||
case 'closeExtensionHostWindow': return this.service.closeExtensionHostWindow(arg);
|
||||
case 'showItemInFolder': return this.service.showItemInFolder(arg);
|
||||
case 'openExternal': return this.service.openExternal(arg);
|
||||
case 'startCrashReporter': return this.service.startCrashReporter(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,4 +155,8 @@ export class WindowsChannelClient implements IWindowsService {
|
|||
openExternal(url: string): TPromise<void> {
|
||||
return this.channel.call('openExternal', url);
|
||||
}
|
||||
|
||||
startCrashReporter(config: Electron.CrashReporterStartOptions): TPromise<void> {
|
||||
return this.channel.call('startCrashReporter', config);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { shell } from 'electron';
|
||||
import { shell, crashReporter } from 'electron';
|
||||
|
||||
// TODO@Joao: remove this dependency, move all implementation to this class
|
||||
import { IWindowsMainService } from 'vs/code/electron-main/windows';
|
||||
|
@ -187,4 +187,9 @@ export class WindowsService implements IWindowsService {
|
|||
shell.openExternal(url);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
startCrashReporter(config: Electron.CrashReporterStartOptions): TPromise<void> {
|
||||
crashReporter.start(config);
|
||||
return TPromise.as(null);
|
||||
}
|
||||
}
|
|
@ -5,17 +5,23 @@
|
|||
'use strict';
|
||||
|
||||
import nls = require('vs/nls');
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { assign, clone } from 'vs/base/common/objects';
|
||||
import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ITelemetryService, NullTelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { Registry } from 'vs/platform/platform';
|
||||
|
||||
import { ipcRenderer as ipc, crashReporter } from 'electron';
|
||||
import { crashReporter } from 'electron';
|
||||
import product from 'vs/platform/product';
|
||||
import pkg from 'vs/platform/package';
|
||||
|
||||
const TELEMETRY_SECTION_ID = 'telemetry';
|
||||
|
||||
interface ICrashReporterConfig {
|
||||
enableCrashReporter: boolean;
|
||||
}
|
||||
|
||||
const configurationRegistry = <IConfigurationRegistry>Registry.as(Extensions.Configuration);
|
||||
configurationRegistry.registerConfiguration({
|
||||
'id': TELEMETRY_SECTION_ID,
|
||||
|
@ -31,71 +37,29 @@ configurationRegistry.registerConfiguration({
|
|||
});
|
||||
|
||||
export class CrashReporter {
|
||||
private isStarted: boolean;
|
||||
private config: any;
|
||||
private version: string;
|
||||
private commit: string;
|
||||
private sessionId: string;
|
||||
|
||||
constructor(version: string, commit: string,
|
||||
@ITelemetryService private telemetryService: ITelemetryService = NullTelemetryService,
|
||||
@IConfigurationService private configurationService: IConfigurationService
|
||||
constructor(
|
||||
configuration: Electron.CrashReporterStartOptions,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IWindowsService windowsService: IWindowsService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
this.configurationService = configurationService;
|
||||
this.telemetryService = telemetryService;
|
||||
this.version = version;
|
||||
this.commit = commit;
|
||||
const config = configurationService.getConfiguration<ICrashReporterConfig>(TELEMETRY_SECTION_ID);
|
||||
|
||||
this.isStarted = false;
|
||||
this.config = null;
|
||||
}
|
||||
|
||||
public start(rawConfiguration: Electron.CrashReporterStartOptions): void {
|
||||
if (!this.isStarted) {
|
||||
|
||||
const sessionId = !this.sessionId
|
||||
? this.telemetryService.getTelemetryInfo().then(info => this.sessionId = info.sessionId)
|
||||
: TPromise.as(undefined);
|
||||
|
||||
sessionId.then(() => {
|
||||
if (!this.config) {
|
||||
this.config = this.configurationService.getConfiguration(TELEMETRY_SECTION_ID);
|
||||
if (this.config && this.config.enableCrashReporter) {
|
||||
this.doStart(rawConfiguration);
|
||||
}
|
||||
} else {
|
||||
if (this.config.enableCrashReporter) {
|
||||
this.doStart(rawConfiguration);
|
||||
}
|
||||
}
|
||||
}, onUnexpectedError);
|
||||
if (!config.enableCrashReporter) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private doStart(rawConfiguration: Electron.CrashReporterStartOptions): void {
|
||||
const config = this.toConfiguration(rawConfiguration);
|
||||
telemetryService.getTelemetryInfo()
|
||||
.then(info => ({ vscode_sessionId: info.sessionId, vscode_version: pkg.version, vscode_commit: product.commit }))
|
||||
.then(extra => assign(configuration, { extra }))
|
||||
.then(configuration => {
|
||||
// start crash reporter right here
|
||||
crashReporter.start(clone(configuration));
|
||||
|
||||
crashReporter.start(config);
|
||||
|
||||
//notify the main process to start the crash reporter
|
||||
ipc.send('vscode:startCrashReporter', config);
|
||||
}
|
||||
|
||||
private toConfiguration(rawConfiguration: Electron.CrashReporterStartOptions): Electron.CrashReporterStartOptions {
|
||||
return JSON.parse(JSON.stringify(rawConfiguration, (key, value) => {
|
||||
if (value === '$(sessionId)') {
|
||||
return this.sessionId;
|
||||
}
|
||||
|
||||
if (value === '$(version)') {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
if (value === '$(commit)') {
|
||||
return this.commit;
|
||||
}
|
||||
|
||||
return value;
|
||||
}));
|
||||
// TODO: start crash reporter in the main process
|
||||
return windowsService.startCrashReporter(configuration);
|
||||
})
|
||||
.done(null, onUnexpectedError);
|
||||
}
|
||||
}
|
|
@ -156,8 +156,7 @@ export class WorkbenchShell {
|
|||
|
||||
//crash reporting
|
||||
if (!!product.crashReporter) {
|
||||
const crashReporter = instantiationService.createInstance(CrashReporter, pkg.version, product.commit);
|
||||
crashReporter.start(product.crashReporter);
|
||||
instantiationService.createInstance(CrashReporter, product.crashReporter);
|
||||
}
|
||||
|
||||
// Workbench
|
||||
|
@ -212,7 +211,7 @@ export class WorkbenchShell {
|
|||
}
|
||||
}
|
||||
|
||||
private initServiceCollection(container: HTMLElement): [InstantiationService, ServiceCollection] {
|
||||
private initServiceCollection(container: HTMLElement): [IInstantiationService, ServiceCollection] {
|
||||
const disposables = new Disposables();
|
||||
|
||||
const mainProcessClient = new ElectronIPCClient(String(`window${remote.getCurrentWindow().id}`));
|
||||
|
|
Loading…
Reference in a new issue