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

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

Issue 230183002: Remove unnecessary Platform::createMessagePortChannel method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 if (message_port_id_ != MSG_ROUTING_NONE) 55 if (message_port_id_ != MSG_ROUTING_NONE)
56 Send(new MessagePortHostMsg_DestroyMessagePort(message_port_id_)); 56 Send(new MessagePortHostMsg_DestroyMessagePort(message_port_id_));
57 57
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 // static 62 // static
63 void WebMessagePortChannelImpl::CreatePair(
64 base::MessageLoopProxy* child_thread_loop,
65 blink::WebMessagePortChannel** channel1,
66 blink::WebMessagePortChannel** channel2) {
67 WebMessagePortChannelImpl* impl1 =
68 new WebMessagePortChannelImpl(child_thread_loop);
69 WebMessagePortChannelImpl* impl2 =
70 new WebMessagePortChannelImpl(child_thread_loop);
71
72 impl1->Entangle(impl2);
73 impl2->Entangle(impl1);
74
75 *channel1 = impl1;
76 *channel2 = impl2;
77 }
78
79 // static
63 std::vector<int> WebMessagePortChannelImpl::ExtractMessagePortIDs( 80 std::vector<int> WebMessagePortChannelImpl::ExtractMessagePortIDs(
64 WebMessagePortChannelArray* channels) { 81 WebMessagePortChannelArray* channels) {
65 std::vector<int> message_port_ids; 82 std::vector<int> message_port_ids;
66 if (channels) { 83 if (channels) {
67 message_port_ids.resize(channels->size()); 84 message_port_ids.resize(channels->size());
68 // Extract the port IDs from the source array, then free it. 85 // Extract the port IDs from the source array, then free it.
69 for (size_t i = 0; i < channels->size(); ++i) { 86 for (size_t i = 0; i < channels->size(); ++i) {
70 WebMessagePortChannelImpl* webchannel = 87 WebMessagePortChannelImpl* webchannel =
71 static_cast<WebMessagePortChannelImpl*>((*channels)[i]); 88 static_cast<WebMessagePortChannelImpl*>((*channels)[i]);
72 message_port_ids[i] = webchannel->message_port_id(); 89 message_port_ids[i] = webchannel->message_port_id();
(...skipping 13 matching lines...) Expand all
86 103
87 void WebMessagePortChannelImpl::destroy() { 104 void WebMessagePortChannelImpl::destroy() {
88 setClient(NULL); 105 setClient(NULL);
89 106
90 // Release the object on the main thread, since the destructor might want to 107 // Release the object on the main thread, since the destructor might want to
91 // send an IPC, and that has to happen on the main thread. 108 // send an IPC, and that has to happen on the main thread.
92 child_thread_loop_->ReleaseSoon(FROM_HERE, this); 109 child_thread_loop_->ReleaseSoon(FROM_HERE, this);
93 } 110 }
94 111
95 void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) { 112 void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) {
96 // The message port ids might not be set up yet, if this channel wasn't 113 NOTREACHED(); // DEPRECATED
97 // created on the main thread. So need to wait until we're on the main thread
98 // before getting the other message port id.
99 scoped_refptr<WebMessagePortChannelImpl> webchannel(
100 static_cast<WebMessagePortChannelImpl*>(channel));
101 Entangle(webchannel);
102 } 114 }
103 115
104 void WebMessagePortChannelImpl::postMessage( 116 void WebMessagePortChannelImpl::postMessage(
105 const WebString& message, 117 const WebString& message,
106 WebMessagePortChannelArray* channels) { 118 WebMessagePortChannelArray* channels) {
107 if (!child_thread_loop_->BelongsToCurrentThread()) { 119 if (!child_thread_loop_->BelongsToCurrentThread()) {
108 child_thread_loop_->PostTask( 120 child_thread_loop_->PostTask(
109 FROM_HERE, 121 FROM_HERE,
110 base::Bind( 122 base::Bind(
111 &WebMessagePortChannelImpl::PostMessage, this, message, channels)); 123 &WebMessagePortChannelImpl::PostMessage, this, message, channels));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 DCHECK(message_port_id_ == MSG_ROUTING_NONE); 165 DCHECK(message_port_id_ == MSG_ROUTING_NONE);
154 Send(new MessagePortHostMsg_CreateMessagePort( 166 Send(new MessagePortHostMsg_CreateMessagePort(
155 &route_id_, &message_port_id_)); 167 &route_id_, &message_port_id_));
156 } 168 }
157 169
158 ChildThread::current()->GetRouter()->AddRoute(route_id_, this); 170 ChildThread::current()->GetRouter()->AddRoute(route_id_, this);
159 } 171 }
160 172
161 void WebMessagePortChannelImpl::Entangle( 173 void WebMessagePortChannelImpl::Entangle(
162 scoped_refptr<WebMessagePortChannelImpl> channel) { 174 scoped_refptr<WebMessagePortChannelImpl> channel) {
175 // The message port ids might not be set up yet, if this channel wasn't
176 // created on the main thread. So need to wait until we're on the main thread
177 // before getting the other message port id.
163 if (!child_thread_loop_->BelongsToCurrentThread()) { 178 if (!child_thread_loop_->BelongsToCurrentThread()) {
164 child_thread_loop_->PostTask( 179 child_thread_loop_->PostTask(
165 FROM_HERE, 180 FROM_HERE,
166 base::Bind(&WebMessagePortChannelImpl::Entangle, this, channel)); 181 base::Bind(&WebMessagePortChannelImpl::Entangle, this, channel));
167 return; 182 return;
168 } 183 }
169 184
170 Send(new MessagePortHostMsg_Entangle( 185 Send(new MessagePortHostMsg_Entangle(
171 message_port_id_, channel->message_port_id())); 186 message_port_id_, channel->message_port_id()));
172 } 187 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 276
262 Release(); 277 Release();
263 ChildProcess::current()->ReleaseProcess(); 278 ChildProcess::current()->ReleaseProcess();
264 } 279 }
265 280
266 WebMessagePortChannelImpl::Message::Message() {} 281 WebMessagePortChannelImpl::Message::Message() {}
267 282
268 WebMessagePortChannelImpl::Message::~Message() {} 283 WebMessagePortChannelImpl::Message::~Message() {}
269 284
270 } // namespace content 285 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698