| 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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 RaiseErrorInNonTestingMode(); | 695 RaiseErrorInNonTestingMode(); |
| 696 return true; | 696 return true; |
| 697 } | 697 } |
| 698 | 698 |
| 699 InterfaceId id = message->interface_id(); | 699 InterfaceId id = message->interface_id(); |
| 700 DCHECK(IsValidInterfaceId(id)); | 700 DCHECK(IsValidInterfaceId(id)); |
| 701 | 701 |
| 702 bool inserted = false; | 702 bool inserted = false; |
| 703 InterfaceEndpoint* endpoint = FindOrInsertEndpoint(id, &inserted); | 703 InterfaceEndpoint* endpoint = FindOrInsertEndpoint(id, &inserted); |
| 704 if (inserted) { | 704 if (inserted) { |
| 705 DCHECK(!IsMasterInterfaceId(id)); | |
| 706 | |
| 707 // Currently, it is legitimate to receive messages for an endpoint | 705 // Currently, it is legitimate to receive messages for an endpoint |
| 708 // that is not registered. For example, the endpoint is transferred in | 706 // that is not registered. For example, the endpoint is transferred in |
| 709 // a message that is discarded. Once we add support to specify all | 707 // a message that is discarded. Once we add support to specify all |
| 710 // enclosing endpoints in message header, we should be able to remove | 708 // enclosing endpoints in message header, we should be able to remove |
| 711 // this. | 709 // this. |
| 712 UpdateEndpointStateMayRemove(endpoint, ENDPOINT_CLOSED); | 710 UpdateEndpointStateMayRemove(endpoint, ENDPOINT_CLOSED); |
| 713 | 711 |
| 714 control_message_proxy_.NotifyPeerEndpointClosed(id); | 712 // It is also possible that this newly-inserted endpoint is the master |
| 713 // endpoint. When the master InterfacePtr/Binding goes away, the message |
| 714 // pipe is closed and we explicitly trigger a pipe connection error. The |
| 715 // error updates all the endpoints, including the master endpoint, with |
| 716 // PEER_ENDPOINT_CLOSED and removes the master endpoint from the |
| 717 // registration. We continue to process remaining tasks in the queue, as |
| 718 // long as there are refs keeping the router alive. If there are remaining |
| 719 // messages for the master endpoint, we will get here. |
| 720 if (!IsMasterInterfaceId(id)) |
| 721 control_message_proxy_.NotifyPeerEndpointClosed(id); |
| 715 return true; | 722 return true; |
| 716 } | 723 } |
| 717 | 724 |
| 718 if (endpoint->closed()) | 725 if (endpoint->closed()) |
| 719 return true; | 726 return true; |
| 720 | 727 |
| 721 if (!endpoint->client()) { | 728 if (!endpoint->client()) { |
| 722 // We need to wait until a client is attached in order to dispatch further | 729 // We need to wait until a client is attached in order to dispatch further |
| 723 // messages. | 730 // messages. |
| 724 return false; | 731 return false; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 *inserted = true; | 828 *inserted = true; |
| 822 } else { | 829 } else { |
| 823 endpoint = iter->second.get(); | 830 endpoint = iter->second.get(); |
| 824 } | 831 } |
| 825 | 832 |
| 826 return endpoint; | 833 return endpoint; |
| 827 } | 834 } |
| 828 | 835 |
| 829 } // namespace internal | 836 } // namespace internal |
| 830 } // namespace mojo | 837 } // namespace mojo |
| OLD | NEW |