Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eba7707d
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,发现更多精彩内容 >>
提交
eba7707d
编写于
1月 13, 2021
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shared process - clean up some types and imports
上级
675e5da7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
31 addition
and
29 deletion
+31
-29
src/vs/base/parts/ipc/electron-main/ipc.electron.ts
src/vs/base/parts/ipc/electron-main/ipc.electron.ts
+1
-0
src/vs/base/parts/ipc/electron-sandbox/ipc.electron.ts
src/vs/base/parts/ipc/electron-sandbox/ipc.electron.ts
+1
-0
src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
.../code/electron-browser/sharedProcess/sharedProcessMain.ts
+12
-12
src/vs/code/electron-main/app.ts
src/vs/code/electron-main/app.ts
+8
-8
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+8
-8
src/vs/platform/ipc/electron-sandbox/mainProcessService.ts
src/vs/platform/ipc/electron-sandbox/mainProcessService.ts
+1
-1
未找到文件。
src/vs/base/parts/ipc/electron-main/ipc.electron
-main
.ts
→
src/vs/base/parts/ipc/electron-main/ipc.electron.ts
浏览文件 @
eba7707d
...
...
@@ -18,6 +18,7 @@ interface IIPCEvent {
function
createScopedOnMessageEvent
(
senderId
:
number
,
eventName
:
string
):
Event
<
VSBuffer
|
null
>
{
const
onMessage
=
Event
.
fromNodeEventEmitter
<
IIPCEvent
>
(
ipcMain
,
eventName
,
(
event
,
message
)
=>
({
event
,
message
}));
const
onMessageFromSender
=
Event
.
filter
(
onMessage
,
({
event
})
=>
event
.
sender
.
id
===
senderId
);
return
Event
.
map
(
onMessageFromSender
,
({
message
})
=>
message
?
VSBuffer
.
wrap
(
message
)
:
message
);
}
...
...
src/vs/base/parts/ipc/electron-sandbox/ipc.electron
-sandbox
.ts
→
src/vs/base/parts/ipc/electron-sandbox/ipc.electron.ts
浏览文件 @
eba7707d
...
...
@@ -17,6 +17,7 @@ export class Client extends IPCClient implements IDisposable {
private
static
createProtocol
():
Protocol
{
const
onMessage
=
Event
.
fromNodeEventEmitter
<
VSBuffer
>
(
ipcRenderer
,
'
vscode:message
'
,
(
_
,
message
)
=>
VSBuffer
.
wrap
(
message
));
ipcRenderer
.
send
(
'
vscode:hello
'
);
return
new
Protocol
(
ipcRenderer
,
onMessage
);
}
...
...
src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
浏览文件 @
eba7707d
...
...
@@ -3,10 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
fs
from
'
fs
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
product
from
'
vs/platform/product/common/product
'
;
import
{
serve
,
Server
,
connect
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
unlinkSync
}
from
'
fs
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
IChannel
,
IServerChannel
,
StaticRouter
,
createChannelSender
,
createChannelReceiver
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
serve
as
nodeIPCServe
,
Server
as
NodeIPCServer
,
connect
as
nodeIPCConnect
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
...
...
@@ -35,7 +36,6 @@ import { ILocalizationsService } from 'vs/platform/localizations/common/localiza
import
{
combinedDisposable
,
DisposableStore
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
DownloadService
}
from
'
vs/platform/download/common/downloadService
'
;
import
{
IDownloadService
}
from
'
vs/platform/download/common/download
'
;
import
{
IChannel
,
IServerChannel
,
StaticRouter
,
createChannelSender
,
createChannelReceiver
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
NodeCachedDataCleaner
}
from
'
vs/code/electron-browser/sharedProcess/contrib/nodeCachedDataCleaner
'
;
import
{
LanguagePackCachedDataCleaner
}
from
'
vs/code/electron-browser/sharedProcess/contrib/languagePackCachedDataCleaner
'
;
import
{
StorageDataCleaner
}
from
'
vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner
'
;
...
...
@@ -95,7 +95,7 @@ const eventPrefix = 'monacoworkbench';
class
MainProcessService
implements
IMainProcessService
{
constructor
(
private
server
:
Server
,
private
server
:
NodeIPC
Server
,
private
mainRouter
:
StaticRouter
)
{
}
...
...
@@ -110,7 +110,7 @@ class MainProcessService implements IMainProcessService {
}
}
async
function
main
(
server
:
Server
,
initData
:
ISharedProcessInitData
,
configuration
:
ISharedProcessConfiguration
):
Promise
<
void
>
{
async
function
main
(
server
:
NodeIPC
Server
,
initData
:
ISharedProcessInitData
,
configuration
:
ISharedProcessConfiguration
):
Promise
<
void
>
{
const
services
=
new
ServiceCollection
();
const
disposables
=
new
DisposableStore
();
...
...
@@ -276,16 +276,16 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
});
}
function
setupIPC
(
hook
:
string
):
Promise
<
Server
>
{
function
setup
(
retry
:
boolean
):
Promise
<
Server
>
{
return
s
erve
(
hook
).
then
(
null
,
err
=>
{
if
(
!
retry
||
platform
.
isWindows
||
err
.
code
!==
'
EADDRINUSE
'
)
{
function
setupIPC
(
hook
:
string
):
Promise
<
NodeIPC
Server
>
{
function
setup
(
retry
:
boolean
):
Promise
<
NodeIPC
Server
>
{
return
nodeIPCS
erve
(
hook
).
then
(
null
,
err
=>
{
if
(
!
retry
||
isWindows
||
err
.
code
!==
'
EADDRINUSE
'
)
{
return
Promise
.
reject
(
err
);
}
// should retry, not windows and eaddrinuse
return
c
onnect
(
hook
,
''
).
then
(
return
nodeIPCC
onnect
(
hook
,
''
).
then
(
client
=>
{
// we could connect to a running instance. this is not good, abort
client
.
dispose
();
...
...
@@ -296,7 +296,7 @@ function setupIPC(hook: string): Promise<Server> {
// let's delete it, since we can't connect to it
// and the retry the whole thing
try
{
fs
.
unlinkSync
(
hook
);
unlinkSync
(
hook
);
}
catch
(
e
)
{
return
Promise
.
reject
(
new
Error
(
'
Error deleting the shared ipc hook.
'
));
}
...
...
src/vs/code/electron-main/app.ts
浏览文件 @
eba7707d
...
...
@@ -11,9 +11,10 @@ import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle
import
{
resolveShellEnv
}
from
'
vs/code/node/shellEnv
'
;
import
{
IUpdateService
}
from
'
vs/platform/update/common/update
'
;
import
{
UpdateChannel
}
from
'
vs/platform/update/electron-main/updateIpc
'
;
import
{
Server
as
ElectronIPCServer
}
from
'
vs/base/parts/ipc/electron-main/ipc.electron-main
'
;
import
{
Client
}
from
'
vs/base/parts/ipc/common/ipc.net
'
;
import
{
Server
,
connect
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
getDelayedChannel
,
StaticRouter
,
createChannelReceiver
,
createChannelSender
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
Server
as
ElectronIPCServer
}
from
'
vs/base/parts/ipc/electron-main/ipc.electron
'
;
import
{
Client
as
NodeIPCClient
}
from
'
vs/base/parts/ipc/common/ipc.net
'
;
import
{
Server
as
NodeIPCServer
,
connect
as
nodeIPCConnect
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
SharedProcess
}
from
'
vs/code/electron-main/sharedProcess
'
;
import
{
LaunchMainService
,
ILaunchMainService
}
from
'
vs/platform/launch/electron-main/launchMainService
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -30,7 +31,6 @@ import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtil
import
{
TelemetryAppenderClient
}
from
'
vs/platform/telemetry/node/telemetryIpc
'
;
import
{
TelemetryService
,
ITelemetryServiceConfig
}
from
'
vs/platform/telemetry/common/telemetryService
'
;
import
{
resolveCommonProperties
}
from
'
vs/platform/telemetry/node/commonProperties
'
;
import
{
getDelayedChannel
,
StaticRouter
,
createChannelReceiver
,
createChannelSender
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
product
from
'
vs/platform/product/common/product
'
;
import
{
ProxyAuthHandler
}
from
'
vs/code/electron-main/auth
'
;
import
{
FileProtocolHandler
}
from
'
vs/code/electron-main/protocol
'
;
...
...
@@ -96,7 +96,7 @@ export class CodeApplication extends Disposable {
private
nativeHostMainService
:
INativeHostMainService
|
undefined
;
constructor
(
private
readonly
mainIpcServer
:
Server
,
private
readonly
mainIpcServer
:
NodeIPC
Server
,
private
readonly
userEnv
:
IProcessEnvironment
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
ILogService
private
readonly
logService
:
ILogService
,
...
...
@@ -429,7 +429,7 @@ export class CodeApplication extends Disposable {
const
sharedProcessClient
=
sharedProcess
.
whenIpcReady
().
then
(()
=>
{
this
.
logService
.
trace
(
'
Shared process: IPC ready
'
);
return
c
onnect
(
this
.
environmentService
.
sharedIPCHandle
,
'
main
'
);
return
nodeIPCC
onnect
(
this
.
environmentService
.
sharedIPCHandle
,
'
main
'
);
});
const
sharedProcessReady
=
sharedProcess
.
whenReady
().
then
(()
=>
{
this
.
logService
.
trace
(
'
Shared process: init ready
'
);
...
...
@@ -482,7 +482,7 @@ export class CodeApplication extends Disposable {
return
machineId
;
}
private
async
createServices
(
machineId
:
string
,
sharedProcess
:
SharedProcess
,
sharedProcessReady
:
Promise
<
Client
<
string
>>
):
Promise
<
IInstantiationService
>
{
private
async
createServices
(
machineId
:
string
,
sharedProcess
:
SharedProcess
,
sharedProcessReady
:
Promise
<
NodeIPC
Client
<
string
>>
):
Promise
<
IInstantiationService
>
{
const
services
=
new
ServiceCollection
();
switch
(
process
.
platform
)
{
...
...
@@ -584,7 +584,7 @@ export class CodeApplication extends Disposable {
});
}
private
openFirstWindow
(
accessor
:
ServicesAccessor
,
electronIpcServer
:
ElectronIPCServer
,
sharedProcessClient
:
Promise
<
Client
<
string
>>
,
fileProtocolHandler
:
FileProtocolHandler
):
ICodeWindow
[]
{
private
openFirstWindow
(
accessor
:
ServicesAccessor
,
electronIpcServer
:
ElectronIPCServer
,
sharedProcessClient
:
Promise
<
NodeIPC
Client
<
string
>>
,
fileProtocolHandler
:
FileProtocolHandler
):
ICodeWindow
[]
{
// Register more Main IPC services
const
launchMainService
=
accessor
.
get
(
ILaunchMainService
);
...
...
src/vs/code/electron-main/main.ts
浏览文件 @
eba7707d
...
...
@@ -13,8 +13,9 @@ import { parseMainProcessArgv, addArg } from 'vs/platform/environment/node/argvH
import
{
createWaitMarkerFile
}
from
'
vs/platform/environment/node/waitMarkerFile
'
;
import
{
mkdirp
}
from
'
vs/base/node/pfs
'
;
import
{
LifecycleMainService
,
ILifecycleMainService
}
from
'
vs/platform/lifecycle/electron-main/lifecycleMainService
'
;
import
{
Server
,
serve
,
connect
,
XDG_RUNTIME_DIR
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
createChannelSender
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
Server
as
NodeIPCServer
,
serve
as
nodeIPCServe
,
connect
as
nodeIPCConnect
,
XDG_RUNTIME_DIR
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
Client
as
NodeIPCClient
}
from
'
vs/base/parts/ipc/common/ipc.net
'
;
import
{
ILaunchMainService
}
from
'
vs/platform/launch/electron-main/launchMainService
'
;
import
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
...
...
@@ -35,7 +36,6 @@ import { SpdLogService } from 'vs/platform/log/node/spdlogService';
import
{
BufferLogService
}
from
'
vs/platform/log/common/bufferLog
'
;
import
{
setUnexpectedErrorHandler
}
from
'
vs/base/common/errors
'
;
import
{
IThemeMainService
,
ThemeMainService
}
from
'
vs/platform/theme/electron-main/themeMainService
'
;
import
{
Client
}
from
'
vs/base/parts/ipc/common/ipc.net
'
;
import
{
once
}
from
'
vs/base/common/functional
'
;
import
{
ISignService
}
from
'
vs/platform/sign/common/sign
'
;
import
{
SignService
}
from
'
vs/platform/sign/node/signService
'
;
...
...
@@ -213,14 +213,14 @@ class CodeMain {
return
instanceEnvironment
;
}
private
async
doStartup
(
args
:
NativeParsedArgs
,
logService
:
ILogService
,
environmentService
:
IEnvironmentMainService
,
lifecycleMainService
:
ILifecycleMainService
,
instantiationService
:
IInstantiationService
,
retry
:
boolean
):
Promise
<
Server
>
{
private
async
doStartup
(
args
:
NativeParsedArgs
,
logService
:
ILogService
,
environmentService
:
IEnvironmentMainService
,
lifecycleMainService
:
ILifecycleMainService
,
instantiationService
:
IInstantiationService
,
retry
:
boolean
):
Promise
<
NodeIPC
Server
>
{
// Try to setup a server for running. If that succeeds it means
// we are the first instance to startup. Otherwise it is likely
// that another instance is already running.
let
server
:
Server
;
let
server
:
NodeIPC
Server
;
try
{
server
=
await
s
erve
(
environmentService
.
mainIPCHandle
);
server
=
await
nodeIPCS
erve
(
environmentService
.
mainIPCHandle
);
once
(
lifecycleMainService
.
onWillShutdown
)(()
=>
server
.
dispose
());
}
catch
(
error
)
{
...
...
@@ -236,9 +236,9 @@ class CodeMain {
}
// there's a running instance, let's connect to it
let
client
:
Client
<
string
>
;
let
client
:
NodeIPC
Client
<
string
>
;
try
{
client
=
await
c
onnect
(
environmentService
.
mainIPCHandle
,
'
main
'
);
client
=
await
nodeIPCC
onnect
(
environmentService
.
mainIPCHandle
,
'
main
'
);
}
catch
(
error
)
{
// Handle unexpected connection errors by showing a dialog to the user
...
...
@@ -296,7 +296,7 @@ class CodeMain {
return
instantiationService
.
invokeFunction
(
async
()
=>
{
// Create a diagnostic service connected to the existing shared process
const
sharedProcessClient
=
await
c
onnect
(
environmentService
.
sharedIPCHandle
,
'
main
'
);
const
sharedProcessClient
=
await
nodeIPCC
onnect
(
environmentService
.
sharedIPCHandle
,
'
main
'
);
const
diagnosticsChannel
=
sharedProcessClient
.
getChannel
(
'
diagnostics
'
);
const
diagnosticsService
=
createChannelSender
<
IDiagnosticsService
>
(
diagnosticsChannel
);
const
mainProcessInfo
=
await
launchService
.
getMainProcessInfo
();
...
...
src/vs/platform/ipc/electron-sandbox/mainProcessService.ts
浏览文件 @
eba7707d
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
IChannel
,
IServerChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
Client
}
from
'
vs/base/parts/ipc/electron-sandbox/ipc.electron
-sandbox
'
;
import
{
Client
}
from
'
vs/base/parts/ipc/electron-sandbox/ipc.electron
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录