Skip to content

Commit 05999d3

Browse files
author
Benjamin Pasero
authored
debt - use utility for diagnostics IPC and introduce real workbench diagnostics service (microsoft#106836)
* debt - use utility for diagnostics IPC and introduce real workbench diagnostics service * address feedback * implement interface behind ts-ignore
1 parent d19c4ec commit 05999d3

7 files changed

Lines changed: 33 additions & 72 deletions

File tree

src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import { LogsDataCleaner } from 'vs/code/electron-browser/sharedProcess/contrib/
4343
import { IMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService';
4444
import { SpdLogService } from 'vs/platform/log/node/spdlogService';
4545
import { DiagnosticsService, IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService';
46-
import { DiagnosticsChannel } from 'vs/platform/diagnostics/node/diagnosticsIpc';
4746
import { FileService } from 'vs/platform/files/common/fileService';
4847
import { IFileService } from 'vs/platform/files/common/files';
4948
import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider';
@@ -223,7 +222,7 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
223222
server.registerChannel('localizations', localizationsChannel);
224223

225224
const diagnosticsService = accessor.get(IDiagnosticsService);
226-
const diagnosticsChannel = new DiagnosticsChannel(diagnosticsService);
225+
const diagnosticsChannel = createChannelReceiver(diagnosticsService);
227226
server.registerChannel('diagnostics', diagnosticsChannel);
228227

229228
const extensionTipsService = accessor.get(IExtensionTipsService);

src/vs/code/electron-main/app.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { NullTelemetryService, combinedAppender, LogAppender } from 'vs/platform
3131
import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc';
3232
import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
3333
import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties';
34-
import { getDelayedChannel, StaticRouter, createChannelReceiver } from 'vs/base/parts/ipc/common/ipc';
34+
import { getDelayedChannel, StaticRouter, createChannelReceiver, createChannelSender } from 'vs/base/parts/ipc/common/ipc';
3535
import product from 'vs/platform/product/common/product';
3636
import { ProxyAuthHandler } from 'vs/code/electron-main/auth';
3737
import { Disposable } from 'vs/base/common/lifecycle';
@@ -65,7 +65,6 @@ import { WorkspacesHistoryMainService, IWorkspacesHistoryMainService } from 'vs/
6565
import { NativeURLService } from 'vs/platform/url/common/urlService';
6666
import { WorkspacesMainService, IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService';
6767
import { statSync } from 'fs';
68-
import { DiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsIpc';
6968
import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService';
7069
import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc';
7170
import { ElectronExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/electron-main/extensionHostDebugIpc';
@@ -446,9 +445,7 @@ export class CodeApplication extends Disposable {
446445
services.set(IDialogMainService, new SyncDescriptor(DialogMainService));
447446
services.set(ISharedProcessMainService, new SyncDescriptor(SharedProcessMainService, [sharedProcess]));
448447
services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService));
449-
450-
const diagnosticsChannel = getDelayedChannel(sharedProcessReady.then(client => client.getChannel('diagnostics')));
451-
services.set(IDiagnosticsService, new SyncDescriptor(DiagnosticsService, [diagnosticsChannel]));
448+
services.set(IDiagnosticsService, createChannelSender(getDelayedChannel(sharedProcessReady.then(client => client.getChannel('diagnostics')))));
452449

453450
services.set(IIssueMainService, new SyncDescriptor(IssueMainService, [machineId, this.userEnv]));
454451
services.set(IElectronMainService, new SyncDescriptor(ElectronMainService));

src/vs/code/electron-main/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { Client } from 'vs/base/parts/ipc/common/ipc.net';
4040
import { once } from 'vs/base/common/functional';
4141
import { ISignService } from 'vs/platform/sign/common/sign';
4242
import { SignService } from 'vs/platform/sign/node/signService';
43-
import { DiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsIpc';
43+
import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService';
4444
import { FileService } from 'vs/platform/files/common/fileService';
4545
import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider';
4646
import { Schemas } from 'vs/base/common/network';
@@ -298,7 +298,7 @@ class CodeMain {
298298
// Create a diagnostic service connected to the existing shared process
299299
const sharedProcessClient = await connect(environmentService.sharedIPCHandle, 'main');
300300
const diagnosticsChannel = sharedProcessClient.getChannel('diagnostics');
301-
const diagnosticsService = new DiagnosticsService(diagnosticsChannel);
301+
const diagnosticsService = createChannelSender<IDiagnosticsService>(diagnosticsChannel);
302302
const mainProcessInfo = await launchService.getMainProcessInfo();
303303
const remoteDiagnostics = await launchService.getRemoteDiagnostics({ includeProcesses: true, includeWorkspaceMetadata: true });
304304
const diagnostics = await diagnosticsService.getDiagnostics(mainProcessInfo, remoteDiagnostics);

src/vs/platform/diagnostics/node/diagnosticsIpc.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/vs/workbench/contrib/tags/electron-browser/workspaceTags.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1111
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
1212
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
1313
import { ITextFileService, } from 'vs/workbench/services/textfile/common/textfiles';
14-
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
1514
import { IWorkspaceTagsService, Tags } from 'vs/workbench/contrib/tags/common/workspaceTags';
1615
import { IWorkspaceInformation } from 'vs/platform/diagnostics/common/diagnostics';
1716
import { IRequestService } from 'vs/platform/request/common/request';
1817
import { isWindows } from 'vs/base/common/platform';
1918
import { getRemotes, AllowedSecondLevelDomains, getDomainsOfRemotes } from 'vs/platform/extensionManagement/common/configRemotes';
19+
import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService';
2020

2121
export function getHashedRemotesFromConfig(text: string, stripEndingDotGit: boolean = false): string[] {
2222
return getRemotes(text, stripEndingDotGit).map(r => {
@@ -32,8 +32,8 @@ export class WorkspaceTags implements IWorkbenchContribution {
3232
@ITelemetryService private readonly telemetryService: ITelemetryService,
3333
@IRequestService private readonly requestService: IRequestService,
3434
@ITextFileService private readonly textFileService: ITextFileService,
35-
@ISharedProcessService private readonly sharedProcessService: ISharedProcessService,
36-
@IWorkspaceTagsService private readonly workspaceTagsService: IWorkspaceTagsService
35+
@IWorkspaceTagsService private readonly workspaceTagsService: IWorkspaceTagsService,
36+
@IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService
3737
) {
3838
if (this.telemetryService.isOptedIn) {
3939
this.report();
@@ -53,8 +53,7 @@ export class WorkspaceTags implements IWorkbenchContribution {
5353

5454
this.reportProxyStats();
5555

56-
const diagnosticsChannel = this.sharedProcessService.getChannel('diagnostics');
57-
this.getWorkspaceInformation().then(stats => diagnosticsChannel.call('reportWorkspaceStats', stats));
56+
this.getWorkspaceInformation().then(stats => this.diagnosticsService.reportWorkspaceStats(stats));
5857
}
5958

6059
async reportWindowsEdition(): Promise<void> {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { createChannelSender } from 'vs/base/parts/ipc/common/ipc';
7+
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
8+
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
9+
import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService';
10+
11+
// @ts-ignore: interface is implemented via proxy
12+
export class DiagnosticsService implements IDiagnosticsService {
13+
14+
declare readonly _serviceBrand: undefined;
15+
16+
constructor(
17+
@ISharedProcessService sharedProcessService: ISharedProcessService
18+
) {
19+
return createChannelSender<IDiagnosticsService>(sharedProcessService.getChannel('diagnostics'));
20+
}
21+
}
22+
23+
registerSingleton(IDiagnosticsService, DiagnosticsService, true);

src/vs/workbench/workbench.desktop.main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncStoreMan
5353
import 'vs/workbench/services/userDataSync/electron-browser/userDataAutoSyncService';
5454
import 'vs/workbench/services/sharedProcess/electron-browser/sharedProcessService';
5555
import 'vs/workbench/services/localizations/electron-browser/localizationsService';
56+
import 'vs/workbench/services/diagnostics/electron-browser/diagnosticsService';
5657
import 'vs/workbench/services/experiment/electron-browser/experimentService';
5758

5859
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';

0 commit comments

Comments
 (0)