| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BINDING_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 CHECK(!HasAssociatedInterfaces()); | 177 CHECK(!HasAssociatedInterfaces()); |
| 178 return internal_state_.Unbind(); | 178 return internal_state_.Unbind(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Sets an error handler that will be called if a connection error occurs on | 181 // Sets an error handler that will be called if a connection error occurs on |
| 182 // the bound message pipe. | 182 // the bound message pipe. |
| 183 // | 183 // |
| 184 // This method may only be called after this Binding has been bound to a | 184 // This method may only be called after this Binding has been bound to a |
| 185 // message pipe. The error handler will be reset when this Binding is unbound | 185 // message pipe. The error handler will be reset when this Binding is unbound |
| 186 // or closed. | 186 // or closed. |
| 187 void set_connection_error_handler(const base::Closure& error_handler) { | 187 void set_connection_error_handler(base::OnceClosure error_handler) { |
| 188 DCHECK(is_bound()); | 188 DCHECK(is_bound()); |
| 189 internal_state_.set_connection_error_handler(error_handler); | 189 internal_state_.set_connection_error_handler(std::move(error_handler)); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void set_connection_error_with_reason_handler( | 192 void set_connection_error_with_reason_handler( |
| 193 const ConnectionErrorWithReasonCallback& error_handler) { | 193 ConnectionErrorWithReasonCallback error_handler) { |
| 194 DCHECK(is_bound()); | 194 DCHECK(is_bound()); |
| 195 internal_state_.set_connection_error_with_reason_handler(error_handler); | 195 internal_state_.set_connection_error_with_reason_handler( |
| 196 std::move(error_handler)); |
| 196 } | 197 } |
| 197 | 198 |
| 198 // Returns the interface implementation that was previously specified. Caller | 199 // Returns the interface implementation that was previously specified. Caller |
| 199 // does not take ownership. | 200 // does not take ownership. |
| 200 Interface* impl() { return internal_state_.impl(); } | 201 Interface* impl() { return internal_state_.impl(); } |
| 201 | 202 |
| 202 // Indicates whether the binding has been completed (i.e., whether a message | 203 // Indicates whether the binding has been completed (i.e., whether a message |
| 203 // pipe has been bound to the implementation). | 204 // pipe has been bound to the implementation). |
| 204 bool is_bound() const { return internal_state_.is_bound(); } | 205 bool is_bound() const { return internal_state_.is_bound(); } |
| 205 | 206 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 220 | 221 |
| 221 private: | 222 private: |
| 222 internal::BindingState<Interface, ImplRefTraits> internal_state_; | 223 internal::BindingState<Interface, ImplRefTraits> internal_state_; |
| 223 | 224 |
| 224 DISALLOW_COPY_AND_ASSIGN(Binding); | 225 DISALLOW_COPY_AND_ASSIGN(Binding); |
| 225 }; | 226 }; |
| 226 | 227 |
| 227 } // namespace mojo | 228 } // namespace mojo |
| 228 | 229 |
| 229 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ | 230 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ |
| OLD | NEW |