|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 |
| -import { Event } from 'vs/base/common/event'; |
7 |
| -import { ipcMessagePort, ipcRenderer } from 'vs/base/parts/sandbox/electron-sandbox/globals'; |
8 | 6 | import { Client as MessagePortClient } from 'vs/base/parts/ipc/common/ipc.mp';
|
9 | 7 | import { IChannel, IServerChannel, getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
|
10 |
| -import { generateUuid } from 'vs/base/common/uuid'; |
11 | 8 | import { ILogService } from 'vs/platform/log/common/log';
|
12 | 9 | import { Disposable } from 'vs/base/common/lifecycle';
|
13 | 10 | import { ISharedProcessService } from 'vs/platform/ipc/electron-sandbox/services';
|
14 | 11 | import { mark } from 'vs/base/common/performance';
|
15 | 12 | import { Barrier, timeout } from 'vs/base/common/async';
|
| 13 | +import { acquirePort } from 'vs/base/parts/ipc/electron-sandbox/ipc.mp'; |
16 | 14 |
|
17 | 15 | export class SharedProcessService extends Disposable implements ISharedProcessService {
|
18 | 16 |
|
@@ -44,20 +42,9 @@ export class SharedProcessService extends Disposable implements ISharedProcessSe
|
44 | 42 | // is more cruicial.
|
45 | 43 | await Promise.race([this.restoredBarrier.wait(), timeout(2000)]);
|
46 | 44 |
|
| 45 | + // Acquire a message port connected to the shared process |
47 | 46 | mark('code/willConnectSharedProcess');
|
48 |
| - |
49 |
| - // Ask to create message channel inside the window |
50 |
| - // and send over a UUID to correlate the response |
51 |
| - const nonce = generateUuid(); |
52 |
| - ipcMessagePort.acquire('vscode:createSharedProcessMessageChannelResult', nonce); |
53 |
| - ipcRenderer.send('vscode:createSharedProcessMessageChannel', nonce); |
54 |
| - |
55 |
| - // Wait until the main side has returned the `MessagePort` |
56 |
| - // We need to filter by the `nonce` to ensure we listen |
57 |
| - // to the right response. |
58 |
| - const onMessageChannelResult = Event.fromDOMEventEmitter<{ nonce: string, port: MessagePort, source: unknown }>(window, 'message', (e: MessageEvent) => ({ nonce: e.data, port: e.ports[0], source: e.source })); |
59 |
| - const { port } = await Event.toPromise(Event.once(Event.filter(onMessageChannelResult, e => e.nonce === nonce && e.source === window))); |
60 |
| - |
| 47 | + const port = await acquirePort('vscode:createSharedProcessMessageChannel', 'vscode:createSharedProcessMessageChannelResult'); |
61 | 48 | mark('code/didConnectSharedProcess');
|
62 | 49 | this.logService.trace('Renderer->SharedProcess#connect: connection established');
|
63 | 50 |
|
|
0 commit comments