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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ |
7 | 7 |
8 #include <algorithm> // For |std::swap()|. | 8 #include <algorithm> // For |std::swap()|. |
| 9 #include <utility> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "mojo/public/cpp/bindings/associated_group.h" | 13 #include "mojo/public/cpp/bindings/associated_group.h" |
13 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" | 14 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" |
14 #include "mojo/public/cpp/bindings/callback.h" | 15 #include "mojo/public/cpp/bindings/callback.h" |
15 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" | 16 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" |
16 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h" | 17 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h" |
17 #include "mojo/public/cpp/bindings/lib/interface_id.h" | 18 #include "mojo/public/cpp/bindings/lib/interface_id.h" |
18 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" | 19 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 88 |
88 // After this method is called, the object is in an invalid state and | 89 // After this method is called, the object is in an invalid state and |
89 // shouldn't be reused. | 90 // shouldn't be reused. |
90 AssociatedInterfacePtrInfo<GenericInterface> PassInterface() { | 91 AssociatedInterfacePtrInfo<GenericInterface> PassInterface() { |
91 ScopedInterfaceEndpointHandle handle = endpoint_client_->PassHandle(); | 92 ScopedInterfaceEndpointHandle handle = endpoint_client_->PassHandle(); |
92 endpoint_client_.reset(); | 93 endpoint_client_.reset(); |
93 proxy_.reset(); | 94 proxy_.reset(); |
94 | 95 |
95 AssociatedInterfacePtrInfo<GenericInterface> result; | 96 AssociatedInterfacePtrInfo<GenericInterface> result; |
96 result.set_version(version_); | 97 result.set_version(version_); |
97 AssociatedInterfacePtrInfoHelper::SetHandle(&result, handle.Pass()); | 98 AssociatedInterfacePtrInfoHelper::SetHandle(&result, std::move(handle)); |
98 return result.Pass(); | 99 return result.Pass(); |
99 } | 100 } |
100 | 101 |
101 bool is_bound() const { return !!endpoint_client_; } | 102 bool is_bound() const { return !!endpoint_client_; } |
102 | 103 |
103 bool encountered_error() const { | 104 bool encountered_error() const { |
104 return endpoint_client_ ? endpoint_client_->encountered_error() : false; | 105 return endpoint_client_ ? endpoint_client_->encountered_error() : false; |
105 } | 106 } |
106 | 107 |
107 void set_connection_error_handler(const Closure& error_handler) { | 108 void set_connection_error_handler(const Closure& error_handler) { |
(...skipping 18 matching lines...) Expand all Loading... |
126 | 127 |
127 uint32_t version_; | 128 uint32_t version_; |
128 | 129 |
129 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtrState); | 130 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtrState); |
130 }; | 131 }; |
131 | 132 |
132 } // namespace internal | 133 } // namespace internal |
133 } // namespace mojo | 134 } // namespace mojo |
134 | 135 |
135 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ | 136 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ASSOCIATED_INTERFACE_PTR_STATE_H_ |
OLD | NEW |