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 "mojo/public/c/environment/async_waiter.h" | 8 #include "mojo/public/c/environment/async_waiter.h" |
9 #include "mojo/public/cpp/bindings/error_handler.h" | 9 #include "mojo/public/cpp/bindings/error_handler.h" |
10 #include "mojo/public/cpp/bindings/interface_ptr.h" | 10 #include "mojo/public/cpp/bindings/interface_ptr.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 InterfaceRequest<Interface> request, | 94 InterfaceRequest<Interface> request, |
95 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) | 95 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) |
96 : Binding(impl) { | 96 : Binding(impl) { |
97 Bind(request.PassMessagePipe(), waiter); | 97 Bind(request.PassMessagePipe(), waiter); |
98 } | 98 } |
99 | 99 |
100 // Tears down the binding, closing the message pipe and leaving the interface | 100 // Tears down the binding, closing the message pipe and leaving the interface |
101 // implementation unbound. | 101 // implementation unbound. |
102 ~Binding() override { | 102 ~Binding() override { |
103 if (internal_router_) { | 103 if (internal_router_) { |
104 DestroyRouter(); | 104 Close(); |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 // Completes a binding that was constructed with only an interface | 108 // Completes a binding that was constructed with only an interface |
109 // implementation. Takes ownership of |handle| and binds it to the previously | 109 // implementation. Takes ownership of |handle| and binds it to the previously |
110 // specified implementation. See class comment for definition of |waiter|. | 110 // specified implementation. See class comment for definition of |waiter|. |
111 void Bind( | 111 void Bind( |
112 ScopedMessagePipeHandle handle, | 112 ScopedMessagePipeHandle handle, |
113 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | 113 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
114 MOJO_DCHECK(!internal_router_); | 114 MOJO_DCHECK(!internal_router_); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 typename Interface::Stub_ stub_; | 208 typename Interface::Stub_ stub_; |
209 Interface* impl_; | 209 Interface* impl_; |
210 ErrorHandler* error_handler_ = nullptr; | 210 ErrorHandler* error_handler_ = nullptr; |
211 | 211 |
212 MOJO_DISALLOW_COPY_AND_ASSIGN(Binding); | 212 MOJO_DISALLOW_COPY_AND_ASSIGN(Binding); |
213 }; | 213 }; |
214 | 214 |
215 } // namespace mojo | 215 } // namespace mojo |
216 | 216 |
217 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ | 217 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ |
OLD | NEW |