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

Unified Diff: content/renderer/shared_worker/embedded_shared_worker_stub.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
Index: content/renderer/shared_worker/embedded_shared_worker_stub.cc
diff --git a/content/renderer/shared_worker/embedded_shared_worker_stub.cc b/content/renderer/shared_worker/embedded_shared_worker_stub.cc
index 60a035f955b96d00d24b277f40ffc1adaf746f09..b0ac6424920b16c963ed56cec421af72f3e9439c 100644
--- a/content/renderer/shared_worker/embedded_shared_worker_stub.cc
+++ b/content/renderer/shared_worker/embedded_shared_worker_stub.cc
@@ -189,22 +189,13 @@ void EmbeddedSharedWorkerStub::workerScriptLoaded() {
Send(new WorkerHostMsg_WorkerScriptLoaded(route_id_));
running_ = true;
// Process any pending connections.
- for (PendingChannelList::const_iterator iter = pending_channels_.begin();
- iter != pending_channels_.end();
- ++iter) {
- ConnectToChannel(*iter);
- }
+ for (auto& item : pending_channels_)
+ ConnectToChannel(item.first, std::move(item.second));
pending_channels_.clear();
}
void EmbeddedSharedWorkerStub::workerScriptLoadFailed() {
Send(new WorkerHostMsg_WorkerScriptLoadFailed(route_id_));
- for (PendingChannelList::const_iterator iter = pending_channels_.begin();
- iter != pending_channels_.end();
- ++iter) {
- blink::WebMessagePortChannel* channel = *iter;
- channel->destroy();
- }
pending_channels_.clear();
Shutdown();
}
@@ -301,24 +292,24 @@ bool EmbeddedSharedWorkerStub::Send(IPC::Message* message) {
}
void EmbeddedSharedWorkerStub::ConnectToChannel(
- WebMessagePortChannelImpl* channel) {
- impl_->connect(channel);
- Send(
- new WorkerHostMsg_WorkerConnected(channel->message_port_id(), route_id_));
+ int connection_request_id,
+ std::unique_ptr<WebMessagePortChannelImpl> channel) {
+ impl_->connect(channel.release());
+ Send(new WorkerHostMsg_WorkerConnected(connection_request_id, route_id_));
}
-void EmbeddedSharedWorkerStub::OnConnect(int port,
- int routing_id) {
- WebMessagePortChannelImpl* channel = new WebMessagePortChannelImpl(
- routing_id, port, base::ThreadTaskRunnerHandle::Get().get());
+void EmbeddedSharedWorkerStub::OnConnect(int connection_request_id,
+ const MessagePort& port) {
+ auto channel = base::MakeUnique<WebMessagePortChannelImpl>(port);
if (running_) {
- ConnectToChannel(channel);
+ ConnectToChannel(connection_request_id, std::move(channel));
} else {
// If two documents try to load a SharedWorker at the same time, the
// WorkerMsg_Connect for one of the documents can come in before the
// worker is started. Just queue up the connect and deliver it once the
// worker starts.
- pending_channels_.push_back(channel);
+ pending_channels_.emplace_back(
+ std::make_pair(connection_request_id, std::move(channel)));
}
}
« no previous file with comments | « content/renderer/shared_worker/embedded_shared_worker_stub.h ('k') | content/renderer/shared_worker/websharedworker_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698