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

Unified Diff: mojo/system/message_pipe_endpoint.h

Issue 27060003: Mojo: Abstract out the endpoints of MessagePipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: mojo/system/message_pipe_endpoint.h
diff --git a/mojo/system/message_pipe_endpoint.h b/mojo/system/message_pipe_endpoint.h
new file mode 100644
index 0000000000000000000000000000000000000000..adb9ede232d1d9ff00eeb640d118553e6155b232
--- /dev/null
+++ b/mojo/system/message_pipe_endpoint.h
@@ -0,0 +1,59 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_
+#define MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_
+
+#include "base/basictypes.h"
+#include "mojo/public/system/core.h"
+
+namespace mojo {
+namespace system {
+
+class Waiter;
+
+// This is an interface to one of the ends of a message pipe, and is used by
+// |MessagePipe|. Its most important role is to provide a sink for messages
+// (i.e., a place where messages can be sent). It has a secondary role: When the
+// endpoint is local (i.e., in the current process), there'll be a dispatcher
+// corresponding to the endpoint, and |MessagePipeEndpoint| also implements the
darin (slow to review) 2013/10/15 06:50:36 nit: Is the comment "|MessagePipeEndpoint| also im
viettrungluu 2013/10/15 17:48:58 Errr, "the implementation of |MessagePipeEndpoint|
+// requisite functionality, e.g., to read messages and to wait. This class is
+// not thread-safe; instances are protected by |MesssagePipe|'s lock.
+class MessagePipeEndpoint {
+ public:
+ virtual ~MessagePipeEndpoint() {}
+
+ // All implementations must implement these.
+ virtual void OnPeerClose() = 0;
+ virtual MojoResult EnqueueMessage(
+ const void* bytes, uint32_t num_bytes,
+ const MojoHandle* handles, uint32_t num_handles,
+ MojoWriteMessageFlags flags) = 0;
+
+ // Implementations must implement/override these if they are "connected" to a
+ // local |MessagePipeDispatcher| (the default implementations should never be
darin (slow to review) 2013/10/15 06:50:36 I'm having trouble following this design. Are you
viettrungluu 2013/10/15 17:48:58 A MessagePipeDispatcher corresponds to a handle, s
+ // called). They implement the methods of the same name in |MessagePipe|,
+ // though |MessagePipe|'s implementation may have to do a little more if the
+ // operation involves both endpoints.
+ virtual void CancelAllWaiters();
+ virtual void Close();
+ virtual MojoResult ReadMessage(void* bytes, uint32_t* num_bytes,
+ MojoHandle* handles, uint32_t* num_handles,
+ MojoReadMessageFlags flags);
+ virtual MojoResult AddWaiter(Waiter* waiter,
+ MojoWaitFlags flags,
+ MojoResult wake_result);
+ virtual void RemoveWaiter(Waiter* waiter);
+
+ protected:
+ MessagePipeEndpoint() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MessagePipeEndpoint);
+};
+
+} // namespace system
+} // namespace mojo
+
+#endif // MOJO_SYSTEM_MESSAGE_PIPE_ENDPOINT_H_

Powered by Google App Engine
This is Rietveld 408576698