Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1455)

Unified Diff: content/child/webmessageportchannel_impl.cc

Issue 2755223002: Enable Blink to pass extra Mojo handles across MessagePorts
Patch Set: Finish plumbing Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | content/common/message_port.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webmessageportchannel_impl.cc
diff --git a/content/child/webmessageportchannel_impl.cc b/content/child/webmessageportchannel_impl.cc
index 3c5e8d90ed75c5523c12f432d50589b24f897a5d..77ce5e065d08f6fcf19982aad4472419c27411f8 100644
--- a/content/child/webmessageportchannel_impl.cc
+++ b/content/child/webmessageportchannel_impl.cc
@@ -16,6 +16,7 @@ using blink::WebMessagePortChannel;
using blink::WebMessagePortChannelArray;
using blink::WebMessagePortChannelClient;
using blink::WebString;
+using blink::WebVector;
namespace content {
@@ -94,7 +95,8 @@ void WebMessagePortChannelImpl::setClient(WebMessagePortChannelClient* client) {
void WebMessagePortChannelImpl::postMessage(
const WebString& encoded_message,
- WebMessagePortChannelArray channels) {
+ WebMessagePortChannelArray channels,
+ WebVector<mojo::ScopedHandle> handles) {
std::vector<MessagePort> ports;
if (!channels.isEmpty()) {
ports.resize(channels.size());
@@ -103,15 +105,21 @@ void WebMessagePortChannelImpl::postMessage(
ReleaseMessagePort();
}
}
- port_.PostMessage(encoded_message.utf16(), std::move(ports));
+ std::vector<mojo::ScopedHandle> extra_handles;
+ for (size_t i = 0; i < handles.size(); ++i)
+ extra_handles.emplace_back(std::move(handles[i]));
+ port_.PostMessage(encoded_message.utf16(), std::move(ports),
+ std::move(extra_handles));
}
bool WebMessagePortChannelImpl::tryGetMessage(
WebString* encoded_message,
- WebMessagePortChannelArray& channels) {
+ WebMessagePortChannelArray& channels,
+ WebVector<mojo::ScopedHandle>& handles) {
base::string16 buffer;
std::vector<MessagePort> ports;
- if (!port_.GetMessage(&buffer, &ports))
+ std::vector<mojo::ScopedHandle> extra_handles;
+ if (!port_.GetMessage(&buffer, &ports, &extra_handles))
return false;
*encoded_message = WebString::fromUTF16(buffer);
@@ -121,6 +129,11 @@ bool WebMessagePortChannelImpl::tryGetMessage(
for (size_t i = 0; i < ports.size(); ++i)
channels[i] = base::MakeUnique<WebMessagePortChannelImpl>(ports[i]);
}
+ if (!extra_handles.empty()) {
+ handles = WebVector<mojo::ScopedHandle>(extra_handles.size());
+ for (size_t i = 0; i < extra_handles.size(); ++i)
+ handles[i] = std::move(extra_handles[i]);
+ }
return true;
}
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | content/common/message_port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698