| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/public/cpp/bindings/lib/multiplex_router.h" | 5 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 return true; | 519 return true; |
| 520 } | 520 } |
| 521 | 521 |
| 522 bool MultiplexRouter::OnPeerAssociatedEndpointClosed(InterfaceId id) { | 522 bool MultiplexRouter::OnPeerAssociatedEndpointClosed(InterfaceId id) { |
| 523 lock_.AssertAcquired(); | 523 lock_.AssertAcquired(); |
| 524 | 524 |
| 525 if (IsMasterInterfaceId(id)) | 525 if (IsMasterInterfaceId(id)) |
| 526 return false; | 526 return false; |
| 527 | 527 |
| 528 InterfaceEndpoint* endpoint = FindOrInsertEndpoint(id, nullptr); | 528 InterfaceEndpoint* endpoint = FindOrInsertEndpoint(id, nullptr); |
| 529 DCHECK(!endpoint->peer_closed()); | |
| 530 | 529 |
| 531 if (endpoint->client()) | 530 // It is possible that this endpoint has been set as peer closed. That is |
| 532 tasks_.push_back(Task::CreateNotifyErrorTask(endpoint)); | 531 // because when the message pipe is closed, all the endpoints are updated with |
| 533 UpdateEndpointStateMayRemove(endpoint, PEER_ENDPOINT_CLOSED); | 532 // PEER_ENDPOINT_CLOSED. We continue to process remaining tasks in the queue, |
| 533 // as long as there are refs keeping the router alive. If there is a |
| 534 // PeerAssociatedEndpointClosedEvent control message in the queue, we will get |
| 535 // here and see that the endpoint has been marked as peer closed. |
| 536 if (!endpoint->peer_closed()) { |
| 537 if (endpoint->client()) |
| 538 tasks_.push_back(Task::CreateNotifyErrorTask(endpoint)); |
| 539 UpdateEndpointStateMayRemove(endpoint, PEER_ENDPOINT_CLOSED); |
| 540 } |
| 534 | 541 |
| 535 // No need to trigger a ProcessTasks() because it is already on the stack. | 542 // No need to trigger a ProcessTasks() because it is already on the stack. |
| 536 | 543 |
| 537 return true; | 544 return true; |
| 538 } | 545 } |
| 539 | 546 |
| 540 bool MultiplexRouter::OnAssociatedEndpointClosedBeforeSent(InterfaceId id) { | 547 bool MultiplexRouter::OnAssociatedEndpointClosedBeforeSent(InterfaceId id) { |
| 541 lock_.AssertAcquired(); | 548 lock_.AssertAcquired(); |
| 542 | 549 |
| 543 if (IsMasterInterfaceId(id)) | 550 if (IsMasterInterfaceId(id)) |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 *inserted = true; | 835 *inserted = true; |
| 829 } else { | 836 } else { |
| 830 endpoint = iter->second.get(); | 837 endpoint = iter->second.get(); |
| 831 } | 838 } |
| 832 | 839 |
| 833 return endpoint; | 840 return endpoint; |
| 834 } | 841 } |
| 835 | 842 |
| 836 } // namespace internal | 843 } // namespace internal |
| 837 } // namespace mojo | 844 } // namespace mojo |
| OLD | NEW |