Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
18daad32
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 搜索 >>
提交
18daad32
编写于
7月 14, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create electron main process services in workbech main
上级
74df06e0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
31 deletion
+45
-31
src/vs/workbench/electron-browser/main.ts
src/vs/workbench/electron-browser/main.ts
+36
-4
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+9
-27
未找到文件。
src/vs/workbench/electron-browser/main.ts
浏览文件 @
18daad32
...
...
@@ -20,6 +20,8 @@ import strings = require('vs/base/common/strings');
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
EmptyWorkspaceServiceImpl
,
WorkspaceServiceImpl
,
WorkspaceService
}
from
'
vs/workbench/services/configuration/node/configuration
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
realpath
}
from
'
vs/base/node/pfs
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
path
=
require
(
'
path
'
);
...
...
@@ -27,12 +29,19 @@ import gracefulFs = require('graceful-fs');
import
{
IInitData
}
from
'
vs/workbench/services/timer/common/timerService
'
;
import
{
TimerService
}
from
'
vs/workbench/services/timer/node/timerService
'
;
import
{
KeyboardMapperFactory
}
from
"
vs/workbench/services/keybinding/electron-browser/keybindingService
"
;
import
{
IWindowConfiguration
,
IPath
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IWindowConfiguration
,
IPath
,
IWindowsService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
WindowsChannelClient
}
from
'
vs/platform/windows/common/windowsIpc
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
StorageService
,
inMemoryLocalStorageInstance
}
from
'
vs/platform/storage/common/storageService
'
;
import
{
webFrame
}
from
'
electron
'
;
import
{
Client
as
ElectronIPCClient
}
from
'
vs/base/parts/ipc/electron-browser/ipc.electron-browser
'
;
import
{
webFrame
,
remote
}
from
'
electron
'
;
import
{
UpdateChannelClient
}
from
'
vs/platform/update/common/updateIpc
'
;
import
{
IUpdateService
}
from
'
vs/platform/update/common/update
'
;
import
{
URLChannelClient
}
from
'
vs/platform/url/common/urlIpc
'
;
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
WorkspacesChannelClient
}
from
'
vs/platform/workspaces/common/workspacesIpc
'
;
import
{
IWorkspacesService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
fs
=
require
(
'
fs
'
);
gracefulFs
.
gracefulify
(
fs
);
// enable gracefulFs
...
...
@@ -95,6 +104,11 @@ function toInputs(paths: IPath[], isUntitledFile?: boolean): IResourceInput[] {
}
function
openWorkbench
(
configuration
:
IWindowConfiguration
,
options
:
IOptions
):
TPromise
<
void
>
{
const
currentWindow
=
remote
.
getCurrentWindow
();
const
mainProcessClient
=
new
ElectronIPCClient
(
String
(
`window
${
currentWindow
.
id
}
`
));
const
mainServices
=
createMainProcessServices
(
mainProcessClient
,
currentWindow
);
const
environmentService
=
new
EnvironmentService
(
configuration
,
configuration
.
execPath
);
// Since the configuration service is one of the core services that is used in so many places, we initialize it
...
...
@@ -116,7 +130,7 @@ function openWorkbench(configuration: IWindowConfiguration, options: IOptions):
environmentService
,
timerService
,
storageService
},
configuration
,
options
);
},
mainServices
,
configuration
,
options
);
shell
.
open
();
// Inform user about loading issues from the loader
...
...
@@ -199,6 +213,24 @@ function createStorageService(configuration: IWindowConfiguration, workspaceServ
return
new
StorageService
(
storage
,
storage
,
workspaceId
,
secondaryWorkspaceId
);
}
function
createMainProcessServices
(
mainProcessClient
:
ElectronIPCClient
,
currentWindow
:
Electron
.
BrowserWindow
):
ServiceCollection
{
const
serviceCollection
=
new
ServiceCollection
();
const
windowsChannel
=
mainProcessClient
.
getChannel
(
'
windows
'
);
serviceCollection
.
set
(
IWindowsService
,
new
WindowsChannelClient
(
windowsChannel
));
const
updateChannel
=
mainProcessClient
.
getChannel
(
'
update
'
);
serviceCollection
.
set
(
IUpdateService
,
new
SyncDescriptor
(
UpdateChannelClient
,
updateChannel
));
const
urlChannel
=
mainProcessClient
.
getChannel
(
'
url
'
);
serviceCollection
.
set
(
IURLService
,
new
SyncDescriptor
(
URLChannelClient
,
urlChannel
,
currentWindow
.
id
));
const
workspacesChannel
=
mainProcessClient
.
getChannel
(
'
workspaces
'
);
serviceCollection
.
set
(
IWorkspacesService
,
new
SyncDescriptor
(
WorkspacesChannelClient
,
workspacesChannel
));
return
serviceCollection
;
}
function
loaderError
(
err
:
Error
):
Error
{
if
(
platform
.
isWeb
)
{
return
new
Error
(
nls
.
localize
(
'
loaderError
'
,
"
Failed to load a required file. Either you are no longer connected to the internet or the server you are connected to is offline. Please refresh the browser to try again.
"
));
...
...
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
18daad32
...
...
@@ -33,7 +33,6 @@ import { resolveWorkbenchCommonProperties, getOrCreateMachineId } from 'vs/platf
import
{
machineIdIpcChannel
}
from
'
vs/platform/telemetry/node/commonProperties
'
;
import
{
WorkspaceStats
}
from
'
vs/workbench/services/telemetry/common/workspaceStats
'
;
import
{
IWindowsService
,
IWindowService
,
IWindowConfiguration
}
from
'
vs/platform/windows/common/windows
'
;
import
{
WindowsChannelClient
}
from
'
vs/platform/windows/common/windowsIpc
'
;
import
{
WindowService
}
from
'
vs/platform/windows/electron-browser/windowService
'
;
import
{
MessageService
}
from
'
vs/workbench/services/message/electron-browser/messageService
'
;
import
{
IRequestService
}
from
'
vs/platform/request/node/request
'
;
...
...
@@ -52,8 +51,6 @@ import { IIntegrityService } from 'vs/platform/integrity/common/integrity';
import
{
EditorWorkerServiceImpl
}
from
'
vs/editor/common/services/editorWorkerServiceImpl
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
MainProcessExtensionService
}
from
'
vs/workbench/api/electron-browser/mainThreadExtensionService
'
;
import
{
IWorkspacesService
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
WorkspacesChannelClient
}
from
'
vs/platform/workspaces/common/workspacesIpc
'
;
import
{
IOptions
}
from
'
vs/workbench/common/options
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -79,14 +76,9 @@ import { CrashReporterService } from 'vs/workbench/services/crashReporter/electr
import
{
NodeCachedDataManager
}
from
'
vs/workbench/electron-browser/nodeCachedDataManager
'
;
import
{
getDelayedChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
connect
as
connectNet
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
Client
as
ElectronIPCClient
}
from
'
vs/base/parts/ipc/electron-browser/ipc.electron-browser
'
;
import
{
IExtensionManagementChannel
,
ExtensionManagementChannelClient
}
from
'
vs/platform/extensionManagement/common/extensionManagementIpc
'
;
import
{
IExtensionManagementService
,
IExtensionEnablementService
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
ExtensionEnablementService
}
from
'
vs/platform/extensionManagement/common/extensionEnablementService
'
;
import
{
UpdateChannelClient
}
from
'
vs/platform/update/common/updateIpc
'
;
import
{
IUpdateService
}
from
'
vs/platform/update/common/update
'
;
import
{
URLChannelClient
}
from
'
vs/platform/url/common/urlIpc
'
;
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
ExtensionHostProcessWorker
}
from
'
vs/workbench/electron-browser/extensionHost
'
;
import
{
ITimerService
}
from
'
vs/workbench/services/timer/common/timerService
'
;
import
{
remote
,
ipcRenderer
as
ipc
}
from
'
electron
'
;
...
...
@@ -131,12 +123,13 @@ export class WorkbenchShell {
private
contextService
:
IWorkspaceContextService
;
private
telemetryService
:
ITelemetryService
;
private
extensionService
:
MainProcessExtensionService
;
private
windowsService
:
IWindowsService
;
private
broadcastService
:
IBroadcastService
;
private
timerService
:
ITimerService
;
private
themeService
:
WorkbenchThemeService
;
private
lifecycleService
:
LifecycleService
;
private
mainProcessServices
:
ServiceCollection
;
private
container
:
HTMLElement
;
private
toUnbind
:
IDisposable
[];
private
previousErrorValue
:
string
;
...
...
@@ -148,7 +141,7 @@ export class WorkbenchShell {
private
options
:
IOptions
;
private
workbench
:
Workbench
;
constructor
(
container
:
HTMLElement
,
services
:
ICoreServices
,
configuration
:
IWindowConfiguration
,
options
:
IOptions
)
{
constructor
(
container
:
HTMLElement
,
services
:
ICoreServices
,
mainProcessServices
:
ServiceCollection
,
configuration
:
IWindowConfiguration
,
options
:
IOptions
)
{
this
.
container
=
container
;
this
.
configuration
=
configuration
;
...
...
@@ -160,6 +153,8 @@ export class WorkbenchShell {
this
.
timerService
=
services
.
timerService
;
this
.
storageService
=
services
.
storageService
;
this
.
mainProcessServices
=
mainProcessServices
;
this
.
toUnbind
=
[];
this
.
previousErrorTime
=
0
;
}
...
...
@@ -255,22 +250,18 @@ export class WorkbenchShell {
serviceCollection
.
set
(
IEnvironmentService
,
this
.
environmentService
);
serviceCollection
.
set
(
ITimerService
,
this
.
timerService
);
serviceCollection
.
set
(
IStorageService
,
this
.
storageService
);
this
.
mainProcessServices
.
forEach
((
serviceIdentifier
,
serviceInstance
)
=>
{
serviceCollection
.
set
(
serviceIdentifier
,
serviceInstance
);
});
const
instantiationService
:
IInstantiationService
=
new
InstantiationService
(
serviceCollection
,
true
);
this
.
broadcastService
=
new
BroadcastService
(
currentWindow
.
id
);
serviceCollection
.
set
(
IBroadcastService
,
this
.
broadcastService
);
const
mainProcessClient
=
new
ElectronIPCClient
(
String
(
`window
${
currentWindow
.
id
}
`
));
disposables
.
push
(
mainProcessClient
);
const
windowsChannel
=
mainProcessClient
.
getChannel
(
'
windows
'
);
this
.
windowsService
=
new
WindowsChannelClient
(
windowsChannel
);
serviceCollection
.
set
(
IWindowsService
,
this
.
windowsService
);
serviceCollection
.
set
(
IWindowService
,
new
SyncDescriptor
(
WindowService
,
currentWindow
.
id
));
const
sharedProcess
=
this
.
windowsService
.
whenSharedProcessReady
()
const
sharedProcess
=
(
<
IWindowsService
>
serviceCollection
.
get
(
IWindowsService
))
.
whenSharedProcessReady
()
.
then
(()
=>
connectNet
(
this
.
environmentService
.
sharedIPCHandle
,
`window:
${
currentWindow
.
id
}
`
));
sharedProcess
...
...
@@ -380,15 +371,6 @@ export class WorkbenchShell {
serviceCollection
.
set
(
IIntegrityService
,
new
SyncDescriptor
(
IntegrityServiceImpl
));
const
updateChannel
=
mainProcessClient
.
getChannel
(
'
update
'
);
serviceCollection
.
set
(
IUpdateService
,
new
SyncDescriptor
(
UpdateChannelClient
,
updateChannel
));
const
urlChannel
=
mainProcessClient
.
getChannel
(
'
url
'
);
serviceCollection
.
set
(
IURLService
,
new
SyncDescriptor
(
URLChannelClient
,
urlChannel
,
currentWindow
.
id
));
const
workspacesChannel
=
mainProcessClient
.
getChannel
(
'
workspaces
'
);
serviceCollection
.
set
(
IWorkspacesService
,
new
SyncDescriptor
(
WorkspacesChannelClient
,
workspacesChannel
));
return
[
instantiationService
,
serviceCollection
];
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录