aboutsummaryrefslogtreecommitdiff
path: root/mojo/public/cpp/bindings/associated_group_controller.h
diff options
context:
space:
mode:
authorLuis Hector Chavez <lhchavez@google.com>2017-07-26 17:38:05 +0000
committerLuis Hector Chavez <lhchavez@google.com>2017-07-26 17:38:05 +0000
commit21a249e4d9cb0b2ec6f0ff84ed5f7939ea67ac52 (patch)
treed380c2689495d31fd250cf8f1d0ceebbdd4cf250 /mojo/public/cpp/bindings/associated_group_controller.h
parent8ac9103e05b66812c25348943383f9365d1ce3e0 (diff)
downloadlibmojo-21a249e4d9cb0b2ec6f0ff84ed5f7939ea67ac52.tar.gz
Revert "libmojo: Uprev the library to r456626 from Chromium"
This reverts commit 8ac9103e05b66812c25348943383f9365d1ce3e0. Reason for revert: Broke the mac_sdk Exempt-From-Owner-Approval: Fixing mac_sdk Change-Id: I0b74d1abaa66933a93fd6f82ff018e8948c1204e
Diffstat (limited to 'mojo/public/cpp/bindings/associated_group_controller.h')
-rw-r--r--mojo/public/cpp/bindings/associated_group_controller.h60
1 files changed, 26 insertions, 34 deletions
diff --git a/mojo/public/cpp/bindings/associated_group_controller.h b/mojo/public/cpp/bindings/associated_group_controller.h
index d33c277..0ab8253 100644
--- a/mojo/public/cpp/bindings/associated_group_controller.h
+++ b/mojo/public/cpp/bindings/associated_group_controller.h
@@ -9,47 +9,41 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/optional.h"
+#include "base/memory/ref_counted_delete_on_message_loop.h"
#include "base/single_thread_task_runner.h"
-#include "mojo/public/cpp/bindings/bindings_export.h"
-#include "mojo/public/cpp/bindings/disconnect_reason.h"
#include "mojo/public/cpp/bindings/interface_id.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
namespace mojo {
+class AssociatedGroup;
class InterfaceEndpointClient;
class InterfaceEndpointController;
-// An internal interface used to manage endpoints within an associated group,
-// which corresponds to one end of a message pipe.
-class MOJO_CPP_BINDINGS_EXPORT AssociatedGroupController
- : public base::RefCountedThreadSafe<AssociatedGroupController> {
+// An internal interface used to manage endpoints within an associated group.
+class AssociatedGroupController :
+ public base::RefCountedDeleteOnMessageLoop<AssociatedGroupController> {
public:
- // Associates an interface with this AssociatedGroupController's message pipe.
- // It takes ownership of |handle_to_send| and returns an interface ID that
- // could be sent by any endpoints within the same associated group.
- // If |handle_to_send| is not in pending association state, it returns
- // kInvalidInterfaceId. Otherwise, the peer handle of |handle_to_send| joins
- // the associated group and is no longer pending.
- virtual InterfaceId AssociateInterface(
- ScopedInterfaceEndpointHandle handle_to_send) = 0;
+ explicit AssociatedGroupController(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+
+ // Creates a pair of interface endpoint handles. The method generates a new
+ // interface ID and assigns it to the two handles. |local_endpoint| is used
+ // locally; while |remote_endpoint| is sent over the message pipe.
+ virtual void CreateEndpointHandlePair(
+ ScopedInterfaceEndpointHandle* local_endpoint,
+ ScopedInterfaceEndpointHandle* remote_endpoint) = 0;
// Creates an interface endpoint handle from a given interface ID. The handle
- // joins this associated group.
+ // is used locally.
// Typically, this method is used to (1) create an endpoint handle for the
// master interface; or (2) create an endpoint handle on receiving an
// interface ID from the message pipe.
- //
- // On failure, the method returns an invalid handle. Usually that is because
- // the ID has already been used to create a handle.
virtual ScopedInterfaceEndpointHandle CreateLocalEndpointHandle(
InterfaceId id) = 0;
// Closes an interface endpoint handle.
- virtual void CloseEndpointHandle(
- InterfaceId id,
- const base::Optional<DisconnectReason>& reason) = 0;
+ virtual void CloseEndpointHandle(InterfaceId id, bool is_local) = 0;
// Attaches a client to the specified endpoint to send and receive messages.
// The returned object is still owned by the controller. It must only be used
@@ -69,23 +63,21 @@ class MOJO_CPP_BINDINGS_EXPORT AssociatedGroupController
// and notifies all interfaces running on this pipe.
virtual void RaiseError() = 0;
+ std::unique_ptr<AssociatedGroup> CreateAssociatedGroup();
+
protected:
- friend class base::RefCountedThreadSafe<AssociatedGroupController>;
+ friend class base::RefCountedDeleteOnMessageLoop<AssociatedGroupController>;
+ friend class base::DeleteHelper<AssociatedGroupController>;
- // Creates a new ScopedInterfaceEndpointHandle within this associated group.
+ // Creates a new ScopedInterfaceEndpointHandle associated with this
+ // controller.
ScopedInterfaceEndpointHandle CreateScopedInterfaceEndpointHandle(
- InterfaceId id);
-
- // Notifies that the interface represented by |handle_to_send| and its peer
- // has been associated with this AssociatedGroupController's message pipe, and
- // |handle_to_send|'s peer has joined this associated group. (Note: it is the
- // peer who has joined the associated group; |handle_to_send| will be sent to
- // the remote side.)
- // Returns false if |handle_to_send|'s peer has closed.
- bool NotifyAssociation(ScopedInterfaceEndpointHandle* handle_to_send,
- InterfaceId id);
+ InterfaceId id,
+ bool is_local);
virtual ~AssociatedGroupController();
+
+ DISALLOW_COPY_AND_ASSIGN(AssociatedGroupController);
};
} // namespace mojo