diff options
author | Hidehiko Abe <hidehiko@google.com> | 2017-12-13 19:00:02 +0900 |
---|---|---|
committer | Hidehiko Abe <hidehiko@google.com> | 2017-12-13 23:42:13 +0900 |
commit | 0411add1e14cc2dc041f5f1776f05a8c4b787d73 (patch) | |
tree | 19a081baf4afcba8d442b5e839cb1ff247f31b7f /mojo/public/cpp/bindings/associated_group.h | |
parent | c96e5aa6f5f1f6df03ef539b4b85c78bf7c292e5 (diff) | |
download | libmojo-0411add1e14cc2dc041f5f1776f05a8c4b787d73.tar.gz |
Revert "Revert "libmojo: Uprev the library to r456626 from Chromium""
This reverts commit 21a249e4d9cb0b2ec6f0ff84ed5f7939ea67ac52.
Test: Build.
Change-Id: Id31199817067e933eb08889b21b83c787b0d4c0d
Merged-In: I2f77e0bb4541d6520dac974cd499b30561c6658f
Diffstat (limited to 'mojo/public/cpp/bindings/associated_group.h')
-rw-r--r-- | mojo/public/cpp/bindings/associated_group.h | 77 |
1 files changed, 19 insertions, 58 deletions
diff --git a/mojo/public/cpp/bindings/associated_group.h b/mojo/public/cpp/bindings/associated_group.h index 836c0d6..14e78ec 100644 --- a/mojo/public/cpp/bindings/associated_group.h +++ b/mojo/public/cpp/bindings/associated_group.h @@ -5,11 +5,9 @@ #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_GROUP_H_ -#include <utility> - +#include "base/callback.h" #include "base/memory/ref_counted.h" -#include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" -#include "mojo/public/cpp/bindings/associated_interface_request.h" +#include "mojo/public/cpp/bindings/bindings_export.h" #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" namespace mojo { @@ -17,71 +15,34 @@ namespace mojo { class AssociatedGroupController; // AssociatedGroup refers to all the interface endpoints running at one end of a -// message pipe. It is used to create associated interfaces for that message -// pipe. +// message pipe. // It is thread safe and cheap to make copies. -class AssociatedGroup { +class MOJO_CPP_BINDINGS_EXPORT AssociatedGroup { public: - // Configuration used by CreateAssociatedInterface(). Please see the comments - // of that method for more details. - enum AssociatedInterfaceConfig { WILL_PASS_PTR, WILL_PASS_REQUEST }; - AssociatedGroup(); - AssociatedGroup(const AssociatedGroup& other); - ~AssociatedGroup(); - - AssociatedGroup& operator=(const AssociatedGroup& other); + explicit AssociatedGroup(scoped_refptr<AssociatedGroupController> controller); - // |config| indicates whether |ptr_info| or |request| will be sent to the - // remote side of the message pipe. - // - // NOTE: If |config| is |WILL_PASS_REQUEST|, you will want to bind |ptr_info| - // to a local AssociatedInterfacePtr to make calls. However, there is one - // restriction: the pointer should NOT be used to make calls before |request| - // is sent. Violating that will cause the message pipe to be closed. On the - // other hand, as soon as |request| is sent, the pointer is usable. There is - // no need to wait until |request| is bound to an implementation at the remote - // side. - template <typename T> - void CreateAssociatedInterface( - AssociatedInterfaceConfig config, - AssociatedInterfacePtrInfo<T>* ptr_info, - AssociatedInterfaceRequest<T>* request) { - ScopedInterfaceEndpointHandle local; - ScopedInterfaceEndpointHandle remote; - CreateEndpointHandlePair(&local, &remote); + explicit AssociatedGroup(const ScopedInterfaceEndpointHandle& handle); - if (!local.is_valid() || !remote.is_valid()) { - *ptr_info = AssociatedInterfacePtrInfo<T>(); - *request = AssociatedInterfaceRequest<T>(); - return; - } + AssociatedGroup(const AssociatedGroup& other); - if (config == WILL_PASS_PTR) { - ptr_info->set_handle(std::move(remote)); + ~AssociatedGroup(); - // The implementation is local, therefore set the version according to - // the interface definition that this code is built against. - ptr_info->set_version(T::Version_); - request->Bind(std::move(local)); - } else { - ptr_info->set_handle(std::move(local)); + AssociatedGroup& operator=(const AssociatedGroup& other); - // The implementation is remote, we don't know about its actual version - // yet. - ptr_info->set_version(0u); - request->Bind(std::move(remote)); - } - } + // The return value of this getter if this object is initialized with a + // ScopedInterfaceEndpointHandle: + // - If the handle is invalid, the return value will always be null. + // - If the handle is valid and non-pending, the return value will be + // non-null and remain unchanged even if the handle is later reset. + // - If the handle is pending asssociation, the return value will initially + // be null, change to non-null when/if the handle is associated, and + // remain unchanged ever since. + AssociatedGroupController* GetController(); private: - friend class AssociatedGroupController; - - void CreateEndpointHandlePair( - ScopedInterfaceEndpointHandle* local_endpoint, - ScopedInterfaceEndpointHandle* remote_endpoint); - + base::Callback<AssociatedGroupController*()> controller_getter_; scoped_refptr<AssociatedGroupController> controller_; }; |