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_STRONG_BINDING_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
7 | 7 |
8 #include <assert.h> | 8 #include <assert.h> |
9 | 9 |
10 #include "mojo/public/c/environment/async_waiter.h" | 10 #include "mojo/public/c/environment/async_waiter.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // | 38 // |
39 // class MyFooFactory : public InterfaceFactory<Foo> { | 39 // class MyFooFactory : public InterfaceFactory<Foo> { |
40 // public: | 40 // public: |
41 // void Create(..., InterfaceRequest<Foo> request) override { | 41 // void Create(..., InterfaceRequest<Foo> request) override { |
42 // new StronglyBound(request.Pass()); // The binding now owns the | 42 // new StronglyBound(request.Pass()); // The binding now owns the |
43 // // instance of StronglyBound. | 43 // // instance of StronglyBound. |
44 // } | 44 // } |
45 // }; | 45 // }; |
46 template <typename Interface> | 46 template <typename Interface> |
47 class StrongBinding : public ErrorHandler { | 47 class StrongBinding : public ErrorHandler { |
| 48 MOJO_MOVE_ONLY_TYPE(StrongBinding) |
| 49 |
48 public: | 50 public: |
49 explicit StrongBinding(Interface* impl) : binding_(impl) { | 51 explicit StrongBinding(Interface* impl) : binding_(impl) { |
50 binding_.set_error_handler(this); | 52 binding_.set_error_handler(this); |
51 } | 53 } |
52 | 54 |
53 StrongBinding( | 55 StrongBinding( |
54 Interface* impl, | 56 Interface* impl, |
55 ScopedMessagePipeHandle handle, | 57 ScopedMessagePipeHandle handle, |
56 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) | 58 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) |
57 : StrongBinding(impl) { | 59 : StrongBinding(impl) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 120 } |
119 | 121 |
120 private: | 122 private: |
121 ErrorHandler* error_handler_ = nullptr; | 123 ErrorHandler* error_handler_ = nullptr; |
122 Binding<Interface> binding_; | 124 Binding<Interface> binding_; |
123 }; | 125 }; |
124 | 126 |
125 } // namespace mojo | 127 } // namespace mojo |
126 | 128 |
127 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ | 129 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
OLD | NEW |