Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
acfadb48
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,发现更多精彩内容 >>
未验证
提交
acfadb48
编写于
8月 24, 2018
作者:
A
Alexandru Dima
提交者:
GitHub
8月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #57144 from Microsoft/alex/binary-rpc
Convert renderer <-> ext host communication to a binary format
上级
6a733c7f
8e35ed1d
变更
7
展开全部
显示空白变更内容
内联
并排
Showing
7 changed file
with
562 addition
and
134 deletion
+562
-134
src/vs/base/parts/ipc/node/ipc.net.ts
src/vs/base/parts/ipc/node/ipc.net.ts
+1
-1
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
...vs/workbench/api/electron-browser/mainThreadFileSystem.ts
+3
-5
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+2
-2
src/vs/workbench/api/node/extHostFileSystem.ts
src/vs/workbench/api/node/extHostFileSystem.ts
+4
-4
src/vs/workbench/services/extensions/electron-browser/extensionService.ts
.../services/extensions/electron-browser/extensionService.ts
+15
-14
src/vs/workbench/services/extensions/node/rpcProtocol.ts
src/vs/workbench/services/extensions/node/rpcProtocol.ts
+393
-108
src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts
...rkbench/services/extensions/test/node/rpcProtocol.test.ts
+144
-0
未找到文件。
src/vs/base/parts/ipc/node/ipc.net.ts
浏览文件 @
acfadb48
...
@@ -164,7 +164,7 @@ export class Protocol implements IDisposable, IMessagePassingProtocol {
...
@@ -164,7 +164,7 @@ export class Protocol implements IDisposable, IMessagePassingProtocol {
}
}
send
(
buffer
:
Buffer
):
void
{
send
(
buffer
:
Buffer
):
void
{
const
header
=
Buffer
.
alloc
(
Protocol
.
_headerLen
);
const
header
=
Buffer
.
alloc
Unsafe
(
Protocol
.
_headerLen
);
header
.
writeUInt32BE
(
buffer
.
length
,
0
,
true
);
header
.
writeUInt32BE
(
buffer
.
length
,
0
,
true
);
this
.
_writeSoon
(
header
,
buffer
);
this
.
_writeSoon
(
header
,
buffer
);
}
}
...
...
src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts
浏览文件 @
acfadb48
...
@@ -99,15 +99,13 @@ class RemoteFileSystemProvider implements IFileSystemProvider {
...
@@ -99,15 +99,13 @@ class RemoteFileSystemProvider implements IFileSystemProvider {
}
}
readFile
(
resource
:
URI
):
TPromise
<
Uint8Array
>
{
readFile
(
resource
:
URI
):
TPromise
<
Uint8Array
>
{
return
this
.
_proxy
.
$readFile
(
this
.
_handle
,
resource
).
then
(
encoded
=>
{
return
this
.
_proxy
.
$readFile
(
this
.
_handle
,
resource
);
return
Buffer
.
from
(
encoded
,
'
base64
'
);
});
}
}
writeFile
(
resource
:
URI
,
content
:
Uint8Array
,
opts
:
FileWriteOptions
):
TPromise
<
void
>
{
writeFile
(
resource
:
URI
,
content
:
Uint8Array
,
opts
:
FileWriteOptions
):
TPromise
<
void
>
{
let
encoded
=
Buffer
.
isBuffer
(
content
)
let
encoded
=
Buffer
.
isBuffer
(
content
)
?
content
.
toString
(
'
base64
'
)
?
content
:
Buffer
.
from
(
content
.
buffer
,
content
.
byteOffset
,
content
.
byteLength
)
.
toString
(
'
base64
'
)
;
:
Buffer
.
from
(
content
.
buffer
,
content
.
byteOffset
,
content
.
byteLength
);
return
this
.
_proxy
.
$writeFile
(
this
.
_handle
,
resource
,
encoded
,
opts
);
return
this
.
_proxy
.
$writeFile
(
this
.
_handle
,
resource
,
encoded
,
opts
);
}
}
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
acfadb48
...
@@ -680,8 +680,8 @@ export interface ExtHostWorkspaceShape {
...
@@ -680,8 +680,8 @@ export interface ExtHostWorkspaceShape {
export
interface
ExtHostFileSystemShape
{
export
interface
ExtHostFileSystemShape
{
$stat
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
IStat
>
;
$stat
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
IStat
>
;
$readdir
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
[
string
,
FileType
][]
>
;
$readdir
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
[
string
,
FileType
][]
>
;
$readFile
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
string
>
;
$readFile
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
Buffer
>
;
$writeFile
(
handle
:
number
,
resource
:
UriComponents
,
base64Encoded
:
string
,
opts
:
FileWriteOptions
):
TPromise
<
void
>
;
$writeFile
(
handle
:
number
,
resource
:
UriComponents
,
content
:
Buffer
,
opts
:
FileWriteOptions
):
TPromise
<
void
>
;
$rename
(
handle
:
number
,
resource
:
UriComponents
,
target
:
UriComponents
,
opts
:
FileOverwriteOptions
):
TPromise
<
void
>
;
$rename
(
handle
:
number
,
resource
:
UriComponents
,
target
:
UriComponents
,
opts
:
FileOverwriteOptions
):
TPromise
<
void
>
;
$copy
(
handle
:
number
,
resource
:
UriComponents
,
target
:
UriComponents
,
opts
:
FileOverwriteOptions
):
TPromise
<
void
>
;
$copy
(
handle
:
number
,
resource
:
UriComponents
,
target
:
UriComponents
,
opts
:
FileOverwriteOptions
):
TPromise
<
void
>
;
$mkdir
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
void
>
;
$mkdir
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
void
>
;
...
...
src/vs/workbench/api/node/extHostFileSystem.ts
浏览文件 @
acfadb48
...
@@ -159,16 +159,16 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
...
@@ -159,16 +159,16 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
return
asWinJsPromise
(()
=>
this
.
_fsProvider
.
get
(
handle
).
readDirectory
(
URI
.
revive
(
resource
)));
return
asWinJsPromise
(()
=>
this
.
_fsProvider
.
get
(
handle
).
readDirectory
(
URI
.
revive
(
resource
)));
}
}
$readFile
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
string
>
{
$readFile
(
handle
:
number
,
resource
:
UriComponents
):
TPromise
<
Buffer
>
{
return
asWinJsPromise
(()
=>
{
return
asWinJsPromise
(()
=>
{
return
this
.
_fsProvider
.
get
(
handle
).
readFile
(
URI
.
revive
(
resource
));
return
this
.
_fsProvider
.
get
(
handle
).
readFile
(
URI
.
revive
(
resource
));
}).
then
(
data
=>
{
}).
then
(
data
=>
{
return
Buffer
.
isBuffer
(
data
)
?
data
.
toString
(
'
base64
'
)
:
Buffer
.
from
(
data
.
buffer
,
data
.
byteOffset
,
data
.
byteLength
).
toString
(
'
base64
'
);
return
Buffer
.
isBuffer
(
data
)
?
data
:
Buffer
.
from
(
data
.
buffer
,
data
.
byteOffset
,
data
.
byteLength
);
});
});
}
}
$writeFile
(
handle
:
number
,
resource
:
UriComponents
,
base64Content
:
string
,
opts
:
files
.
FileWriteOptions
):
TPromise
<
void
>
{
$writeFile
(
handle
:
number
,
resource
:
UriComponents
,
content
:
Buffer
,
opts
:
files
.
FileWriteOptions
):
TPromise
<
void
>
{
return
asWinJsPromise
(()
=>
this
.
_fsProvider
.
get
(
handle
).
writeFile
(
URI
.
revive
(
resource
),
Buffer
.
from
(
base64Content
,
'
base64
'
)
,
opts
));
return
asWinJsPromise
(()
=>
this
.
_fsProvider
.
get
(
handle
).
writeFile
(
URI
.
revive
(
resource
),
content
,
opts
));
}
}
$delete
(
handle
:
number
,
resource
:
UriComponents
,
opts
:
files
.
FileDeleteOptions
):
TPromise
<
void
>
{
$delete
(
handle
:
number
,
resource
:
UriComponents
,
opts
:
files
.
FileDeleteOptions
):
TPromise
<
void
>
{
...
...
src/vs/workbench/services/extensions/electron-browser/extensionService.ts
浏览文件 @
acfadb48
...
@@ -39,7 +39,7 @@ import { Event, Emitter } from 'vs/base/common/event';
...
@@ -39,7 +39,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import
{
ExtensionHostProfiler
}
from
'
vs/workbench/services/extensions/electron-browser/extensionHostProfiler
'
;
import
{
ExtensionHostProfiler
}
from
'
vs/workbench/services/extensions/electron-browser/extensionHostProfiler
'
;
import
product
from
'
vs/platform/node/product
'
;
import
product
from
'
vs/platform/node/product
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
RPCProtocol
}
from
'
vs/workbench/services/extensions/node/rpcProtocol
'
;
import
{
RPCProtocol
,
IRPCProtocolLogger
}
from
'
vs/workbench/services/extensions/node/rpcProtocol
'
;
import
{
INotificationService
,
Severity
}
from
'
vs/platform/notification/common/notification
'
;
import
{
INotificationService
,
Severity
}
from
'
vs/platform/notification/common/notification
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
...
@@ -180,11 +180,12 @@ export class ExtensionHostProcessManager extends Disposable {
...
@@ -180,11 +180,12 @@ export class ExtensionHostProcessManager extends Disposable {
private
_createExtensionHostCustomers
(
protocol
:
IMessagePassingProtocol
):
ExtHostExtensionServiceShape
{
private
_createExtensionHostCustomers
(
protocol
:
IMessagePassingProtocol
):
ExtHostExtensionServiceShape
{
let
logger
:
IRPCProtocolLogger
=
null
;
if
(
logExtensionHostCommunication
||
this
.
_environmentService
.
logExtensionHostCommunication
)
{
if
(
logExtensionHostCommunication
||
this
.
_environmentService
.
logExtensionHostCommunication
)
{
protocol
=
asLoggingProtocol
(
protocol
);
logger
=
new
RPCLogger
(
);
}
}
this
.
_extensionHostProcessRPCProtocol
=
new
RPCProtocol
(
protocol
);
this
.
_extensionHostProcessRPCProtocol
=
new
RPCProtocol
(
protocol
,
logger
);
const
extHostContext
:
IExtHostContext
=
{
const
extHostContext
:
IExtHostContext
=
{
getProxy
:
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
=>
this
.
_extensionHostProcessRPCProtocol
.
getProxy
(
identifier
),
getProxy
:
<
T
>
(
identifier
:
ProxyIdentifier
<
T
>
):
T
=>
this
.
_extensionHostProcessRPCProtocol
.
getProxy
(
identifier
),
set
:
<
T
,
R
extends
T
>
(
identifier
:
ProxyIdentifier
<
T
>
,
instance
:
R
):
R
=>
this
.
_extensionHostProcessRPCProtocol
.
set
(
identifier
,
instance
),
set
:
<
T
,
R
extends
T
>
(
identifier
:
ProxyIdentifier
<
T
>
,
instance
:
R
):
R
=>
this
.
_extensionHostProcessRPCProtocol
.
set
(
identifier
,
instance
),
...
@@ -954,20 +955,20 @@ export class ExtensionService extends Disposable implements IExtensionService {
...
@@ -954,20 +955,20 @@ export class ExtensionService extends Disposable implements IExtensionService {
}
}
}
}
function
asLoggingProtocol
(
protocol
:
IMessagePassingProtocol
):
IMessagePassingProtocol
{
class
RPCLogger
implements
IRPCProtocolLogger
{
protocol
.
onMessage
(
msg
=>
{
private
_totalIncoming
=
0
;
console
.
log
(
'
%c[Extension
\
u2192 Window]%c[len:
'
+
strings
.
pad
(
msg
.
length
,
5
,
'
'
)
+
'
]
'
,
'
color: darkgreen
'
,
'
color: grey
'
,
msg
);
private
_totalOutgoing
=
0
;
});
return
{
logIncoming
(
msgLength
:
number
,
str
:
string
,
data
?:
any
):
void
{
onMessage
:
protocol
.
onMessage
,
this
.
_totalIncoming
+=
msgLength
;
console
.
log
(
`%c[Extension \u2192 Window]%c[
${
strings
.
pad
(
this
.
_totalIncoming
,
7
,
'
'
)}
]%c[len:
${
strings
.
pad
(
msgLength
,
5
,
'
'
)}
]`
,
'
color: darkgreen
'
,
'
color: grey
'
,
'
color: grey
'
,
str
,
data
);
}
send
(
msg
:
any
)
{
logOutgoing
(
msgLength
:
number
,
str
:
string
,
data
?:
any
):
void
{
protocol
.
send
(
msg
)
;
this
.
_totalOutgoing
+=
msgLength
;
console
.
log
(
'
%c[Window
\
u2192 Extension]%c[len:
'
+
strings
.
pad
(
msg
.
length
,
5
,
'
'
)
+
'
]
'
,
'
color: darkgreen
'
,
'
color: grey
'
,
msg
);
console
.
log
(
`%c[Window \u2192 Extension]%c[
${
strings
.
pad
(
this
.
_totalOutgoing
,
7
,
'
'
)}
]%c[len:
${
strings
.
pad
(
msgLength
,
5
,
'
'
)}
]`
,
'
color: darkgreen
'
,
'
color: grey
'
,
'
color: grey
'
,
str
,
data
);
}
}
};
}
}
interface
IExtensionCacheData
{
interface
IExtensionCacheData
{
...
...
src/vs/workbench/services/extensions/node/rpcProtocol.ts
浏览文件 @
acfadb48
此差异已折叠。
点击以展开。
src/vs/workbench/services/extensions/test/node/rpcProtocol.test.ts
0 → 100644
浏览文件 @
acfadb48
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
RPCProtocol
}
from
'
vs/workbench/services/extensions/node/rpcProtocol
'
;
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/node/ipc
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ProxyIdentifier
}
from
'
vs/workbench/services/extensions/node/proxyIdentifier
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
suite
(
'
RPCProtocol
'
,
()
=>
{
class
MessagePassingProtocol
implements
IMessagePassingProtocol
{
private
_pair
:
MessagePassingProtocol
;
private
readonly
_onMessage
:
Emitter
<
Buffer
>
=
new
Emitter
<
Buffer
>
();
public
readonly
onMessage
:
Event
<
Buffer
>
=
this
.
_onMessage
.
event
;
public
setPair
(
other
:
MessagePassingProtocol
)
{
this
.
_pair
=
other
;
}
public
send
(
buffer
:
Buffer
):
void
{
process
.
nextTick
(()
=>
{
this
.
_pair
.
_onMessage
.
fire
(
buffer
);
});
}
}
let
delegate
:
(
a1
:
any
,
a2
:
any
)
=>
any
;
let
bProxy
:
BClass
;
class
BClass
{
$m
(
a1
:
any
,
a2
:
any
):
TPromise
<
any
>
{
return
TPromise
.
as
(
delegate
.
call
(
null
,
a1
,
a2
));
}
}
setup
(()
=>
{
let
a_protocol
=
new
MessagePassingProtocol
();
let
b_protocol
=
new
MessagePassingProtocol
();
a_protocol
.
setPair
(
b_protocol
);
b_protocol
.
setPair
(
a_protocol
);
let
A
=
new
RPCProtocol
(
a_protocol
);
let
B
=
new
RPCProtocol
(
b_protocol
);
delegate
=
null
;
const
bIdentifier
=
new
ProxyIdentifier
<
BClass
>
(
false
,
'
bb
'
);
const
bInstance
=
new
BClass
();
B
.
set
(
bIdentifier
,
bInstance
);
bProxy
=
A
.
getProxy
(
bIdentifier
);
});
test
(
'
simple call
'
,
function
(
done
)
{
delegate
=
(
a1
:
number
,
a2
:
number
)
=>
a1
+
a2
;
bProxy
.
$m
(
4
,
1
).
then
((
res
:
number
)
=>
{
assert
.
equal
(
res
,
5
);
done
(
null
);
},
done
);
});
test
(
'
simple call without result
'
,
function
(
done
)
{
delegate
=
(
a1
:
number
,
a2
:
number
)
=>
{
};
bProxy
.
$m
(
4
,
1
).
then
((
res
:
number
)
=>
{
assert
.
equal
(
res
,
undefined
);
done
(
null
);
},
done
);
});
test
(
'
passing buffer as argument
'
,
function
(
done
)
{
delegate
=
(
a1
:
Buffer
,
a2
:
number
)
=>
{
assert
.
ok
(
Buffer
.
isBuffer
(
a1
));
return
a1
[
a2
];
};
let
b
=
Buffer
.
allocUnsafe
(
4
);
b
[
0
]
=
1
;
b
[
1
]
=
2
;
b
[
2
]
=
3
;
b
[
3
]
=
4
;
bProxy
.
$m
(
b
,
2
).
then
((
res
:
number
)
=>
{
assert
.
equal
(
res
,
3
);
done
(
null
);
},
done
);
});
test
(
'
returning a buffer
'
,
function
(
done
)
{
delegate
=
(
a1
:
number
,
a2
:
number
)
=>
{
let
b
=
Buffer
.
allocUnsafe
(
4
);
b
[
0
]
=
1
;
b
[
1
]
=
2
;
b
[
2
]
=
3
;
b
[
3
]
=
4
;
return
b
;
};
bProxy
.
$m
(
4
,
1
).
then
((
res
:
Buffer
)
=>
{
assert
.
ok
(
Buffer
.
isBuffer
(
res
));
assert
.
equal
(
res
[
0
],
1
);
assert
.
equal
(
res
[
1
],
2
);
assert
.
equal
(
res
[
2
],
3
);
assert
.
equal
(
res
[
3
],
4
);
done
(
null
);
},
done
);
});
test
(
'
cancelling a call
'
,
function
()
{
delegate
=
(
a1
:
number
,
a2
:
number
)
=>
a1
+
a2
;
let
p
=
bProxy
.
$m
(
4
,
1
);
p
.
then
((
res
:
number
)
=>
{
assert
.
fail
(
'
should not receive result
'
);
});
p
.
cancel
();
});
test
(
'
throwing an error
'
,
function
(
done
)
{
delegate
=
(
a1
:
number
,
a2
:
number
)
=>
{
throw
new
Error
(
`nope`
);
};
bProxy
.
$m
(
4
,
1
).
then
((
res
)
=>
{
assert
.
fail
(
'
unexpected
'
);
done
(
null
);
},
(
err
)
=>
{
assert
.
equal
(
err
.
message
,
'
nope
'
);
done
(
null
);
});
});
test
(
'
error promise
'
,
function
(
done
)
{
delegate
=
(
a1
:
number
,
a2
:
number
)
=>
{
return
TPromise
.
wrapError
(
undefined
);
};
bProxy
.
$m
(
4
,
1
).
then
((
res
)
=>
{
assert
.
fail
(
'
unexpected
'
);
done
(
null
);
},
(
err
)
=>
{
assert
.
equal
(
err
,
undefined
);
done
(
null
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录