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

Unified Diff: content/renderer/websharedworker_proxy.cc

Issue 2607753002: SharedWorker: Make sure route_id is always valid in WebSharedWorkerProxy (Closed)
Patch Set: Created 4 years 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/websharedworker_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/websharedworker_proxy.cc
diff --git a/content/renderer/websharedworker_proxy.cc b/content/renderer/websharedworker_proxy.cc
index 880a6960762858c227ef8d7b65b1d89fcca3c193..8dd71b8ccfc172be63127d7f0997b6b4394dfdb7 100644
--- a/content/renderer/websharedworker_proxy.cc
+++ b/content/renderer/websharedworker_proxy.cc
@@ -21,30 +21,17 @@ WebSharedWorkerProxy::WebSharedWorkerProxy(IPC::MessageRouter* router,
router_(router),
connect_listener_(nullptr),
created_(false) {
+ DCHECK_NE(MSG_ROUTING_NONE, route_id_);
router_->AddRoute(route_id_, this);
}
WebSharedWorkerProxy::~WebSharedWorkerProxy() {
- Disconnect();
-}
-
-void WebSharedWorkerProxy::Disconnect() {
- if (route_id_ == MSG_ROUTING_NONE)
- return;
-
- // So the messages from WorkerContext (like WorkerContextDestroyed) do not
- // come after nobody is listening. Since Worker and WorkerContext can
- // terminate independently, already sent messages may still be in the pipe.
router_->RemoveRoute(route_id_);
-
- route_id_ = MSG_ROUTING_NONE;
}
bool WebSharedWorkerProxy::Send(std::unique_ptr<IPC::Message> message) {
- // It's possible that messages will be sent before the worker is created, in
- // which case route_id_ will be none. Or the worker object can be interacted
- // with before the browser process told us that it started, in which case we
- // also want to queue the message.
+ // The worker object can be interacted with before the browser process told us
+ // that it started, in which case we want to queue the message.
if (!created_) {
queued_messages_.push_back(std::move(message));
return true;
@@ -96,8 +83,7 @@ bool WebSharedWorkerProxy::OnMessageReceived(const IPC::Message& message) {
void WebSharedWorkerProxy::OnWorkerCreated() {
created_ = true;
- // The worker is created - now send off the WorkerMsg_Connect message and
- // any other queued messages
+ // The worker is created - now send off the WorkerMsg_Connect message.
SendQueuedMessages();
}
« no previous file with comments | « content/renderer/websharedworker_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698