Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0ecb7735
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,发现更多精彩内容 >>
提交
0ecb7735
编写于
1月 13, 2021
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shared process - more cleanup
上级
75ea87a2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
78 addition
and
63 deletion
+78
-63
src/vs/code/electron-main/sharedProcess.ts
src/vs/code/electron-main/sharedProcess.ts
+72
-52
src/vs/code/electron-main/window.ts
src/vs/code/electron-main/window.ts
+6
-11
未找到文件。
src/vs/code/electron-main/sharedProcess.ts
浏览文件 @
0ecb7735
...
...
@@ -11,17 +11,20 @@ import { Barrier } from 'vs/base/common/async';
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILifecycleMainService
}
from
'
vs/platform/lifecycle/electron-main/lifecycleMainService
'
;
import
{
IThemeMainService
}
from
'
vs/platform/theme/electron-main/themeMainService
'
;
import
{
toDisposable
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
FileAccess
}
from
'
vs/base/common/network
'
;
import
{
browserCodeLoadingCacheStrategy
}
from
'
vs/base/common/platform
'
;
import
{
ISharedProcessConfiguration
}
from
'
vs/platform/sharedProcess/node/sharedProcess
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
export
class
SharedProcess
implements
ISharedProcess
{
export
class
SharedProcess
extends
Disposable
implements
ISharedProcess
{
private
readonly
barrier
=
new
Barrier
();
private
readonly
_whenReady
:
Promise
<
void
>
;
private
readonly
whenSpawnedBarrier
=
new
Barrier
();
private
window
:
BrowserWindow
|
null
=
null
;
// overall ready promise when shared process signals initialization is done
private
readonly
_whenReady
=
new
Promise
<
void
>
(
resolve
=>
ipcMain
.
once
(
'
vscode:shared-process->electron-main=init-done
'
,
()
=>
resolve
()));
private
window
:
BrowserWindow
|
undefined
=
undefined
;
private
windowCloseListener
:
((
event
:
Event
)
=>
void
)
|
undefined
=
undefined
;
constructor
(
private
readonly
machineId
:
string
,
...
...
@@ -31,12 +34,59 @@ export class SharedProcess implements ISharedProcess {
@
ILogService
private
readonly
logService
:
ILogService
,
@
IThemeMainService
private
readonly
themeMainService
:
IThemeMainService
)
{
// overall ready promise when shared process signals initialization is done
this
.
_whenReady
=
new
Promise
<
void
>
(
c
=>
ipcMain
.
once
(
'
vscode:shared-process->electron-main=init-done
'
,
()
=>
c
(
undefined
)));
super
();
this
.
registerListeners
();
}
private
registerListeners
():
void
{
this
.
_register
(
this
.
lifecycleMainService
.
onWillShutdown
(()
=>
this
.
onWillShutdown
()));
}
private
onWillShutdown
():
void
{
const
window
=
this
.
window
;
if
(
!
window
)
{
return
;
// possibly too early before created
}
// Signal exit to shared process when shutting down
window
.
webContents
.
send
(
'
vscode:electron-main->shared-process=exit
'
);
// Shut the shared process down when we are quitting
//
// Note: because we veto the window close, we must first remove our veto.
// Otherwise the application would never quit because the shared process
// window is refusing to close!
//
if
(
this
.
windowCloseListener
)
{
window
.
removeListener
(
'
close
'
,
this
.
windowCloseListener
);
}
// Electron seems to crash on Windows without this setTimeout :|
setTimeout
(()
=>
{
try
{
window
.
close
();
}
catch
(
err
)
{
// ignore, as electron is already shutting down
}
this
.
window
=
undefined
;
},
0
);
}
@
memoize
private
get
_whenIpcReady
():
Promise
<
void
>
{
// Create window for shared process
this
.
createWindow
();
// complete IPC-ready promise when shared process signals this to us
return
new
Promise
<
void
>
(
resolve
=>
ipcMain
.
once
(
'
vscode:shared-process->electron-main=ipc-ready
'
,
()
=>
resolve
(
undefined
)));
}
private
createWindow
():
void
{
// shared process is a hidden window by default
this
.
window
=
new
BrowserWindow
({
show
:
false
,
backgroundColor
:
this
.
themeMainService
.
getBackgroundColor
(),
...
...
@@ -72,72 +122,42 @@ export class SharedProcess implements ISharedProcess {
.
toString
(
true
)
);
// Prevent the window from
dy
ing
const
onClose
=
(
e
:
Event
)
=>
{
// Prevent the window from
clos
ing
this
.
windowCloseListener
=
(
e
:
Event
)
=>
{
this
.
logService
.
trace
(
'
SharedProcess#close prevented
'
);
// We never allow to close the shared process unless we get explicitly disposed()
e
.
preventDefault
();
// Still hide the window though if visible
if
(
this
.
window
&&
this
.
window
.
isVisible
())
{
if
(
this
.
window
?
.
isVisible
())
{
this
.
window
.
hide
();
}
};
this
.
window
.
on
(
'
close
'
,
onClose
);
const
disposables
=
new
DisposableStore
();
this
.
lifecycleMainService
.
onWillShutdown
(()
=>
{
disposables
.
dispose
();
// Shut the shared process down when we are quitting
//
// Note: because we veto the window close, we must first remove our veto.
// Otherwise the application would never quit because the shared process
// window is refusing to close!
//
if
(
this
.
window
)
{
this
.
window
.
removeListener
(
'
close
'
,
onClose
);
}
// Electron seems to crash on Windows without this setTimeout :|
setTimeout
(()
=>
{
try
{
if
(
this
.
window
)
{
this
.
window
.
close
();
}
}
catch
(
err
)
{
// ignore, as electron is already shutting down
}
this
.
window
=
null
;
},
0
);
});
return
new
Promise
<
void
>
(
resolve
=>
{
// signal exit to shared process when we get disposed
disposables
.
add
(
toDisposable
(()
=>
this
.
window
?.
webContents
.
send
(
'
vscode:electron-main->shared-process=exit
'
)));
// complete IPC-ready promise when shared process signals this to us
ipcMain
.
once
(
'
vscode:shared-process->electron-main=ipc-ready
'
,
()
=>
resolve
(
undefined
));
});
this
.
window
.
on
(
'
close
'
,
this
.
windowCloseListener
);
}
spawn
(
userEnv
:
NodeJS
.
ProcessEnv
):
void
{
this
.
userEnv
=
{
...
this
.
userEnv
,
...
userEnv
};
this
.
barrier
.
open
();
// Release barrier
this
.
whenSpawnedBarrier
.
open
();
}
async
whenReady
():
Promise
<
void
>
{
await
this
.
barrier
.
wait
();
// Always wait for `spawn()`
await
this
.
whenSpawnedBarrier
.
wait
();
await
this
.
_whenReady
;
}
async
whenIpcReady
():
Promise
<
void
>
{
await
this
.
barrier
.
wait
();
// Always wait for `spawn()`
await
this
.
whenSpawnedBarrier
.
wait
();
await
this
.
_whenIpcReady
;
}
...
...
src/vs/code/electron-main/window.ts
浏览文件 @
0ecb7735
...
...
@@ -102,22 +102,22 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private
hiddenTitleBarStyle
:
boolean
|
undefined
;
private
showTimeoutHandle
:
NodeJS
.
Timeout
|
undefined
;
private
_lastFocusTime
:
number
;
private
_readyState
:
ReadyState
;
private
_lastFocusTime
=
-
1
;
private
_readyState
=
ReadyState
.
NONE
;
private
windowState
:
IWindowState
;
private
currentMenuBarVisibility
:
MenuBarVisibility
|
undefined
;
private
representedFilename
:
string
|
undefined
;
private
documentEdited
:
boolean
|
undefined
;
private
readonly
whenReadyCallbacks
:
{
(
window
:
ICodeWindow
):
void
}[];
private
readonly
whenReadyCallbacks
:
{
(
window
:
ICodeWindow
):
void
}[]
=
[]
;
private
marketplaceHeadersPromise
:
Promise
<
object
>
;
private
readonly
touchBarGroups
:
TouchBarSegmentedControl
[];
private
readonly
touchBarGroups
:
TouchBarSegmentedControl
[]
=
[]
;
private
currentHttpProxy
?:
string
;
private
currentNoProxy
?:
string
;
private
currentHttpProxy
:
string
|
undefined
=
undefined
;
private
currentNoProxy
:
string
|
undefined
=
undefined
;
constructor
(
config
:
IWindowCreationOptions
,
...
...
@@ -135,11 +135,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
)
{
super
();
this
.
touchBarGroups
=
[];
this
.
_lastFocusTime
=
-
1
;
this
.
_readyState
=
ReadyState
.
NONE
;
this
.
whenReadyCallbacks
=
[];
//#region create browser window
{
// Load window state
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录