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

Unified Diff: mojo/edk/system/message_pipe.h

Issue 738453003: Add a ChannelEndpointClient abstraction. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: review comments Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/channel_endpoint_client.h ('k') | mojo/edk/system/message_pipe.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/message_pipe.h
diff --git a/mojo/edk/system/message_pipe.h b/mojo/edk/system/message_pipe.h
index b39e5170e7b1473444d0cc7199b27dc0e399a301..90af7cba0a9600c1a4dc075ceb7b800db1fb2004 100644
--- a/mojo/edk/system/message_pipe.h
+++ b/mojo/edk/system/message_pipe.h
@@ -15,6 +15,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "mojo/edk/embedder/platform_handle_vector.h"
+#include "mojo/edk/system/channel_endpoint_client.h"
#include "mojo/edk/system/dispatcher.h"
#include "mojo/edk/system/handle_signals_state.h"
#include "mojo/edk/system/memory.h"
@@ -34,8 +35,7 @@ class Waiter;
// |MessagePipe| is the secondary object implementing a message pipe (see the
// explanatory comment in core.cc). It is typically owned by the dispatcher(s)
// corresponding to the local endpoints. This class is thread-safe.
-class MOJO_SYSTEM_IMPL_EXPORT MessagePipe
- : public base::RefCountedThreadSafe<MessagePipe> {
+class MOJO_SYSTEM_IMPL_EXPORT MessagePipe : public ChannelEndpointClient {
public:
// Creates a |MessagePipe| with two new |LocalMessagePipeEndpoint|s.
static MessagePipe* CreateLocalLocal();
@@ -110,34 +110,30 @@ class MOJO_SYSTEM_IMPL_EXPORT MessagePipe
// |EndSerialize()|).
scoped_refptr<ChannelEndpoint> ConvertLocalToProxy(unsigned port);
- // This is used by |Channel| to enqueue messages (typically to a
- // |LocalMessagePipeEndpoint|). Unlike |WriteMessage()|, |port| is the
- // *destination* port.
- MojoResult EnqueueMessage(unsigned port,
- scoped_ptr<MessageInTransit> message);
+ // |ChannelEndpointClient| methods:
+ bool OnReadMessage(unsigned port,
+ scoped_ptr<MessageInTransit> message) override;
+ void OnDetachFromChannel(unsigned port) override;
private:
MessagePipe();
+ virtual ~MessagePipe();
- friend class base::RefCountedThreadSafe<MessagePipe>;
- ~MessagePipe();
-
- // This is used internally by |WriteMessage()| and by |EnqueueMessage()|.
+ // This is used internally by |WriteMessage()| and by |OnReadMessage()|.
// |transports| may be non-null only if it's nonempty and |message| has no
// dispatchers attached.
- MojoResult EnqueueMessageInternal(
- unsigned port,
- scoped_ptr<MessageInTransit> message,
- std::vector<DispatcherTransport>* transports);
+ MojoResult EnqueueMessage(unsigned port,
+ scoped_ptr<MessageInTransit> message,
+ std::vector<DispatcherTransport>* transports);
- // Helper for |EnqueueMessageInternal()|. Must be called with |lock_| held.
+ // Helper for |EnqueueMessage()|. Must be called with |lock_| held.
MojoResult AttachTransportsNoLock(
unsigned port,
MessageInTransit* message,
std::vector<DispatcherTransport>* transports);
- // Used by |EnqueueMessageInternal()| to handle control messages that are
- // actually meant for us.
+ // Used by |EnqueueMessage()| to handle control messages that are actually
+ // meant for us.
MojoResult HandleControlMessage(unsigned port,
scoped_ptr<MessageInTransit> message);
« no previous file with comments | « mojo/edk/system/channel_endpoint_client.h ('k') | mojo/edk/system/message_pipe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698