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

Unified Diff: mojo/system/message_pipe.h

Issue 60103005: Mojo: First stab at making MessagePipes work across OS pipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 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
Index: mojo/system/message_pipe.h
diff --git a/mojo/system/message_pipe.h b/mojo/system/message_pipe.h
index bb2f4ff0a7d8366551c988333d02c5bfaef49261..67f99d2f584e1ed7ebf717c8f6311ac923ae8218 100644
--- a/mojo/system/message_pipe.h
+++ b/mojo/system/message_pipe.h
@@ -6,15 +6,18 @@
#define MOJO_SYSTEM_MESSAGE_PIPE_H_
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "mojo/public/system/core.h"
#include "mojo/public/system/system_export.h"
+#include "mojo/system/message_in_transit.h"
namespace mojo {
namespace system {
+class Channel;
class MessagePipeEndpoint;
class Waiter;
@@ -32,6 +35,9 @@ class MOJO_SYSTEM_EXPORT MessagePipe :
// |LocalMessagePipeEndpoint|s.
MessagePipe();
+ // Gets the other port number (i.e., 0 -> 1, 1 -> 0).
+ static unsigned GetPeerPort(unsigned port);
+
// These are called by the dispatcher to implement its methods of
// corresponding names. In all cases, the port |port| must be open.
void CancelAllWaiters(unsigned port);
@@ -54,10 +60,26 @@ class MOJO_SYSTEM_EXPORT MessagePipe :
MojoResult wake_result);
void RemoveWaiter(unsigned port, Waiter* waiter);
+ // This is used internally by |WriteMessage()| and by |Channel| to enqueue
+ // messages (typically to a |LocalMessagePipeEndpoint|). Unlike
+ // |WriteMessage()|, |port| is the *destination* port. Takes ownership of
+ // |message|.
+ MojoResult EnqueueMessage(unsigned port, MessageInTransit* message);
+
+ // These are used by |Channel|.
+ void Attach(unsigned port,
+ scoped_refptr<Channel> channel,
+ MessageInTransit::EndpointId local_id);
+ void Run(unsigned port, MessageInTransit::EndpointId remote_id);
+
private:
friend class base::RefCountedThreadSafe<MessagePipe>;
virtual ~MessagePipe();
+ // Used by |EnqueueMessage()| to handle control messages that are actually
+ // meant for us.
+ MojoResult HandleControlMessage(unsigned port, MessageInTransit* message);
+
base::Lock lock_; // Protects the following members.
scoped_ptr<MessagePipeEndpoint> endpoints_[2];

Powered by Google App Engine
This is Rietveld 408576698