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

Unified Diff: content/renderer/shared_worker/websharedworker_proxy.cc

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Add missing ScopedAsyncTaskScheduler instance for the new unit tests; required by a recent change t… Created 3 years, 10 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/renderer/shared_worker/websharedworker_proxy.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/shared_worker/websharedworker_proxy.cc
diff --git a/content/renderer/shared_worker/websharedworker_proxy.cc b/content/renderer/shared_worker/websharedworker_proxy.cc
index e29fa0b2d3332ea48f7fda14611635b7abd9c81d..c0c412fd5c5781c0101e1f1657d19904b83d74f6 100644
--- a/content/renderer/shared_worker/websharedworker_proxy.cc
+++ b/content/renderer/shared_worker/websharedworker_proxy.cc
@@ -9,7 +9,6 @@
#include "content/child/child_thread_impl.h"
#include "content/child/webmessageportchannel_impl.h"
#include "content/common/view_messages.h"
-#include "content/common/worker_messages.h"
#include "ipc/message_router.h"
namespace content {
@@ -20,7 +19,6 @@ WebSharedWorkerProxy::WebSharedWorkerProxy(
blink::WebMessagePortChannel* channel)
: route_id_(MSG_ROUTING_NONE),
router_(ChildThreadImpl::current()->GetRouter()),
- message_port_id_(MSG_ROUTING_NONE),
listener_(std::move(listener)) {
connect(params, channel);
}
@@ -40,14 +38,11 @@ void WebSharedWorkerProxy::connect(ViewHostMsg_CreateWorker_Params params,
router_->AddRoute(route_id_, this);
listener_->workerCreated(reply.error);
- DCHECK_EQ(MSG_ROUTING_NONE, message_port_id_);
- WebMessagePortChannelImpl* webchannel =
- static_cast<WebMessagePortChannelImpl*>(channel);
- message_port_id_ = webchannel->message_port_id();
- DCHECK_NE(MSG_ROUTING_NONE, message_port_id_);
- webchannel->QueueMessages();
- // |webchannel| is intentionally leaked here: it'll be removed at
- // WebMessagePortChannelImpl::OnMessagesQueued().
+ // Accept ownership of the channel.
+ std::unique_ptr<WebMessagePortChannelImpl> channel_impl(
+ static_cast<WebMessagePortChannelImpl*>(channel));
+
+ message_port_ = channel_impl->ReleaseMessagePort();
// An actual connection request will be issued on OnWorkerCreated().
}
@@ -68,9 +63,10 @@ bool WebSharedWorkerProxy::OnMessageReceived(const IPC::Message& message) {
}
void WebSharedWorkerProxy::OnWorkerCreated() {
- // The worker is created - now send off the connection request.
- router_->Send(
- new ViewHostMsg_ConnectToWorker(route_id_, message_port_id_));
+ DCHECK(message_port_.GetHandle().is_valid());
+
+ // The worker is created - now send off the connect message.
+ router_->Send(new ViewHostMsg_ConnectToWorker(route_id_, message_port_));
}
void WebSharedWorkerProxy::OnWorkerScriptLoadFailed() {
« no previous file with comments | « content/renderer/shared_worker/websharedworker_proxy.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698