Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1146)

Side by Side Diff: mojo/public/cpp/bindings/associated_interface_ptr.h

Issue 2702603002: Mojo C++ bindings: remove unnecessary getters/params of AssociatedGroup. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/cpp/bindings/associated_group.h ('k') | mojo/public/cpp/bindings/binding.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ASSOCIATED_INTERFACE_PTR_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
19 #include "mojo/public/cpp/bindings/associated_group.h"
20 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" 19 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h"
21 #include "mojo/public/cpp/bindings/associated_interface_request.h" 20 #include "mojo/public/cpp/bindings/associated_interface_request.h"
22 #include "mojo/public/cpp/bindings/connection_error_callback.h" 21 #include "mojo/public/cpp/bindings/connection_error_callback.h"
23 #include "mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h" 22 #include "mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h"
24 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" 23 #include "mojo/public/cpp/bindings/lib/multiplex_router.h"
25 #include "mojo/public/cpp/system/message_pipe.h" 24 #include "mojo/public/cpp/system/message_pipe.h"
26 25
27 namespace mojo { 26 namespace mojo {
28 27
29 // Represents the client side of an associated interface. It is similar to 28 // Represents the client side of an associated interface. It is similar to
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // TODO: fix this restriction, it's not always obvious when there is a 152 // TODO: fix this restriction, it's not always obvious when there is a
154 // pending response. 153 // pending response.
155 AssociatedInterfacePtrInfo<Interface> PassInterface() { 154 AssociatedInterfacePtrInfo<Interface> PassInterface() {
156 DCHECK(!internal_state_.has_pending_callbacks()); 155 DCHECK(!internal_state_.has_pending_callbacks());
157 State state; 156 State state;
158 internal_state_.Swap(&state); 157 internal_state_.Swap(&state);
159 158
160 return state.PassInterface(); 159 return state.PassInterface();
161 } 160 }
162 161
163 // Returns the associated group that this object belongs to. Returns null if
164 // the object is not bound.
165 AssociatedGroup* associated_group() {
166 return internal_state_.associated_group();
167 }
168
169 // DO NOT USE. Exposed only for internal use and for testing. 162 // DO NOT USE. Exposed only for internal use and for testing.
170 internal::AssociatedInterfacePtrState<Interface>* internal_state() { 163 internal::AssociatedInterfacePtrState<Interface>* internal_state() {
171 return &internal_state_; 164 return &internal_state_;
172 } 165 }
173 166
174 // Allow AssociatedInterfacePtr<> to be used in boolean expressions, but not 167 // Allow AssociatedInterfacePtr<> to be used in boolean expressions, but not
175 // implicitly convertible to a real bool (which is dangerous). 168 // implicitly convertible to a real bool (which is dangerous).
176 private: 169 private:
177 // TODO(dcheng): Use an explicit conversion operator. 170 // TODO(dcheng): Use an explicit conversion operator.
178 typedef internal::AssociatedInterfacePtrState<Interface> 171 typedef internal::AssociatedInterfacePtrState<Interface>
(...skipping 19 matching lines...) Expand all
198 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtr); 191 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfacePtr);
199 }; 192 };
200 193
201 // Creates an associated interface. The returned request is supposed to be sent 194 // Creates an associated interface. The returned request is supposed to be sent
202 // over another interface (either associated or non-associated). 195 // over another interface (either associated or non-associated).
203 // 196 //
204 // NOTE: |ptr| must NOT be used to make calls before the request is sent. 197 // NOTE: |ptr| must NOT be used to make calls before the request is sent.
205 // Violating that will lead to crash. On the other hand, as soon as the request 198 // Violating that will lead to crash. On the other hand, as soon as the request
206 // is sent, |ptr| is usable. There is no need to wait until the request is bound 199 // is sent, |ptr| is usable. There is no need to wait until the request is bound
207 // to an implementation at the remote side. 200 // to an implementation at the remote side.
208 // TODO(yzshen): Remove the |group| parameter.
209 template <typename Interface> 201 template <typename Interface>
210 AssociatedInterfaceRequest<Interface> MakeRequest( 202 AssociatedInterfaceRequest<Interface> MakeRequest(
211 AssociatedInterfacePtr<Interface>* ptr, 203 AssociatedInterfacePtr<Interface>* ptr,
212 AssociatedGroup* group = nullptr,
213 scoped_refptr<base::SingleThreadTaskRunner> runner = 204 scoped_refptr<base::SingleThreadTaskRunner> runner =
214 base::ThreadTaskRunnerHandle::Get()) { 205 base::ThreadTaskRunnerHandle::Get()) {
215 AssociatedInterfacePtrInfo<Interface> ptr_info; 206 AssociatedInterfacePtrInfo<Interface> ptr_info;
216 auto request = MakeRequest(&ptr_info); 207 auto request = MakeRequest(&ptr_info);
217 ptr->Bind(std::move(ptr_info), std::move(runner)); 208 ptr->Bind(std::move(ptr_info), std::move(runner));
218 return request; 209 return request;
219 } 210 }
220 211
221 // Creates an associated interface. One of the two endpoints is supposed to be 212 // Creates an associated interface. One of the two endpoints is supposed to be
222 // sent over another interface (either associated or non-associated); while the 213 // sent over another interface (either associated or non-associated); while the
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // all callsites of this function to directly use that. 276 // all callsites of this function to directly use that.
286 template <typename Interface> 277 template <typename Interface>
287 AssociatedInterfaceRequest<Interface> MakeRequestForTesting( 278 AssociatedInterfaceRequest<Interface> MakeRequestForTesting(
288 AssociatedInterfacePtr<Interface>* ptr) { 279 AssociatedInterfacePtr<Interface>* ptr) {
289 return GetIsolatedProxy(ptr); 280 return GetIsolatedProxy(ptr);
290 } 281 }
291 282
292 } // namespace mojo 283 } // namespace mojo
293 284
294 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_ 285 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_PTR_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/associated_group.h ('k') | mojo/public/cpp/bindings/binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698