Path: blob/main/src/vs/platform/download/common/downloadIpc.ts
3296 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 '../../../base/common/event.js';6import { URI } from '../../../base/common/uri.js';7import { IURITransformer } from '../../../base/common/uriIpc.js';8import { IChannel, IServerChannel } from '../../../base/parts/ipc/common/ipc.js';9import { IDownloadService } from './download.js';1011export class DownloadServiceChannel implements IServerChannel {1213constructor(private readonly service: IDownloadService) { }1415listen(_: unknown, event: string, arg?: any): Event<any> {16throw new Error('Invalid listen');17}1819call(context: any, command: string, args?: any): Promise<any> {20switch (command) {21case 'download': return this.service.download(URI.revive(args[0]), URI.revive(args[1]));22}23throw new Error('Invalid call');24}25}2627export class DownloadServiceChannelClient implements IDownloadService {2829declare readonly _serviceBrand: undefined;3031constructor(private channel: IChannel, private getUriTransformer: () => IURITransformer | null) { }3233async download(from: URI, to: URI): Promise<void> {34const uriTransformer = this.getUriTransformer();35if (uriTransformer) {36from = uriTransformer.transformOutgoingURI(from);37to = uriTransformer.transformOutgoingURI(to);38}39await this.channel.call('download', [from, to]);40}41}424344