66import { createDecorator } from 'vs/platform/instantiation/common/instantiation' ;
77import { Client } from 'vs/base/parts/ipc/common/ipc.net' ;
88import { connect } from 'vs/base/parts/ipc/node/ipc.net' ;
9- import { IWindowsService , IWindowService } from 'vs/platform/windows/common/windows' ;
9+ import { IWindowService } from 'vs/platform/windows/common/windows' ;
1010import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
1111import { IChannel , IServerChannel , getDelayedChannel } from 'vs/base/parts/ipc/common/ipc' ;
12+ import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService' ;
1213
1314export const ISharedProcessService = createDecorator < ISharedProcessService > ( 'sharedProcessService' ) ;
1415
@@ -17,30 +18,43 @@ export interface ISharedProcessService {
1718 _serviceBrand : undefined ;
1819
1920 getChannel ( channelName : string ) : IChannel ;
20-
2121 registerChannel ( channelName : string , channel : IServerChannel < string > ) : void ;
22+
23+ whenSharedProcessReady ( ) : Promise < void > ;
24+ toggleSharedProcessWindow ( ) : Promise < void > ;
2225}
2326
2427export class SharedProcessService implements ISharedProcessService {
2528
2629 _serviceBrand : undefined ;
2730
2831 private withSharedProcessConnection : Promise < Client < string > > ;
32+ private sharedProcessMainChannel : IChannel ;
2933
3034 constructor (
31- @IWindowsService windowsService : IWindowsService ,
35+ @IMainProcessService mainProcessService : IMainProcessService ,
3236 @IWindowService windowService : IWindowService ,
3337 @IEnvironmentService environmentService : IEnvironmentService
3438 ) {
35- this . withSharedProcessConnection = windowsService . whenSharedProcessReady ( )
39+ this . sharedProcessMainChannel = mainProcessService . getChannel ( 'sharedProcess' ) ;
40+
41+ this . withSharedProcessConnection = this . whenSharedProcessReady ( )
3642 . then ( ( ) => connect ( environmentService . sharedIPCHandle , `window:${ windowService . windowId } ` ) ) ;
3743 }
3844
45+ whenSharedProcessReady ( ) : Promise < void > {
46+ return this . sharedProcessMainChannel . call ( 'whenSharedProcessReady' ) ;
47+ }
48+
3949 getChannel ( channelName : string ) : IChannel {
4050 return getDelayedChannel ( this . withSharedProcessConnection . then ( connection => connection . getChannel ( channelName ) ) ) ;
4151 }
4252
4353 registerChannel ( channelName : string , channel : IServerChannel < string > ) : void {
4454 this . withSharedProcessConnection . then ( connection => connection . registerChannel ( channelName , channel ) ) ;
4555 }
56+
57+ toggleSharedProcessWindow ( ) : Promise < void > {
58+ return this . sharedProcessMainChannel . call ( 'toggleSharedProcessWindow' ) ;
59+ }
4660}
0 commit comments