Index: content/child/webmessageportchannel_impl.cc |
diff --git a/content/child/webmessageportchannel_impl.cc b/content/child/webmessageportchannel_impl.cc |
index cf439cc0742851de8270d70f228bf20b1e86f20c..808bda5869ca363e417af0796ed2b5f1712db2d3 100644 |
--- a/content/child/webmessageportchannel_impl.cc |
+++ b/content/child/webmessageportchannel_impl.cc |
@@ -65,9 +65,24 @@ void WebMessagePortChannelImpl::setClient(WebMessagePortChannelClient* client) { |
client_ = client; |
} |
+void WebMessagePortChannelImpl::OnRouteRemoved() { |
+ child_thread_loop_->ReleaseSoon(FROM_HERE, this); |
+} |
+ |
void WebMessagePortChannelImpl::destroy() { |
+ if (!child_thread_loop_->BelongsToCurrentThread()) { |
+ child_thread_loop_->PostTask( |
+ FROM_HERE, base::Bind(&WebMessagePortChannelImpl::destroy, this)); |
+ return; |
+ } |
setClient(NULL); |
+ if (route_id_ != MSG_ROUTING_NONE) { |
+ ChildThread::current()->message_port_bypass_filter()->RemoveRoute( |
+ route_id_, |
+ base::Bind(&WebMessagePortChannelImpl::OnRouteRemoved, this)); |
+ return; |
+ } |
// Release the object on the main thread, since the destructor might want to |
// send an IPC, and that has to happen on the main thread. |
child_thread_loop_->ReleaseSoon(FROM_HERE, this); |
@@ -149,6 +164,8 @@ void WebMessagePortChannelImpl::Init() { |
&route_id_, &message_port_id_)); |
} |
+ ChildThread::current()->message_port_bypass_filter()->AddRoute(route_id_, |
+ this); |
ChildThread::current()->GetRouter()->AddRoute(route_id_, this); |
} |