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

Side by Side Diff: content/child/webmessageportchannel_impl.cc

Issue 203073005: (NOT READY FOR REVIEW) Introduce MessagePortBypassFilter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/webmessageportchannel_impl.h" 5 #include "content/child/webmessageportchannel_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "content/child/child_process.h" 9 #include "content/child/child_process.h"
10 #include "content/child/child_thread.h" 10 #include "content/child/child_thread.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (route_id_ != MSG_ROUTING_NONE) 58 if (route_id_ != MSG_ROUTING_NONE)
59 ChildThread::current()->GetRouter()->RemoveRoute(route_id_); 59 ChildThread::current()->GetRouter()->RemoveRoute(route_id_);
60 } 60 }
61 61
62 void WebMessagePortChannelImpl::setClient(WebMessagePortChannelClient* client) { 62 void WebMessagePortChannelImpl::setClient(WebMessagePortChannelClient* client) {
63 // Must lock here since client_ is called on the main thread. 63 // Must lock here since client_ is called on the main thread.
64 base::AutoLock auto_lock(lock_); 64 base::AutoLock auto_lock(lock_);
65 client_ = client; 65 client_ = client;
66 } 66 }
67 67
68 void WebMessagePortChannelImpl::OnRouteRemoved() {
69 child_thread_loop_->ReleaseSoon(FROM_HERE, this);
70 }
71
68 void WebMessagePortChannelImpl::destroy() { 72 void WebMessagePortChannelImpl::destroy() {
73 if (!child_thread_loop_->BelongsToCurrentThread()) {
74 child_thread_loop_->PostTask(
75 FROM_HERE, base::Bind(&WebMessagePortChannelImpl::destroy, this));
76 return;
77 }
69 setClient(NULL); 78 setClient(NULL);
70 79
80 if (route_id_ != MSG_ROUTING_NONE) {
81 ChildThread::current()->message_port_bypass_filter()->RemoveRoute(
82 route_id_,
83 base::Bind(&WebMessagePortChannelImpl::OnRouteRemoved, this));
84 return;
85 }
71 // Release the object on the main thread, since the destructor might want to 86 // Release the object on the main thread, since the destructor might want to
72 // send an IPC, and that has to happen on the main thread. 87 // send an IPC, and that has to happen on the main thread.
73 child_thread_loop_->ReleaseSoon(FROM_HERE, this); 88 child_thread_loop_->ReleaseSoon(FROM_HERE, this);
74 } 89 }
75 90
76 void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) { 91 void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) {
77 // The message port ids might not be set up yet, if this channel wasn't 92 // The message port ids might not be set up yet, if this channel wasn't
78 // created on the main thread. So need to wait until we're on the main thread 93 // created on the main thread. So need to wait until we're on the main thread
79 // before getting the other message port id. 94 // before getting the other message port id.
80 scoped_refptr<WebMessagePortChannelImpl> webchannel( 95 scoped_refptr<WebMessagePortChannelImpl> webchannel(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 FROM_HERE, base::Bind(&WebMessagePortChannelImpl::Init, this)); 157 FROM_HERE, base::Bind(&WebMessagePortChannelImpl::Init, this));
143 return; 158 return;
144 } 159 }
145 160
146 if (route_id_ == MSG_ROUTING_NONE) { 161 if (route_id_ == MSG_ROUTING_NONE) {
147 DCHECK(message_port_id_ == MSG_ROUTING_NONE); 162 DCHECK(message_port_id_ == MSG_ROUTING_NONE);
148 Send(new MessagePortHostMsg_CreateMessagePort( 163 Send(new MessagePortHostMsg_CreateMessagePort(
149 &route_id_, &message_port_id_)); 164 &route_id_, &message_port_id_));
150 } 165 }
151 166
167 ChildThread::current()->message_port_bypass_filter()->AddRoute(route_id_,
168 this);
152 ChildThread::current()->GetRouter()->AddRoute(route_id_, this); 169 ChildThread::current()->GetRouter()->AddRoute(route_id_, this);
153 } 170 }
154 171
155 void WebMessagePortChannelImpl::Entangle( 172 void WebMessagePortChannelImpl::Entangle(
156 scoped_refptr<WebMessagePortChannelImpl> channel) { 173 scoped_refptr<WebMessagePortChannelImpl> channel) {
157 if (!child_thread_loop_->BelongsToCurrentThread()) { 174 if (!child_thread_loop_->BelongsToCurrentThread()) {
158 child_thread_loop_->PostTask( 175 child_thread_loop_->PostTask(
159 FROM_HERE, 176 FROM_HERE,
160 base::Bind(&WebMessagePortChannelImpl::Entangle, this, channel)); 177 base::Bind(&WebMessagePortChannelImpl::Entangle, this, channel));
161 return; 178 return;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 272
256 Release(); 273 Release();
257 ChildProcess::current()->ReleaseProcess(); 274 ChildProcess::current()->ReleaseProcess();
258 } 275 }
259 276
260 WebMessagePortChannelImpl::Message::Message() {} 277 WebMessagePortChannelImpl::Message::Message() {}
261 278
262 WebMessagePortChannelImpl::Message::~Message() {} 279 WebMessagePortChannelImpl::Message::~Message() {}
263 280
264 } // namespace content 281 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698