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

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

Issue 1110103003: Initial implementation of stashed message ports, content side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nicer dchecks Created 5 years, 7 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
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 "base/values.h" 9 #include "base/values.h"
10 #include "content/child/child_process.h" 10 #include "content/child/child_process.h"
(...skipping 11 matching lines...) Expand all
22 using blink::WebString; 22 using blink::WebString;
23 23
24 namespace content { 24 namespace content {
25 25
26 WebMessagePortChannelImpl::WebMessagePortChannelImpl( 26 WebMessagePortChannelImpl::WebMessagePortChannelImpl(
27 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner) 27 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner)
28 : client_(NULL), 28 : client_(NULL),
29 route_id_(MSG_ROUTING_NONE), 29 route_id_(MSG_ROUTING_NONE),
30 message_port_id_(MSG_ROUTING_NONE), 30 message_port_id_(MSG_ROUTING_NONE),
31 send_messages_as_values_(false), 31 send_messages_as_values_(false),
32 is_stashed_(false),
32 main_thread_task_runner_(main_thread_task_runner) { 33 main_thread_task_runner_(main_thread_task_runner) {
33 AddRef(); 34 AddRef();
34 Init(); 35 Init();
35 } 36 }
36 37
37 WebMessagePortChannelImpl::WebMessagePortChannelImpl( 38 WebMessagePortChannelImpl::WebMessagePortChannelImpl(
38 int route_id, 39 int route_id,
39 const TransferredMessagePort& port, 40 const TransferredMessagePort& port,
40 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner) 41 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner)
41 : client_(NULL), 42 : client_(NULL),
42 route_id_(route_id), 43 route_id_(route_id),
43 message_port_id_(port.id), 44 message_port_id_(port.id),
44 send_messages_as_values_(port.send_messages_as_values), 45 send_messages_as_values_(port.send_messages_as_values),
46 is_stashed_(false),
45 main_thread_task_runner_(main_thread_task_runner) { 47 main_thread_task_runner_(main_thread_task_runner) {
46 AddRef(); 48 AddRef();
47 Init(); 49 Init();
48 } 50 }
49 51
50 WebMessagePortChannelImpl::~WebMessagePortChannelImpl() { 52 WebMessagePortChannelImpl::~WebMessagePortChannelImpl() {
51 // If we have any queued messages with attached ports, manually destroy them. 53 // If we have any queued messages with attached ports, manually destroy them.
52 while (!message_queue_.empty()) { 54 while (!message_queue_.empty()) {
53 const WebMessagePortChannelArray& channel_array = 55 const WebMessagePortChannelArray& channel_array =
54 message_queue_.front().ports; 56 message_queue_.front().ports;
55 for (size_t i = 0; i < channel_array.size(); i++) { 57 for (size_t i = 0; i < channel_array.size(); i++) {
56 channel_array[i]->destroy(); 58 channel_array[i]->destroy();
57 } 59 }
58 message_queue_.pop(); 60 message_queue_.pop();
59 } 61 }
60 62
61 if (message_port_id_ != MSG_ROUTING_NONE) 63 // TODO(mek): Figure out if in case of a stashed port any messages remaining
64 // in the queue need to be send back to the browser process.
65 if (message_port_id_ != MSG_ROUTING_NONE && !is_stashed_)
62 Send(new MessagePortHostMsg_DestroyMessagePort(message_port_id_)); 66 Send(new MessagePortHostMsg_DestroyMessagePort(message_port_id_));
63 67
64 if (route_id_ != MSG_ROUTING_NONE) 68 if (route_id_ != MSG_ROUTING_NONE)
65 ChildThreadImpl::current()->GetRouter()->RemoveRoute(route_id_); 69 ChildThreadImpl::current()->GetRouter()->RemoveRoute(route_id_);
66 } 70 }
67 71
68 // static 72 // static
69 void WebMessagePortChannelImpl::CreatePair( 73 void WebMessagePortChannelImpl::CreatePair(
70 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, 74 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner,
71 blink::WebMessagePortChannel** channel1, 75 blink::WebMessagePortChannel** channel1,
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 324
321 Release(); 325 Release();
322 ChildProcess::current()->ReleaseProcess(); 326 ChildProcess::current()->ReleaseProcess();
323 } 327 }
324 328
325 WebMessagePortChannelImpl::Message::Message() {} 329 WebMessagePortChannelImpl::Message::Message() {}
326 330
327 WebMessagePortChannelImpl::Message::~Message() {} 331 WebMessagePortChannelImpl::Message::~Message() {}
328 332
329 } // namespace content 333 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | content/common/service_worker/service_worker_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698