Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: mojo/public/cpp/bindings/lib/multiplex_router.cc

Issue 2037793003: Mojo C++ bindings: handle double peer endpoint closed event for the same endpoint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698