Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cc59bf8e
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,发现更多精彩内容 >>
提交
cc59bf8e
编写于
3月 03, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
kill shared process when last window goes away
上级
60ba1dc9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
25 deletion
+52
-25
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+12
-5
src/vs/code/electron-main/sharedProcess.ts
src/vs/code/electron-main/sharedProcess.ts
+40
-20
未找到文件。
src/vs/code/electron-main/main.ts
浏览文件 @
cc59bf8e
...
...
@@ -27,7 +27,7 @@ import { Server, serve, connect } from 'vs/base/parts/ipc/node/ipc.net';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
AskpassChannel
}
from
'
vs/workbench/parts/git/common/gitIpc
'
;
import
{
GitAskpassService
}
from
'
vs/workbench/parts/git/electron-main/askpassService
'
;
import
{
spawn
SharedProcess
}
from
'
vs/code/electron-main/sharedProcess
'
;
import
{
SharedProcess
}
from
'
vs/code/electron-main/sharedProcess
'
;
import
{
Mutex
}
from
'
windows-mutex
'
;
import
{
LaunchService
,
ILaunchChannel
,
LaunchChannel
,
LaunchChannelClient
,
ILaunchService
}
from
'
./launch
'
;
import
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -144,8 +144,9 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
// Spawn shared process
const
initData
=
{
args
:
environmentService
.
args
};
const
sharedProcess
=
spawnSharedProcess
(
initData
,
environmentService
.
appRoot
,
environmentService
.
nodeCachedDataDir
)
.
then
(
disposable
=>
connect
(
environmentService
.
sharedIPCHandle
,
'
main
'
));
const
sharedProcess
=
new
SharedProcess
(
initData
,
environmentService
.
appRoot
,
environmentService
.
nodeCachedDataDir
);
const
sharedProcessClient
=
sharedProcess
.
onReady
.
then
(()
=>
connect
(
environmentService
.
sharedIPCHandle
,
'
main
'
));
// Create a new service collection, because the telemetry service
// requires a connection to shared process, which was only established
...
...
@@ -158,7 +159,7 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
services
.
set
(
ILaunchService
,
new
SyncDescriptor
(
LaunchService
));
if
(
environmentService
.
isBuilt
&&
!
environmentService
.
isExtensionDevelopment
&&
!!
product
.
enableTelemetry
)
{
const
channel
=
getDelayedChannel
<
ITelemetryAppenderChannel
>
(
sharedProcess
.
then
(
c
=>
c
.
getChannel
(
'
telemetryAppender
'
)));
const
channel
=
getDelayedChannel
<
ITelemetryAppenderChannel
>
(
sharedProcess
Client
.
then
(
c
=>
c
.
getChannel
(
'
telemetryAppender
'
)));
const
appender
=
new
TelemetryAppenderClient
(
channel
);
const
commonProperties
=
resolveCommonProperties
(
product
.
commit
,
pkg
.
version
);
const
piiPaths
=
[
environmentService
.
appRoot
,
environmentService
.
extensionsPath
];
...
...
@@ -174,6 +175,12 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
// TODO@Joao: unfold this
windowsMainService
=
accessor
.
get
(
IWindowsMainService
);
windowsMainService
.
onWindowClose
(()
=>
{
if
(
windowsMainService
.
getWindowCount
()
===
0
)
{
sharedProcess
.
dispose
();
}
});
// Register more Main IPC services
const
launchService
=
accessor
.
get
(
ILaunchService
);
const
launchChannel
=
new
LaunchChannel
(
launchService
);
...
...
@@ -195,7 +202,7 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
const
windowsService
=
accessor
.
get
(
IWindowsService
);
const
windowsChannel
=
new
WindowsChannel
(
windowsService
);
electronIpcServer
.
registerChannel
(
'
windows
'
,
windowsChannel
);
sharedProcess
.
done
(
client
=>
client
.
registerChannel
(
'
windows
'
,
windowsChannel
));
sharedProcess
Client
.
done
(
client
=>
client
.
registerChannel
(
'
windows
'
,
windowsChannel
));
// Make sure we associate the program with the app user model id
// This will help Windows to associate the running program with
...
...
src/vs/code/electron-main/sharedProcess.ts
浏览文件 @
cc59bf8e
...
...
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
memoize
}
from
'
vs/base/common/decorators
'
;
import
{
ParsedArgs
}
from
'
vs/platform/environment/common/environment
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
BrowserWindow
,
ipcMain
}
from
'
electron
'
;
...
...
@@ -12,27 +13,46 @@ export interface ISharedProcessInitData {
args
:
ParsedArgs
;
}
export
function
spawnSharedProcess
(
initData
:
ISharedProcessInitData
,
appRoot
:
string
,
nodeCachedDataDir
:
string
):
TPromise
<
void
>
{
const
window
=
new
BrowserWindow
();
const
config
=
assign
({
appRoot
,
nodeCachedDataDir
});
export
class
SharedProcess
{
const
url
=
`
${
require
.
toUrl
(
'
vs/code/electron-browser/sharedProcess.html
'
)}
?config=
${
encodeURIComponent
(
JSON
.
stringify
(
config
))}
`
;
window
.
loadURL
(
url
);
// window.webContents.openDevTools();
window
.
hide
();
private
window
:
Electron
.
BrowserWindow
;
// Prevent the window from dying
window
.
on
(
'
close
'
,
e
=>
{
if
(
window
.
isVisible
())
{
e
.
preventDefault
();
window
.
hide
();
}
});
@
memoize
get
onReady
():
TPromise
<
void
>
{
this
.
window
=
new
BrowserWindow
();
const
config
=
assign
({
appRoot
:
this
.
appRoot
,
nodeCachedDataDir
:
this
.
nodeCachedDataDir
});
const
url
=
`
${
require
.
toUrl
(
'
vs/code/electron-browser/sharedProcess.html
'
)}
?config=
${
encodeURIComponent
(
JSON
.
stringify
(
config
))}
`
;
this
.
window
.
loadURL
(
url
);
this
.
window
.
webContents
.
openDevTools
();
// this.window.hide();
// Prevent the window from dying
this
.
window
.
on
(
'
close
'
,
e
=>
{
if
(
this
.
window
.
isVisible
())
{
e
.
preventDefault
();
this
.
window
.
hide
();
}
});
return
new
TPromise
<
void
>
((
c
,
e
)
=>
{
ipcMain
.
once
(
'
handshake
'
,
({
sender
})
=>
{
sender
.
send
(
'
handshake
'
,
initData
);
c
(
null
);
return
new
TPromise
<
void
>
((
c
,
e
)
=>
{
ipcMain
.
once
(
'
handshake
'
,
({
sender
})
=>
{
sender
.
send
(
'
handshake
'
,
this
.
initData
);
c
(
null
);
});
});
});
}
\ No newline at end of file
}
constructor
(
private
initData
:
ISharedProcessInitData
,
private
appRoot
:
string
,
private
nodeCachedDataDir
:
string
)
{
}
dispose
():
void
{
if
(
this
.
window
)
{
this
.
window
.
close
();
this
.
window
=
null
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录