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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "mojo/public/c/environment/async_waiter.h" | 9 #include "mojo/public/c/environment/async_waiter.h" |
10 #include "mojo/public/cpp/bindings/callback.h" | 10 #include "mojo/public/cpp/bindings/callback.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // on to associated interface endpoint handles at both sides of the | 186 // on to associated interface endpoint handles at both sides of the |
187 // message pipe in order to call this method. We need a way to forcefully | 187 // message pipe in order to call this method. We need a way to forcefully |
188 // invalidate associated interface endpoint handles. | 188 // invalidate associated interface endpoint handles. |
189 InterfaceRequest<Interface> Unbind() { | 189 InterfaceRequest<Interface> Unbind() { |
190 CHECK(!HasAssociatedInterfaces()); | 190 CHECK(!HasAssociatedInterfaces()); |
191 return internal_state_.Unbind(); | 191 return internal_state_.Unbind(); |
192 } | 192 } |
193 | 193 |
194 // Sets an error handler that will be called if a connection error occurs on | 194 // Sets an error handler that will be called if a connection error occurs on |
195 // the bound message pipe. | 195 // the bound message pipe. |
| 196 // |
| 197 // This method may only be called after this Binding has been bound to a |
| 198 // message pipe. The error handler will be reset when this Binding is unbound |
| 199 // or closed. |
196 void set_connection_error_handler(const Closure& error_handler) { | 200 void set_connection_error_handler(const Closure& error_handler) { |
| 201 DCHECK(is_bound()); |
197 internal_state_.set_connection_error_handler(error_handler); | 202 internal_state_.set_connection_error_handler(error_handler); |
198 } | 203 } |
199 | 204 |
200 // Returns the interface implementation that was previously specified. Caller | 205 // Returns the interface implementation that was previously specified. Caller |
201 // does not take ownership. | 206 // does not take ownership. |
202 Interface* impl() { return internal_state_.impl(); } | 207 Interface* impl() { return internal_state_.impl(); } |
203 | 208 |
204 // Indicates whether the binding has been completed (i.e., whether a message | 209 // Indicates whether the binding has been completed (i.e., whether a message |
205 // pipe has been bound to the implementation). | 210 // pipe has been bound to the implementation). |
206 bool is_bound() const { return internal_state_.is_bound(); } | 211 bool is_bound() const { return internal_state_.is_bound(); } |
(...skipping 18 matching lines...) Expand all Loading... |
225 private: | 230 private: |
226 internal::BindingState<Interface, Interface::PassesAssociatedKinds_> | 231 internal::BindingState<Interface, Interface::PassesAssociatedKinds_> |
227 internal_state_; | 232 internal_state_; |
228 | 233 |
229 DISALLOW_COPY_AND_ASSIGN(Binding); | 234 DISALLOW_COPY_AND_ASSIGN(Binding); |
230 }; | 235 }; |
231 | 236 |
232 } // namespace mojo | 237 } // namespace mojo |
233 | 238 |
234 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ | 239 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ |
OLD | NEW |