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 <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 // public: | 34 // public: |
35 // explicit FooImpl(InterfaceRequest<Foo> request) | 35 // explicit FooImpl(InterfaceRequest<Foo> request) |
36 // : binding_(this, request.Pass()) {} | 36 // : binding_(this, request.Pass()) {} |
37 // | 37 // |
38 // // Foo implementation here. | 38 // // Foo implementation here. |
39 // | 39 // |
40 // private: | 40 // private: |
41 // Binding<Foo> binding_; | 41 // Binding<Foo> binding_; |
42 // }; | 42 // }; |
43 // | 43 // |
44 // class MyFooFactory : public InterfaceFactory<Foo> { | |
45 // public: | |
46 // void Create(..., InterfaceRequest<Foo> request) override { | |
47 // auto f = new FooImpl(request.Pass()); | |
48 // // Do something to manage the lifetime of |f|. Use StrongBinding<> to | |
49 // // delete FooImpl on connection errors. | |
50 // } | |
51 // }; | |
52 // | |
53 // The caller may specify a |MojoAsyncWaiter| to be used by the connection when | 44 // The caller may specify a |MojoAsyncWaiter| to be used by the connection when |
54 // waiting for calls to arrive. Normally it is fine to use the default waiter. | 45 // waiting for calls to arrive. Normally it is fine to use the default waiter. |
55 // However, the caller may provide their own implementation if needed. The | 46 // However, the caller may provide their own implementation if needed. The |
56 // |Binding| will not take ownership of the waiter, and the waiter must outlive | 47 // |Binding| will not take ownership of the waiter, and the waiter must outlive |
57 // the |Binding|. The provided waiter must be able to signal the implementation | 48 // the |Binding|. The provided waiter must be able to signal the implementation |
58 // which generally means it needs to be able to schedule work on the thread the | 49 // which generally means it needs to be able to schedule work on the thread the |
59 // implementation runs on. If writing library code that has to work on different | 50 // implementation runs on. If writing library code that has to work on different |
60 // types of threads callers may need to provide different waiter | 51 // types of threads callers may need to provide different waiter |
61 // implementations. | 52 // implementations. |
62 template <typename Interface> | 53 template <typename Interface> |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 typename Interface::Stub_ stub_; | 200 typename Interface::Stub_ stub_; |
210 Interface* impl_; | 201 Interface* impl_; |
211 Closure connection_error_handler_; | 202 Closure connection_error_handler_; |
212 | 203 |
213 MOJO_DISALLOW_COPY_AND_ASSIGN(Binding); | 204 MOJO_DISALLOW_COPY_AND_ASSIGN(Binding); |
214 }; | 205 }; |
215 | 206 |
216 } // namespace mojo | 207 } // namespace mojo |
217 | 208 |
218 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ | 209 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ |
OLD | NEW |