Chromium Code Reviews| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 : StrongBinding(impl) { | 68 : StrongBinding(impl) { |
| 69 binding_.Bind(handle.Pass(), waiter); | 69 binding_.Bind(handle.Pass(), waiter); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Constructs a completed binding of |impl| to a new message pipe, passing the | 72 // Constructs a completed binding of |impl| to a new message pipe, passing the |
| 73 // client end to |ptr|, which takes ownership of it. The caller is expected to | 73 // client end to |ptr|, which takes ownership of it. The caller is expected to |
| 74 // pass |ptr| on to the client of the service. Does not take ownership of any | 74 // pass |ptr| on to the client of the service. Does not take ownership of any |
| 75 // of the parameters. |impl| must outlive the binding. |ptr| only needs to | 75 // of the parameters. |impl| must outlive the binding. |ptr| only needs to |
| 76 // last until the constructor returns. See class comment for definition of | 76 // last until the constructor returns. See class comment for definition of |
| 77 // |waiter|. | 77 // |waiter|. |
| 78 // TODO(vardhan): Consider deprecating this constructor in favor of | |
|
viettrungluu
2016/02/11 18:26:29
What I said earlier....
| |
| 79 // |InterfaceHandle<>| instead of |InterfacePtr<>|. | |
| 78 StrongBinding( | 80 StrongBinding( |
| 79 Interface* impl, | 81 Interface* impl, |
| 80 InterfacePtr<Interface>* ptr, | 82 InterfacePtr<Interface>* ptr, |
| 81 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) | 83 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) |
| 82 : StrongBinding(impl) { | 84 : StrongBinding(impl) { |
| 83 binding_.Bind(ptr, waiter); | 85 binding_.Bind(ptr, waiter); |
| 84 } | 86 } |
| 85 | 87 |
| 88 // Constructs a completed binding of |impl| to a new message pipe, passing the | |
| 89 // client end to |ptr|, which takes ownership of it. The caller is expected to | |
| 90 // pass |ptr| on to the client of the service. Does not take ownership of any | |
| 91 // of the parameters. |impl| must outlive the binding. |ptr| only needs to | |
| 92 // last until the constructor returns. See class comment for definition of | |
| 93 // |waiter|. | |
| 94 StrongBinding( | |
| 95 Interface* impl, | |
| 96 InterfaceHandle<Interface>* ptr, | |
| 97 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) | |
| 98 : StrongBinding(impl) { | |
| 99 binding_.Bind(ptr, waiter); | |
| 100 } | |
| 101 | |
| 86 // Constructs a completed binding of |impl| to the message pipe endpoint in | 102 // Constructs a completed binding of |impl| to the message pipe endpoint in |
| 87 // |request|, taking ownership of the endpoint. Does not take ownership of | 103 // |request|, taking ownership of the endpoint. Does not take ownership of |
| 88 // |impl|, which must outlive the binding. See class comment for definition of | 104 // |impl|, which must outlive the binding. See class comment for definition of |
| 89 // |waiter|. | 105 // |waiter|. |
| 90 StrongBinding( | 106 StrongBinding( |
| 91 Interface* impl, | 107 Interface* impl, |
| 92 InterfaceRequest<Interface> request, | 108 InterfaceRequest<Interface> request, |
| 93 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) | 109 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) |
| 94 : StrongBinding(impl) { | 110 : StrongBinding(impl) { |
| 95 binding_.Bind(request.Pass(), waiter); | 111 binding_.Bind(request.Pass(), waiter); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 108 assert(!binding_.is_bound()); | 124 assert(!binding_.is_bound()); |
| 109 binding_.Bind(handle.Pass(), waiter); | 125 binding_.Bind(handle.Pass(), waiter); |
| 110 } | 126 } |
| 111 | 127 |
| 112 // Completes a binding that was constructed with only an interface | 128 // Completes a binding that was constructed with only an interface |
| 113 // implementation by creating a new message pipe, binding one end of it to the | 129 // implementation by creating a new message pipe, binding one end of it to the |
| 114 // previously specified implementation, and passing the other to |ptr|, which | 130 // previously specified implementation, and passing the other to |ptr|, which |
| 115 // takes ownership of it. The caller is expected to pass |ptr| on to the | 131 // takes ownership of it. The caller is expected to pass |ptr| on to the |
| 116 // eventual client of the service. Does not take ownership of |ptr|. See | 132 // eventual client of the service. Does not take ownership of |ptr|. See |
| 117 // class comment for definition of |waiter|. | 133 // class comment for definition of |waiter|. |
| 134 // TODO(vardhan): Consider deprecating this constructor in favor of | |
|
viettrungluu
2016/02/11 18:26:29
"
| |
| 135 // |InterfaceHandle<>| instead of |InterfacePtr<>|. | |
| 118 void Bind( | 136 void Bind( |
| 119 InterfacePtr<Interface>* ptr, | 137 InterfacePtr<Interface>* ptr, |
| 120 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | 138 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| 121 assert(!binding_.is_bound()); | 139 assert(!binding_.is_bound()); |
| 122 binding_.Bind(ptr, waiter); | 140 binding_.Bind(ptr, waiter); |
| 123 } | 141 } |
| 124 | 142 |
| 125 // Completes a binding that was constructed with only an interface | 143 // Completes a binding that was constructed with only an interface |
| 144 // implementation by creating a new message pipe, binding one end of it to the | |
| 145 // previously specified implementation, and passing the other to |ptr|, which | |
| 146 // takes ownership of it. The caller is expected to pass |ptr| on to the | |
| 147 // eventual client of the service. Does not take ownership of |ptr|. See | |
| 148 // class comment for definition of |waiter|. | |
| 149 void Bind( | |
| 150 InterfaceHandle<Interface>* ptr, | |
| 151 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | |
| 152 assert(!binding_.is_bound()); | |
| 153 binding_.Bind(ptr, waiter); | |
| 154 } | |
| 155 | |
| 156 // Completes a binding that was constructed with only an interface | |
| 126 // implementation by removing the message pipe endpoint from |request| and | 157 // implementation by removing the message pipe endpoint from |request| and |
| 127 // binding it to the previously specified implementation. See class comment | 158 // binding it to the previously specified implementation. See class comment |
| 128 // for definition of |waiter|. | 159 // for definition of |waiter|. |
| 129 void Bind( | 160 void Bind( |
| 130 InterfaceRequest<Interface> request, | 161 InterfaceRequest<Interface> request, |
| 131 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | 162 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| 132 assert(!binding_.is_bound()); | 163 assert(!binding_.is_bound()); |
| 133 binding_.Bind(request.Pass(), waiter); | 164 binding_.Bind(request.Pass(), waiter); |
| 134 } | 165 } |
| 135 | 166 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 private: | 215 private: |
| 185 Closure connection_error_handler_; | 216 Closure connection_error_handler_; |
| 186 Binding<Interface> binding_; | 217 Binding<Interface> binding_; |
| 187 | 218 |
| 188 MOJO_DISALLOW_COPY_AND_ASSIGN(StrongBinding); | 219 MOJO_DISALLOW_COPY_AND_ASSIGN(StrongBinding); |
| 189 }; | 220 }; |
| 190 | 221 |
| 191 } // namespace mojo | 222 } // namespace mojo |
| 192 | 223 |
| 193 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ | 224 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
| OLD | NEW |