Metered network connections support (#288919)

Includes public API, user setting, status bar icon and a new service to support metered network connections.
Updates code in various areas performing automated actions using network to delay/pause network operations while network connection is being metered.
This commit is contained in:
Dmitriy Vasyura
2026-02-06 14:52:14 -08:00
committed by GitHub
parent acab057679
commit fa6cfe12c6
51 changed files with 763 additions and 33 deletions

View File

@@ -60,6 +60,10 @@ import { ILifecycleMainService, LifecycleMainPhase, ShutdownReason } from '../..
import { ILoggerService, ILogService } from '../../platform/log/common/log.js';
import { IMenubarMainService, MenubarMainService } from '../../platform/menubar/electron-main/menubarMainService.js';
import { INativeHostMainService, NativeHostMainService } from '../../platform/native/electron-main/nativeHostMainService.js';
import { IMeteredConnectionService } from '../../platform/meteredConnection/common/meteredConnection.js';
import { METERED_CONNECTION_CHANNEL } from '../../platform/meteredConnection/common/meteredConnectionIpc.js';
import { MeteredConnectionChannel } from '../../platform/meteredConnection/electron-main/meteredConnectionChannel.js';
import { MeteredConnectionMainService } from '../../platform/meteredConnection/electron-main/meteredConnectionMainService.js';
import { IProductService } from '../../platform/product/common/productService.js';
import { getRemoteAuthority } from '../../platform/remote/common/remoteHosts.js';
import { SharedProcess } from '../../platform/sharedProcess/electron-main/sharedProcess.js';
@@ -589,6 +593,11 @@ export class CodeApplication extends Disposable {
// Error telemetry
appInstantiationService.invokeFunction(accessor => this._register(new ErrorTelemetry(accessor.get(ILogService), accessor.get(ITelemetryService))));
// Metered connection telemetry
appInstantiationService.invokeFunction(accessor => {
(accessor.get(IMeteredConnectionService) as MeteredConnectionMainService).setTelemetryService(accessor.get(ITelemetryService));
});
// Auth Handler
appInstantiationService.invokeFunction(accessor => accessor.get(IProxyAuthService));
@@ -1039,6 +1048,10 @@ export class CodeApplication extends Disposable {
// Native Host
services.set(INativeHostMainService, new SyncDescriptor(NativeHostMainService, undefined, false /* proxied to other processes */));
// Metered Connection
const meteredConnectionService = new MeteredConnectionMainService(this.configurationService);
services.set(IMeteredConnectionService, meteredConnectionService);
// Web Contents Extractor
services.set(IWebContentExtractorService, new SyncDescriptor(NativeWebContentExtractorService, undefined, false /* proxied to other processes */));
@@ -1168,6 +1181,11 @@ export class CodeApplication extends Disposable {
const updateChannel = new UpdateChannel(accessor.get(IUpdateService));
mainProcessElectronServer.registerChannel('update', updateChannel);
// Metered Connection
const meteredConnectionChannel = new MeteredConnectionChannel(accessor.get(IMeteredConnectionService) as MeteredConnectionMainService);
mainProcessElectronServer.registerChannel(METERED_CONNECTION_CHANNEL, meteredConnectionChannel);
sharedProcessClient.then(client => client.registerChannel(METERED_CONNECTION_CHANNEL, meteredConnectionChannel));
// Process
const processChannel = ProxyChannel.fromService(new ProcessMainService(this.logService, accessor.get(IDiagnosticsService), accessor.get(IDiagnosticsMainService)), disposables);
mainProcessElectronServer.registerChannel('process', processChannel);