Chromium Code Reviews| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 if (!message_ports_.count(message_port_id)) { | 67 if (!message_ports_.count(message_port_id)) { |
| 68 NOTREACHED(); | 68 NOTREACHED(); |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 | 71 |
| 72 MessagePort& port = message_ports_[message_port_id]; | 72 MessagePort& port = message_ports_[message_port_id]; |
| 73 port.delegate = delegate; | 73 port.delegate = delegate; |
| 74 port.route_id = routing_id; | 74 port.route_id = routing_id; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void MessagePortService::GetMessagePortInfo(int message_port_id, | |
| 78 MessagePortDelegate** delegate, | |
| 79 int* routing_id) { | |
| 80 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 81 if (!message_ports_.count(message_port_id)) { | |
| 82 NOTREACHED(); | |
|
scheib
2015/05/06 22:19:45
Handle it or not, but not both. Looks like here we
Marijn Kruisselbrink
2015/05/12 06:57:33
I would generally agree with you, but this exact s
| |
| 83 return; | |
| 84 } | |
| 85 | |
| 86 const MessagePort& port = message_ports_[message_port_id]; | |
| 87 if (delegate) | |
| 88 *delegate = port.delegate; | |
| 89 if (routing_id) | |
| 90 *routing_id = port.route_id; | |
| 91 } | |
| 92 | |
| 77 void MessagePortService::OnMessagePortDelegateClosing( | 93 void MessagePortService::OnMessagePortDelegateClosing( |
| 78 MessagePortDelegate* delegate) { | 94 MessagePortDelegate* delegate) { |
| 79 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 95 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 80 // Check if the (possibly) crashed process had any message ports. | 96 // Check if the (possibly) crashed process had any message ports. |
| 81 for (MessagePorts::iterator iter = message_ports_.begin(); | 97 for (MessagePorts::iterator iter = message_ports_.begin(); |
| 82 iter != message_ports_.end();) { | 98 iter != message_ports_.end();) { |
| 83 MessagePorts::iterator cur_item = iter++; | 99 MessagePorts::iterator cur_item = iter++; |
| 84 if (cur_item->second.delegate == delegate) { | 100 if (cur_item->second.delegate == delegate) { |
| 85 Erase(cur_item->first); | 101 Erase(cur_item->first); |
| 86 } | 102 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 if (entangled_port.queue_messages()) { | 189 if (entangled_port.queue_messages()) { |
| 174 // If the target port is currently holding messages because the destination | 190 // If the target port is currently holding messages because the destination |
| 175 // renderer isn't available yet, all message ports being sent should also be | 191 // renderer isn't available yet, all message ports being sent should also be |
| 176 // put in this state. | 192 // put in this state. |
| 177 if (entangled_port.hold_messages_for_destination) { | 193 if (entangled_port.hold_messages_for_destination) { |
| 178 for (const auto& port : sent_message_ports) | 194 for (const auto& port : sent_message_ports) |
| 179 HoldMessages(port.id); | 195 HoldMessages(port.id); |
| 180 } | 196 } |
| 181 entangled_port.queued_messages.push_back( | 197 entangled_port.queued_messages.push_back( |
| 182 std::make_pair(message, sent_message_ports)); | 198 std::make_pair(message, sent_message_ports)); |
| 199 | |
| 200 if (entangled_port.delegate) | |
| 201 entangled_port.delegate->MessageWasHeld(entangled_port.route_id); | |
| 202 | |
| 183 return; | 203 return; |
| 184 } | 204 } |
| 185 | 205 |
| 186 if (!entangled_port.delegate) { | 206 if (!entangled_port.delegate) { |
| 187 NOTREACHED(); | 207 NOTREACHED(); |
| 188 return; | 208 return; |
| 189 } | 209 } |
| 190 | 210 |
| 191 // Now send the message to the entangled port. | 211 // Now send the message to the entangled port. |
| 192 entangled_port.delegate->SendMessage(entangled_port.route_id, message, | 212 entangled_port.delegate->SendMessage(entangled_port.route_id, message, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 // Do the disentanglement (and be paranoid about the other side existing | 333 // Do the disentanglement (and be paranoid about the other side existing |
| 314 // just in case something unusual happened during entanglement). | 334 // just in case something unusual happened during entanglement). |
| 315 if (message_ports_.count(entangled_id)) { | 335 if (message_ports_.count(entangled_id)) { |
| 316 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; | 336 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; |
| 317 } | 337 } |
| 318 } | 338 } |
| 319 message_ports_.erase(erase_item); | 339 message_ports_.erase(erase_item); |
| 320 } | 340 } |
| 321 | 341 |
| 322 } // namespace content | 342 } // namespace content |
| OLD | NEW |