Path: blob/main/extensions/copilot/src/extension/power/common/powerService.ts
13399 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Event } from '../../../util/vs/base/common/event';6import { IDisposable } from '../../../util/vs/base/common/lifecycle';7import { createDecorator } from '../../../util/vs/platform/instantiation/common/instantiation';89export const IPowerService = createDecorator<IPowerService>('IPowerService');1011export interface IPowerService {12readonly _serviceBrand: undefined;1314/**15* Fires when the system is suspending (going to sleep).16*/17readonly onDidSuspend: Event<void>;1819/**20* Fires when the system is resuming from sleep.21*/22readonly onDidResume: Event<void>;2324/**25* Acquires a power save blocker that prevents app suspension.26* The blocker is reference-counted and will be released 2 minutes after27* the last acquisition is disposed.28*29* @returns A disposable that releases this acquisition when disposed.30*/31acquirePowerSaveBlocker(): IDisposable;32}3334/**35* A no-op implementation of {@link IPowerService} for environments where36* power save blocking is not supported (e.g., web, headless, tests).37*/38export class NullPowerService implements IPowerService {39declare readonly _serviceBrand: undefined;4041readonly onDidSuspend = Event.None;42readonly onDidResume = Event.None;4344acquirePowerSaveBlocker(): IDisposable {45return { dispose: () => { } };46}47}484950