OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/message_port_service.h" | 5 #include "content/browser/message_port_service.h" |
6 | 6 |
7 #include "content/common/message_port_messages.h" | 7 #include "content/common/message_port_messages.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/message_port_delegate.h" | 9 #include "content/public/browser/message_port_delegate.h" |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 DCHECK(message_ports_[remote_message_port_id].entangled_message_port_id == | 124 DCHECK(message_ports_[remote_message_port_id].entangled_message_port_id == |
125 MSG_ROUTING_NONE); | 125 MSG_ROUTING_NONE); |
126 message_ports_[remote_message_port_id].entangled_message_port_id = | 126 message_ports_[remote_message_port_id].entangled_message_port_id = |
127 local_message_port_id; | 127 local_message_port_id; |
128 } | 128 } |
129 | 129 |
130 void MessagePortService::PostMessage( | 130 void MessagePortService::PostMessage( |
131 int sender_message_port_id, | 131 int sender_message_port_id, |
132 const base::string16& message, | 132 const MessagePortMessage& message, |
133 const std::vector<int>& sent_message_port_ids) { | 133 const std::vector<int>& sent_message_port_ids) { |
134 if (!message_ports_.count(sender_message_port_id)) { | 134 if (!message_ports_.count(sender_message_port_id)) { |
135 NOTREACHED(); | 135 NOTREACHED(); |
136 return; | 136 return; |
137 } | 137 } |
138 | 138 |
139 int entangled_message_port_id = | 139 int entangled_message_port_id = |
140 message_ports_[sender_message_port_id].entangled_message_port_id; | 140 message_ports_[sender_message_port_id].entangled_message_port_id; |
141 if (entangled_message_port_id == MSG_ROUTING_NONE) | 141 if (entangled_message_port_id == MSG_ROUTING_NONE) |
142 return; // Process could have crashed. | 142 return; // Process could have crashed. |
143 | 143 |
144 if (!message_ports_.count(entangled_message_port_id)) { | 144 if (!message_ports_.count(entangled_message_port_id)) { |
145 NOTREACHED(); | 145 NOTREACHED(); |
146 return; | 146 return; |
147 } | 147 } |
148 | 148 |
149 PostMessageTo(entangled_message_port_id, message, sent_message_port_ids); | 149 PostMessageTo(entangled_message_port_id, message, sent_message_port_ids); |
150 } | 150 } |
151 | 151 |
152 void MessagePortService::PostMessageTo( | 152 void MessagePortService::PostMessageTo( |
153 int message_port_id, | 153 int message_port_id, |
154 const base::string16& message, | 154 const MessagePortMessage& message, |
155 const std::vector<int>& sent_message_port_ids) { | 155 const std::vector<int>& sent_message_port_ids) { |
156 if (!message_ports_.count(message_port_id)) { | 156 if (!message_ports_.count(message_port_id)) { |
157 NOTREACHED(); | 157 NOTREACHED(); |
158 return; | 158 return; |
159 } | 159 } |
160 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { | 160 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { |
161 if (!message_ports_.count(sent_message_port_ids[i])) { | 161 if (!message_ports_.count(sent_message_port_ids[i])) { |
162 NOTREACHED(); | 162 NOTREACHED(); |
163 return; | 163 return; |
164 } | 164 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // Do the disentanglement (and be paranoid about the other side existing | 307 // Do the disentanglement (and be paranoid about the other side existing |
308 // just in case something unusual happened during entanglement). | 308 // just in case something unusual happened during entanglement). |
309 if (message_ports_.count(entangled_id)) { | 309 if (message_ports_.count(entangled_id)) { |
310 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; | 310 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; |
311 } | 311 } |
312 } | 312 } |
313 message_ports_.erase(erase_item); | 313 message_ports_.erase(erase_item); |
314 } | 314 } |
315 | 315 |
316 } // namespace content | 316 } // namespace content |
OLD | NEW |