Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
253e9e32
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
253e9e32
编写于
1月 16, 2021
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shared process - consolidate services
上级
0c8cf08b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
93 deletion
+66
-93
src/vs/code/electron-main/sharedProcess.ts
src/vs/code/electron-main/sharedProcess.ts
+11
-19
src/vs/platform/ipc/electron-browser/sharedProcessService.ts
src/vs/platform/ipc/electron-browser/sharedProcessService.ts
+52
-1
src/vs/platform/sharedProcess/node/sharedProcess.ts
src/vs/platform/sharedProcess/node/sharedProcess.ts
+1
-1
src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts
...es/sharedProcess/electron-browser/sharedProcessService.ts
+0
-71
src/vs/workbench/workbench.desktop.main.ts
src/vs/workbench/workbench.desktop.main.ts
+2
-1
未找到文件。
src/vs/code/electron-main/sharedProcess.ts
浏览文件 @
253e9e32
...
...
@@ -212,29 +212,21 @@ export class SharedProcess extends Disposable implements ISharedProcess {
return
connectMessagePort
(
window
);
}
toggle
():
void
{
if
(
!
this
.
window
||
this
.
window
.
isVisible
())
{
this
.
hide
();
}
else
{
this
.
show
();
}
}
show
():
void
{
if
(
!
this
.
window
)
{
return
;
// possibly too early before created
}
async
toggle
():
Promise
<
void
>
{
this
.
window
.
show
();
this
.
window
.
webContents
.
openDevTools
();
}
// wait for window to be created
await
this
.
whenIpcReady
;
hide
():
void
{
if
(
!
this
.
window
)
{
return
;
// possibly
too early before created
return
;
// possibly
disposed already
}
this
.
window
.
webContents
.
closeDevTools
();
this
.
window
.
hide
();
if
(
this
.
window
.
isVisible
())
{
this
.
window
.
webContents
.
closeDevTools
();
this
.
window
.
hide
();
}
else
{
this
.
window
.
show
();
this
.
window
.
webContents
.
openDevTools
();
}
}
}
src/vs/platform/ipc/electron-browser/sharedProcessService.ts
浏览文件 @
253e9e32
...
...
@@ -4,7 +4,15 @@
*--------------------------------------------------------------------------------------------*/
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IChannel
,
IServerChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IpcRendererEvent
}
from
'
vs/base/parts/sandbox/electron-sandbox/electronTypes
'
;
import
{
ipcRenderer
}
from
'
vs/base/parts/sandbox/electron-sandbox/globals
'
;
import
{
Client
as
MessagePortClient
}
from
'
vs/base/parts/ipc/common/ipc.mp
'
;
import
{
IChannel
,
IServerChannel
,
getDelayedChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
INativeHostService
}
from
'
vs/platform/native/electron-sandbox/native
'
;
import
{
generateUuid
}
from
'
vs/base/common/uuid
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
export
const
ISharedProcessService
=
createDecorator
<
ISharedProcessService
>
(
'
sharedProcessService
'
);
...
...
@@ -15,3 +23,46 @@ export interface ISharedProcessService {
getChannel
(
channelName
:
string
):
IChannel
;
registerChannel
(
channelName
:
string
,
channel
:
IServerChannel
<
string
>
):
void
;
}
export
class
SharedProcessService
extends
Disposable
implements
ISharedProcessService
{
declare
readonly
_serviceBrand
:
undefined
;
private
readonly
withSharedProcessConnection
:
Promise
<
MessagePortClient
>
;
constructor
(
@
INativeHostService
private
readonly
nativeHostService
:
INativeHostService
,
@
ILogService
private
readonly
logService
:
ILogService
)
{
super
();
this
.
withSharedProcessConnection
=
this
.
connect
();
}
private
async
connect
():
Promise
<
MessagePortClient
>
{
this
.
logService
.
trace
(
'
Renderer->SharedProcess#connect
'
);
// Ask to create message channel inside the window
// and send over a UUID to correlate the response
const
nonce
=
generateUuid
();
ipcRenderer
.
send
(
'
vscode:createSharedProcessMessageChannel
'
,
nonce
);
// Wait until the main side has returned the `MessagePort`
// We need to filter by the `nonce` to ensure we listen
// to the right response.
const
onMessageChannelResult
=
Event
.
fromNodeEventEmitter
<
{
nonce
:
string
,
port
:
MessagePort
}
>
(
ipcRenderer
,
'
vscode:createSharedProcessMessageChannelResult
'
,
(
e
:
IpcRendererEvent
,
nonce
:
string
)
=>
({
nonce
,
port
:
e
.
ports
[
0
]
}));
const
{
port
}
=
await
Event
.
toPromise
(
Event
.
once
(
Event
.
filter
(
onMessageChannelResult
,
e
=>
e
.
nonce
===
nonce
)));
this
.
logService
.
trace
(
'
Renderer->SharedProcess#connect: connection established
'
);
return
this
.
_register
(
new
MessagePortClient
(
port
,
`window:
${
this
.
nativeHostService
.
windowId
}
`
));
}
getChannel
(
channelName
:
string
):
IChannel
{
return
getDelayedChannel
(
this
.
withSharedProcessConnection
.
then
(
connection
=>
connection
.
getChannel
(
channelName
)));
}
registerChannel
(
channelName
:
string
,
channel
:
IServerChannel
<
string
>
):
void
{
this
.
withSharedProcessConnection
.
then
(
connection
=>
connection
.
registerChannel
(
channelName
,
channel
));
}
}
src/vs/platform/sharedProcess/node/sharedProcess.ts
浏览文件 @
253e9e32
...
...
@@ -12,7 +12,7 @@ export interface ISharedProcess {
* Toggles the visibility of the otherwise hidden
* shared process window.
*/
toggle
():
void
;
toggle
():
Promise
<
void
>
;
}
export
interface
ISharedProcessConfiguration
{
...
...
src/vs/workbench/services/sharedProcess/electron-browser/sharedProcessService.ts
已删除
100644 → 0
浏览文件 @
0c8cf08b
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IpcRendererEvent
}
from
'
vs/base/parts/sandbox/electron-sandbox/electronTypes
'
;
import
{
ipcRenderer
}
from
'
vs/base/parts/sandbox/electron-sandbox/globals
'
;
import
{
Client
as
MessagePortClient
}
from
'
vs/base/parts/ipc/common/ipc.mp
'
;
import
{
IChannel
,
IServerChannel
,
getDelayedChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
ISharedProcessService
}
from
'
vs/platform/ipc/electron-browser/sharedProcessService
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
INativeHostService
}
from
'
vs/platform/native/electron-sandbox/native
'
;
import
{
generateUuid
}
from
'
vs/base/common/uuid
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILifecycleService
}
from
'
vs/workbench/services/lifecycle/common/lifecycle
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
export
class
SharedProcessService
extends
Disposable
implements
ISharedProcessService
{
declare
readonly
_serviceBrand
:
undefined
;
private
readonly
withSharedProcessConnection
:
Promise
<
MessagePortClient
>
;
constructor
(
@
INativeHostService
private
readonly
nativeHostService
:
INativeHostService
,
@
ILogService
private
readonly
logService
:
ILogService
,
@
ILifecycleService
private
readonly
lifecycleService
:
ILifecycleService
)
{
super
();
this
.
withSharedProcessConnection
=
this
.
connect
();
this
.
registerListeners
();
}
private
registerListeners
():
void
{
// Lifecycle
this
.
lifecycleService
.
onWillShutdown
(()
=>
this
.
dispose
());
}
private
async
connect
():
Promise
<
MessagePortClient
>
{
this
.
logService
.
trace
(
'
Workbench->SharedProcess#connect
'
);
// Ask to create message channel inside the window
// and send over a UUID to correlate the response
const
nonce
=
generateUuid
();
ipcRenderer
.
send
(
'
vscode:createSharedProcessMessageChannel
'
,
nonce
);
// Wait until the main side has returned the `MessagePort`
// We need to filter by the `nonce` to ensure we listen
// to the right response.
const
onMessageChannelResult
=
Event
.
fromNodeEventEmitter
<
{
nonce
:
string
,
port
:
MessagePort
}
>
(
ipcRenderer
,
'
vscode:createSharedProcessMessageChannelResult
'
,
(
e
:
IpcRendererEvent
,
nonce
:
string
)
=>
({
nonce
,
port
:
e
.
ports
[
0
]
}));
const
{
port
}
=
await
Event
.
toPromise
(
Event
.
once
(
Event
.
filter
(
onMessageChannelResult
,
e
=>
e
.
nonce
===
nonce
)));
this
.
logService
.
trace
(
'
Workbench->SharedProcess#connect: connection established
'
);
return
this
.
_register
(
new
MessagePortClient
(
port
,
`window:
${
this
.
nativeHostService
.
windowId
}
`
));
}
getChannel
(
channelName
:
string
):
IChannel
{
return
getDelayedChannel
(
this
.
withSharedProcessConnection
.
then
(
connection
=>
connection
.
getChannel
(
channelName
)));
}
registerChannel
(
channelName
:
string
,
channel
:
IServerChannel
<
string
>
):
void
{
this
.
withSharedProcessConnection
.
then
(
connection
=>
connection
.
registerChannel
(
channelName
,
channel
));
}
}
registerSingleton
(
ISharedProcessService
,
SharedProcessService
,
true
);
src/vs/workbench/workbench.desktop.main.ts
浏览文件 @
253e9e32
...
...
@@ -71,7 +71,6 @@ import 'vs/workbench/services/userDataSync/electron-browser/userDataSyncService'
import
'
vs/workbench/services/userDataSync/electron-browser/userDataSyncAccountService
'
;
import
'
vs/workbench/services/userDataSync/electron-browser/userDataSyncStoreManagementService
'
;
import
'
vs/workbench/services/userDataSync/electron-browser/userDataAutoSyncService
'
;
import
'
vs/workbench/services/sharedProcess/electron-browser/sharedProcessService
'
;
import
'
vs/workbench/services/localizations/electron-browser/localizationsService
'
;
import
'
vs/workbench/services/diagnostics/electron-browser/diagnosticsService
'
;
...
...
@@ -90,8 +89,10 @@ import 'vs/workbench/services/diagnostics/electron-browser/diagnosticsService';
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
ITunnelService
}
from
'
vs/platform/remote/common/tunnel
'
;
import
{
TunnelService
}
from
'
vs/workbench/services/remote/electron-browser/tunnelServiceImpl
'
;
import
{
ISharedProcessService
,
SharedProcessService
}
from
'
vs/platform/ipc/electron-browser/sharedProcessService
'
;
registerSingleton
(
ITunnelService
,
TunnelService
);
registerSingleton
(
ISharedProcessService
,
SharedProcessService
,
true
);
//#endregion
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录