diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts index e884724db37..18cdd76fda9 100644 --- a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts +++ b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts @@ -43,7 +43,6 @@ import { LogsDataCleaner } from 'vs/code/electron-browser/sharedProcess/contrib/ import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService'; import { SpdLogService } from 'vs/platform/log/node/spdlogService'; import { DiagnosticsService, IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService'; -import { DiagnosticsChannel } from 'vs/platform/diagnostics/node/diagnosticsIpc'; import { FileService } from 'vs/platform/files/common/fileService'; import { IFileService } from 'vs/platform/files/common/files'; import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider'; @@ -223,7 +222,7 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat server.registerChannel('localizations', localizationsChannel); const diagnosticsService = accessor.get(IDiagnosticsService); - const diagnosticsChannel = new DiagnosticsChannel(diagnosticsService); + const diagnosticsChannel = createChannelReceiver(diagnosticsService); server.registerChannel('diagnostics', diagnosticsChannel); const extensionTipsService = accessor.get(IExtensionTipsService); diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 8fd9ded27b6..10fceadfc30 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -31,7 +31,7 @@ import { NullTelemetryService, combinedAppender, LogAppender } from 'vs/platform import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService'; import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties'; -import { getDelayedChannel, StaticRouter, createChannelReceiver } from 'vs/base/parts/ipc/common/ipc'; +import { getDelayedChannel, StaticRouter, createChannelReceiver, createChannelSender } from 'vs/base/parts/ipc/common/ipc'; import product from 'vs/platform/product/common/product'; import { ProxyAuthHandler } from 'vs/code/electron-main/auth'; import { Disposable } from 'vs/base/common/lifecycle'; @@ -65,7 +65,6 @@ import { WorkspacesHistoryMainService, IWorkspacesHistoryMainService } from 'vs/ import { NativeURLService } from 'vs/platform/url/common/urlService'; import { WorkspacesMainService, IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService'; import { statSync } from 'fs'; -import { DiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsIpc'; import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService'; import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc'; import { ElectronExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/electron-main/extensionHostDebugIpc'; @@ -446,9 +445,7 @@ export class CodeApplication extends Disposable { services.set(IDialogMainService, new SyncDescriptor(DialogMainService)); services.set(ISharedProcessMainService, new SyncDescriptor(SharedProcessMainService, [sharedProcess])); services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService)); - - const diagnosticsChannel = getDelayedChannel(sharedProcessReady.then(client => client.getChannel('diagnostics'))); - services.set(IDiagnosticsService, new SyncDescriptor(DiagnosticsService, [diagnosticsChannel])); + services.set(IDiagnosticsService, createChannelSender(getDelayedChannel(sharedProcessReady.then(client => client.getChannel('diagnostics'))))); services.set(IIssueMainService, new SyncDescriptor(IssueMainService, [machineId, this.userEnv])); services.set(IElectronMainService, new SyncDescriptor(ElectronMainService)); diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index d0ae1450567..a34a585ddcd 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -40,7 +40,7 @@ import { Client } from 'vs/base/parts/ipc/common/ipc.net'; import { once } from 'vs/base/common/functional'; import { ISignService } from 'vs/platform/sign/common/sign'; import { SignService } from 'vs/platform/sign/node/signService'; -import { DiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsIpc'; +import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService'; import { FileService } from 'vs/platform/files/common/fileService'; import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider'; import { Schemas } from 'vs/base/common/network'; @@ -298,7 +298,7 @@ class CodeMain { // Create a diagnostic service connected to the existing shared process const sharedProcessClient = await connect(environmentService.sharedIPCHandle, 'main'); const diagnosticsChannel = sharedProcessClient.getChannel('diagnostics'); - const diagnosticsService = new DiagnosticsService(diagnosticsChannel); + const diagnosticsService = createChannelSender(diagnosticsChannel); const mainProcessInfo = await launchService.getMainProcessInfo(); const remoteDiagnostics = await launchService.getRemoteDiagnostics({ includeProcesses: true, includeWorkspaceMetadata: true }); const diagnostics = await diagnosticsService.getDiagnostics(mainProcessInfo, remoteDiagnostics); diff --git a/src/vs/platform/diagnostics/node/diagnosticsIpc.ts b/src/vs/platform/diagnostics/node/diagnosticsIpc.ts deleted file mode 100644 index f43ae1f4ca3..00000000000 --- a/src/vs/platform/diagnostics/node/diagnosticsIpc.ts +++ /dev/null @@ -1,58 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { IServerChannel, IChannel } from 'vs/base/parts/ipc/common/ipc'; -import { IRemoteDiagnosticInfo, IRemoteDiagnosticError, SystemInfo, PerformanceInfo } from 'vs/platform/diagnostics/common/diagnostics'; -import { IDiagnosticsService } from './diagnosticsService'; -import { Event } from 'vs/base/common/event'; -import { IMainProcessInfo } from 'vs/platform/launch/common/launch'; -import { IWorkspace } from 'vs/platform/workspace/common/workspace'; - -export class DiagnosticsChannel implements IServerChannel { - - constructor(private service: IDiagnosticsService) { } - - listen(context: any, event: string): Event { - throw new Error('Invalid listen'); - } - - call(context: any, command: string, args?: any): Promise { - switch (command) { - case 'getDiagnostics': - return this.service.getDiagnostics(args[0], args[1]); - case 'getSystemInfo': - return this.service.getSystemInfo(args[0], args[1]); - case 'getPerformanceInfo': - return this.service.getPerformanceInfo(args[0], args[1]); - case 'reportWorkspaceStats': - return this.service.reportWorkspaceStats(args); - } - - throw new Error('Invalid call'); - } -} - -export class DiagnosticsService implements IDiagnosticsService { - - declare readonly _serviceBrand: undefined; - - constructor(private channel: IChannel) { } - - public getDiagnostics(mainProcessInfo: IMainProcessInfo, remoteInfo: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise { - return this.channel.call('getDiagnostics', [mainProcessInfo, remoteInfo]); - } - - public getSystemInfo(mainProcessInfo: IMainProcessInfo, remoteInfo: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise { - return this.channel.call('getSystemInfo', [mainProcessInfo, remoteInfo]); - } - - public getPerformanceInfo(mainProcessInfo: IMainProcessInfo, remoteInfo: (IRemoteDiagnosticInfo | IRemoteDiagnosticError)[]): Promise { - return this.channel.call('getPerformanceInfo', [mainProcessInfo, remoteInfo]); - } - - public reportWorkspaceStats(workspace: IWorkspace): Promise { - return this.channel.call('reportWorkspaceStats', workspace); - } -} diff --git a/src/vs/workbench/contrib/tags/electron-browser/workspaceTags.ts b/src/vs/workbench/contrib/tags/electron-browser/workspaceTags.ts index 4737453d673..43cc4d58f3a 100644 --- a/src/vs/workbench/contrib/tags/electron-browser/workspaceTags.ts +++ b/src/vs/workbench/contrib/tags/electron-browser/workspaceTags.ts @@ -11,12 +11,12 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { ITextFileService, } from 'vs/workbench/services/textfile/common/textfiles'; -import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService'; import { IWorkspaceTagsService, Tags } from 'vs/workbench/contrib/tags/common/workspaceTags'; import { IWorkspaceInformation } from 'vs/platform/diagnostics/common/diagnostics'; import { IRequestService } from 'vs/platform/request/common/request'; import { isWindows } from 'vs/base/common/platform'; import { getRemotes, AllowedSecondLevelDomains, getDomainsOfRemotes } from 'vs/platform/extensionManagement/common/configRemotes'; +import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService'; export function getHashedRemotesFromConfig(text: string, stripEndingDotGit: boolean = false): string[] { return getRemotes(text, stripEndingDotGit).map(r => { @@ -32,8 +32,8 @@ export class WorkspaceTags implements IWorkbenchContribution { @ITelemetryService private readonly telemetryService: ITelemetryService, @IRequestService private readonly requestService: IRequestService, @ITextFileService private readonly textFileService: ITextFileService, - @ISharedProcessService private readonly sharedProcessService: ISharedProcessService, - @IWorkspaceTagsService private readonly workspaceTagsService: IWorkspaceTagsService + @IWorkspaceTagsService private readonly workspaceTagsService: IWorkspaceTagsService, + @IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService ) { if (this.telemetryService.isOptedIn) { this.report(); @@ -53,8 +53,7 @@ export class WorkspaceTags implements IWorkbenchContribution { this.reportProxyStats(); - const diagnosticsChannel = this.sharedProcessService.getChannel('diagnostics'); - this.getWorkspaceInformation().then(stats => diagnosticsChannel.call('reportWorkspaceStats', stats)); + this.getWorkspaceInformation().then(stats => this.diagnosticsService.reportWorkspaceStats(stats)); } async reportWindowsEdition(): Promise { diff --git a/src/vs/workbench/services/diagnostics/electron-browser/diagnosticsService.ts b/src/vs/workbench/services/diagnostics/electron-browser/diagnosticsService.ts new file mode 100644 index 00000000000..0b5428fc855 --- /dev/null +++ b/src/vs/workbench/services/diagnostics/electron-browser/diagnosticsService.ts @@ -0,0 +1,23 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { createChannelSender } from 'vs/base/parts/ipc/common/ipc'; +import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; +import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService'; + +// @ts-ignore: interface is implemented via proxy +export class DiagnosticsService implements IDiagnosticsService { + + declare readonly _serviceBrand: undefined; + + constructor( + @ISharedProcessService sharedProcessService: ISharedProcessService + ) { + return createChannelSender(sharedProcessService.getChannel('diagnostics')); + } +} + +registerSingleton(IDiagnosticsService, DiagnosticsService, true); diff --git a/src/vs/workbench/workbench.desktop.main.ts b/src/vs/workbench/workbench.desktop.main.ts index 4654815024c..5fd2222b446 100644 --- a/src/vs/workbench/workbench.desktop.main.ts +++ b/src/vs/workbench/workbench.desktop.main.ts @@ -53,6 +53,7 @@ import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncStoreMan import 'vs/workbench/services/userDataSync/electron-browser/userDataAutoSyncService'; import 'vs/workbench/services/sharedProcess/electron-browser/sharedProcessService'; import 'vs/workbench/services/localizations/electron-browser/localizationsService'; +import 'vs/workbench/services/diagnostics/electron-browser/diagnosticsService'; import 'vs/workbench/services/experiment/electron-browser/experimentService'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions';