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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "content/common/message_port_messages.h" | 9 #include "content/common/message_port_messages.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 288 } |
289 | 289 |
290 // Any ports in messages currently in the queue should also be put on hold. | 290 // Any ports in messages currently in the queue should also be put on hold. |
291 for (const auto& message : message_ports_[message_port_id].queued_messages) | 291 for (const auto& message : message_ports_[message_port_id].queued_messages) |
292 for (const TransferredMessagePort& sent_port : message.second) | 292 for (const TransferredMessagePort& sent_port : message.second) |
293 HoldMessages(sent_port.id); | 293 HoldMessages(sent_port.id); |
294 | 294 |
295 message_ports_[message_port_id].hold_messages_for_destination = true; | 295 message_ports_[message_port_id].hold_messages_for_destination = true; |
296 } | 296 } |
297 | 297 |
| 298 bool MessagePortService::AreMessagesHeld(int message_port_id) { |
| 299 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 300 if (!message_ports_.count(message_port_id)) |
| 301 return false; |
| 302 return message_ports_[message_port_id].hold_messages_for_destination; |
| 303 } |
| 304 |
298 void MessagePortService::ClosePort(int message_port_id) { | 305 void MessagePortService::ClosePort(int message_port_id) { |
299 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 306 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
300 if (!message_ports_.count(message_port_id)) { | 307 if (!message_ports_.count(message_port_id)) { |
301 NOTREACHED(); | 308 NOTREACHED(); |
302 return; | 309 return; |
303 } | 310 } |
304 | 311 |
305 if (message_ports_[message_port_id].queue_for_inflight_messages) { | 312 if (message_ports_[message_port_id].queue_for_inflight_messages) { |
306 message_ports_[message_port_id].should_be_destroyed = true; | 313 message_ports_[message_port_id].should_be_destroyed = true; |
307 return; | 314 return; |
(...skipping 27 matching lines...) Expand all Loading... |
335 // Do the disentanglement (and be paranoid about the other side existing | 342 // Do the disentanglement (and be paranoid about the other side existing |
336 // just in case something unusual happened during entanglement). | 343 // just in case something unusual happened during entanglement). |
337 if (message_ports_.count(entangled_id)) { | 344 if (message_ports_.count(entangled_id)) { |
338 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; | 345 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; |
339 } | 346 } |
340 } | 347 } |
341 message_ports_.erase(erase_item); | 348 message_ports_.erase(erase_item); |
342 } | 349 } |
343 | 350 |
344 } // namespace content | 351 } // namespace content |
OLD | NEW |