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

Side by Side Diff: mojo/public/cpp/bindings/binding.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
OLDNEW
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 <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "mojo/public/cpp/bindings/connection_error_callback.h" 16 #include "mojo/public/cpp/bindings/connection_error_callback.h"
17 #include "mojo/public/cpp/bindings/interface_ptr.h" 17 #include "mojo/public/cpp/bindings/interface_ptr.h"
18 #include "mojo/public/cpp/bindings/interface_ptr_info.h" 18 #include "mojo/public/cpp/bindings/interface_ptr_info.h"
19 #include "mojo/public/cpp/bindings/interface_request.h" 19 #include "mojo/public/cpp/bindings/interface_request.h"
20 #include "mojo/public/cpp/bindings/lib/binding_state.h" 20 #include "mojo/public/cpp/bindings/lib/binding_state.h"
21 #include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h" 21 #include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h"
22 #include "mojo/public/cpp/system/core.h" 22 #include "mojo/public/cpp/system/core.h"
23 23
24 namespace mojo { 24 namespace mojo {
25 25
26 class AssociatedGroup;
27 class MessageReceiver; 26 class MessageReceiver;
28 27
29 // Represents the binding of an interface implementation to a message pipe. 28 // Represents the binding of an interface implementation to a message pipe.
30 // When the |Binding| object is destroyed, the binding between the message pipe 29 // When the |Binding| object is destroyed, the binding between the message pipe
31 // and the interface is torn down and the message pipe is closed, leaving the 30 // and the interface is torn down and the message pipe is closed, leaving the
32 // interface implementation in an unbound state. 31 // interface implementation in an unbound state.
33 // 32 //
34 // Example: 33 // Example:
35 // 34 //
36 // #include "foo.mojom.h" 35 // #include "foo.mojom.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // Indicates whether the binding has been completed (i.e., whether a message 249 // Indicates whether the binding has been completed (i.e., whether a message
251 // pipe has been bound to the implementation). 250 // pipe has been bound to the implementation).
252 bool is_bound() const { return internal_state_.is_bound(); } 251 bool is_bound() const { return internal_state_.is_bound(); }
253 252
254 // Returns the value of the handle currently bound to this Binding which can 253 // Returns the value of the handle currently bound to this Binding which can
255 // be used to make explicit Wait/WaitMany calls. Requires that the Binding be 254 // be used to make explicit Wait/WaitMany calls. Requires that the Binding be
256 // bound. Ownership of the handle is retained by the Binding, it is not 255 // bound. Ownership of the handle is retained by the Binding, it is not
257 // transferred to the caller. 256 // transferred to the caller.
258 MessagePipeHandle handle() const { return internal_state_.handle(); } 257 MessagePipeHandle handle() const { return internal_state_.handle(); }
259 258
260 // Returns the associated group that this object belongs to. Returns null if:
261 // - this object is not bound; or
262 // - the interface doesn't have methods to pass associated interface
263 // pointers or requests.
264 AssociatedGroup* associated_group() {
265 return internal_state_.associated_group();
266 }
267
268 // Sends a no-op message on the underlying message pipe and runs the current 259 // Sends a no-op message on the underlying message pipe and runs the current
269 // message loop until its response is received. This can be used in tests to 260 // message loop until its response is received. This can be used in tests to
270 // verify that no message was sent on a message pipe in response to some 261 // verify that no message was sent on a message pipe in response to some
271 // stimulus. 262 // stimulus.
272 void FlushForTesting() { internal_state_.FlushForTesting(); } 263 void FlushForTesting() { internal_state_.FlushForTesting(); }
273 264
274 // Exposed for testing, should not generally be used. 265 // Exposed for testing, should not generally be used.
275 void EnableTestingMode() { internal_state_.EnableTestingMode(); } 266 void EnableTestingMode() { internal_state_.EnableTestingMode(); }
276 267
277 private: 268 private:
278 internal::BindingState<Interface, ImplRefTraits> internal_state_; 269 internal::BindingState<Interface, ImplRefTraits> internal_state_;
279 270
280 DISALLOW_COPY_AND_ASSIGN(Binding); 271 DISALLOW_COPY_AND_ASSIGN(Binding);
281 }; 272 };
282 273
283 } // namespace mojo 274 } // namespace mojo
284 275
285 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_ 276 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/associated_interface_ptr.h ('k') | mojo/public/cpp/bindings/interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698