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/scoped_interface_endpoint_handle.h" | 5 #include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" | 8 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
(...skipping 17 matching lines...) Expand all Loading... |
28 other.id_ = kInvalidInterfaceId; | 28 other.id_ = kInvalidInterfaceId; |
29 } | 29 } |
30 | 30 |
31 ScopedInterfaceEndpointHandle::~ScopedInterfaceEndpointHandle() { | 31 ScopedInterfaceEndpointHandle::~ScopedInterfaceEndpointHandle() { |
32 reset(); | 32 reset(); |
33 } | 33 } |
34 | 34 |
35 ScopedInterfaceEndpointHandle& ScopedInterfaceEndpointHandle::operator=( | 35 ScopedInterfaceEndpointHandle& ScopedInterfaceEndpointHandle::operator=( |
36 ScopedInterfaceEndpointHandle&& other) { | 36 ScopedInterfaceEndpointHandle&& other) { |
37 reset(); | 37 reset(); |
38 | 38 swap(other); |
39 id_ = other.id_; | |
40 is_local_ = other.is_local_; | |
41 router_.swap(other.router_); | |
42 | |
43 other.id_ = kInvalidInterfaceId; | |
44 | 39 |
45 return *this; | 40 return *this; |
46 } | 41 } |
47 | 42 |
48 void ScopedInterfaceEndpointHandle::reset() { | 43 void ScopedInterfaceEndpointHandle::reset() { |
49 if (!IsValidInterfaceId(id_)) | 44 if (!IsValidInterfaceId(id_)) |
50 return; | 45 return; |
51 | 46 |
52 router_->CloseEndpointHandle(id_, is_local_); | 47 router_->CloseEndpointHandle(id_, is_local_); |
53 | 48 |
54 id_ = kInvalidInterfaceId; | 49 id_ = kInvalidInterfaceId; |
| 50 is_local_ = true; |
55 router_ = nullptr; | 51 router_ = nullptr; |
56 } | 52 } |
57 | 53 |
58 void ScopedInterfaceEndpointHandle::swap(ScopedInterfaceEndpointHandle& other) { | 54 void ScopedInterfaceEndpointHandle::swap(ScopedInterfaceEndpointHandle& other) { |
59 using std::swap; | 55 using std::swap; |
60 swap(other.id_, id_); | 56 swap(other.id_, id_); |
61 swap(other.is_local_, is_local_); | 57 swap(other.is_local_, is_local_); |
62 swap(other.router_, router_); | 58 swap(other.router_, router_); |
63 } | 59 } |
64 | 60 |
65 InterfaceId ScopedInterfaceEndpointHandle::release() { | 61 InterfaceId ScopedInterfaceEndpointHandle::release() { |
66 InterfaceId result = id_; | 62 InterfaceId result = id_; |
67 | 63 |
68 id_ = kInvalidInterfaceId; | 64 id_ = kInvalidInterfaceId; |
| 65 is_local_ = true; |
69 router_ = nullptr; | 66 router_ = nullptr; |
70 | 67 |
71 return result; | 68 return result; |
72 } | 69 } |
73 | 70 |
74 } // namespace internal | 71 } // namespace internal |
75 } // namespace mojo | 72 } // namespace mojo |
OLD | NEW |