| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 126 } |
| 127 | 127 |
| 128 DCHECK(message_ports_[remote_message_port_id].entangled_message_port_id == | 128 DCHECK(message_ports_[remote_message_port_id].entangled_message_port_id == |
| 129 MSG_ROUTING_NONE); | 129 MSG_ROUTING_NONE); |
| 130 message_ports_[remote_message_port_id].entangled_message_port_id = | 130 message_ports_[remote_message_port_id].entangled_message_port_id = |
| 131 local_message_port_id; | 131 local_message_port_id; |
| 132 } | 132 } |
| 133 | 133 |
| 134 void MessagePortService::PostMessage( | 134 void MessagePortService::PostMessage( |
| 135 int sender_message_port_id, | 135 int sender_message_port_id, |
| 136 const base::string16& message, | 136 const MessagePortMessage& message, |
| 137 const std::vector<int>& sent_message_port_ids) { | 137 const std::vector<int>& sent_message_port_ids) { |
| 138 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 138 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 139 if (!message_ports_.count(sender_message_port_id)) { | 139 if (!message_ports_.count(sender_message_port_id)) { |
| 140 NOTREACHED(); | 140 NOTREACHED(); |
| 141 return; | 141 return; |
| 142 } | 142 } |
| 143 | 143 |
| 144 int entangled_message_port_id = | 144 int entangled_message_port_id = |
| 145 message_ports_[sender_message_port_id].entangled_message_port_id; | 145 message_ports_[sender_message_port_id].entangled_message_port_id; |
| 146 if (entangled_message_port_id == MSG_ROUTING_NONE) | 146 if (entangled_message_port_id == MSG_ROUTING_NONE) |
| 147 return; // Process could have crashed. | 147 return; // Process could have crashed. |
| 148 | 148 |
| 149 if (!message_ports_.count(entangled_message_port_id)) { | 149 if (!message_ports_.count(entangled_message_port_id)) { |
| 150 NOTREACHED(); | 150 NOTREACHED(); |
| 151 return; | 151 return; |
| 152 } | 152 } |
| 153 | 153 |
| 154 PostMessageTo(entangled_message_port_id, message, sent_message_port_ids); | 154 PostMessageTo(entangled_message_port_id, message, sent_message_port_ids); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void MessagePortService::PostMessageTo( | 157 void MessagePortService::PostMessageTo( |
| 158 int message_port_id, | 158 int message_port_id, |
| 159 const base::string16& message, | 159 const MessagePortMessage& message, |
| 160 const std::vector<int>& sent_message_port_ids) { | 160 const std::vector<int>& sent_message_port_ids) { |
| 161 if (!message_ports_.count(message_port_id)) { | 161 if (!message_ports_.count(message_port_id)) { |
| 162 NOTREACHED(); | 162 NOTREACHED(); |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { | 165 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { |
| 166 if (!message_ports_.count(sent_message_port_ids[i])) { | 166 if (!message_ports_.count(sent_message_port_ids[i])) { |
| 167 NOTREACHED(); | 167 NOTREACHED(); |
| 168 return; | 168 return; |
| 169 } | 169 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // Do the disentanglement (and be paranoid about the other side existing | 318 // Do the disentanglement (and be paranoid about the other side existing |
| 319 // just in case something unusual happened during entanglement). | 319 // just in case something unusual happened during entanglement). |
| 320 if (message_ports_.count(entangled_id)) { | 320 if (message_ports_.count(entangled_id)) { |
| 321 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; | 321 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 message_ports_.erase(erase_item); | 324 message_ports_.erase(erase_item); |
| 325 } | 325 } |
| 326 | 326 |
| 327 } // namespace content | 327 } // namespace content |
| OLD | NEW |