提交 8a41bdb7 编写于 作者: J Johannes Rieken

reuse telemetry info when getting common http headers, will likely make use...

reuse telemetry info when getting common http headers, will likely make use not spawn a process which saves at least 10ms,  #17108
上级 d749475c
......@@ -14,9 +14,10 @@ import { TPromise, TValueCallback } from 'vs/base/common/winjs.base';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/code/electron-main/log';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { parseArgs } from 'vs/platform/environment/node/argv';
import product from 'vs/platform/node/product';
import { getCommonHTTPHeaders } from 'vs/platform/environment/node/http';
import { getCommonHttpHeaders } from 'vs/platform/environment/node/http';
import { IWindowSettings } from 'vs/platform/windows/common/windows';
export interface IWindowState {
......@@ -154,7 +155,8 @@ export class VSCodeWindow implements IVSCodeWindow {
@ILogService private logService: ILogService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IConfigurationService private configurationService: IConfigurationService,
@IStorageService private storageService: IStorageService
@IStorageService private storageService: IStorageService,
@ITelemetryService private telemetryService: ITelemetryService
) {
this.options = config;
this._lastFocusTime = -1;
......@@ -208,7 +210,7 @@ export class VSCodeWindow implements IVSCodeWindow {
// TODO@joao: hook this up to some initialization routine
// this causes a race between setting the headers and doing
// a request that needs them. chances are low
getCommonHTTPHeaders().done(headers => {
getCommonHttpHeaders(this.telemetryService).done(headers => {
if (!this._win) {
return;
}
......
......@@ -22,6 +22,7 @@ import { ipcMain as ipc, app, screen, BrowserWindow, dialog } from 'electron';
import { IPathWithLineAndColumn, parseLineAndColumnAware } from 'vs/code/electron-main/paths';
import { ILifecycleService, UnloadReason } from 'vs/code/electron-main/lifecycle';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ILogService } from 'vs/code/electron-main/log';
import { getPathLabel } from 'vs/base/common/labels';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
......@@ -148,7 +149,8 @@ export class WindowsManager implements IWindowsMainService {
@IEnvironmentService private environmentService: IEnvironmentService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IBackupMainService private backupService: IBackupMainService,
@IConfigurationService private configurationService: IConfigurationService
@IConfigurationService private configurationService: IConfigurationService,
@ITelemetryService private telemetryService: ITelemetryService
) { }
public ready(initialUserEnv: platform.IProcessEnvironment): void {
......@@ -734,7 +736,8 @@ export class WindowsManager implements IWindowsMainService {
this.logService,
this.environmentService,
this.configurationService,
this.storageService
this.storageService,
this.telemetryService
);
WindowsManager.WINDOWS.push(vscodeWindow);
......
......@@ -4,13 +4,13 @@
*--------------------------------------------------------------------------------------------*/
import { TPromise } from 'vs/base/common/winjs.base';
import { getMachineId } from 'vs/base/node/id';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import pkg from 'vs/platform/node/package';
export function getCommonHTTPHeaders(): TPromise<{ [key: string]: string; }> {
return getMachineId().then(machineId => ({
export function getCommonHttpHeaders(telemetryService: ITelemetryService): TPromise<{ [key: string]: string }> {
return telemetryService.getTelemetryInfo().then(info => ({
'X-Market-Client-Id': `VSCode ${pkg.version}`,
'User-Agent': `VSCode ${pkg.version}`,
'X-Market-User-Id': machineId
'X-Market-User-Id': info.machineId
}));
}
\ No newline at end of file
}
......@@ -22,7 +22,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import pkg from 'vs/platform/node/package';
import product from 'vs/platform/node/product';
import { isVersionValid } from 'vs/platform/extensions/node/extensionValidator';
import { getCommonHTTPHeaders } from 'vs/platform/environment/node/http';
import { getCommonHttpHeaders } from 'vs/platform/environment/node/http';
interface IRawGalleryExtensionFile {
assetType: string;
......@@ -269,7 +269,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
@memoize
private get commonHTTPHeaders(): TPromise<{ [key: string]: string; }> {
return getCommonHTTPHeaders();
return getCommonHttpHeaders(this.telemetryService);
}
constructor(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册