summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-28 00:11:43 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-28 00:11:43 +0000
commit3f3b2b1a9c5a0df3af94f27cf1aeaf747229777c (patch)
treea06dabd01f95e187e9c65fee90450f79689abf05
parent0d98fb2da82a0abdd3a82821d48426aa5d7e9cd8 (diff)
downloadchromium_src-3f3b2b1a9c5a0df3af94f27cf1aeaf747229777c.zip
chromium_src-3f3b2b1a9c5a0df3af94f27cf1aeaf747229777c.tar.gz
chromium_src-3f3b2b1a9c5a0df3af94f27cf1aeaf747229777c.tar.bz2
Mojo: Move message pipe types/constants/functions from mojo/public/c/system/core.h to .../message_pipe.h.
R=sky@chromium.org Review URL: https://codereview.chromium.org/298273005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273082 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--mojo/mojo_public.gypi1
-rw-r--r--mojo/public/c/system/core.h131
-rw-r--r--mojo/public/c/system/functions.h8
-rw-r--r--mojo/public/c/system/message_pipe.h146
-rw-r--r--mojo/system/core.h1
-rw-r--r--mojo/system/dispatcher.h2
-rw-r--r--mojo/system/local_message_pipe_endpoint.h1
-rw-r--r--mojo/system/message_pipe.h3
-rw-r--r--mojo/system/message_pipe_endpoint.h3
-rw-r--r--mojo/system/proxy_message_pipe_endpoint.h1
10 files changed, 161 insertions, 136 deletions
diff --git a/mojo/mojo_public.gypi b/mojo/mojo_public.gypi
index 166d8da..1caa854 100644
--- a/mojo/mojo_public.gypi
+++ b/mojo/mojo_public.gypi
@@ -29,6 +29,7 @@
'public/c/system/core.h',
'public/c/system/functions.h',
'public/c/system/macros.h',
+ 'public/c/system/message_pipe.h',
'public/c/system/system_export.h',
'public/c/system/types.h',
'public/platform/native/system_thunks.cc',
diff --git a/mojo/public/c/system/core.h b/mojo/public/c/system/core.h
index 199d918..9531494 100644
--- a/mojo/public/c/system/core.h
+++ b/mojo/public/c/system/core.h
@@ -7,10 +7,9 @@
#ifndef MOJO_PUBLIC_C_SYSTEM_CORE_H_
#define MOJO_PUBLIC_C_SYSTEM_CORE_H_
-#include <stdint.h>
-
#include "mojo/public/c/system/functions.h"
#include "mojo/public/c/system/macros.h"
+#include "mojo/public/c/system/message_pipe.h"
#include "mojo/public/c/system/system_export.h"
#include "mojo/public/c/system/types.h"
@@ -18,37 +17,6 @@
// TODO(vtl): Split these into their own header files.
-// Message pipe:
-
-// |MojoWriteMessageFlags|: Used to specify different modes to
-// |MojoWriteMessage()|.
-// |MOJO_WRITE_MESSAGE_FLAG_NONE| - No flags; default mode.
-
-typedef uint32_t MojoWriteMessageFlags;
-
-#ifdef __cplusplus
-const MojoWriteMessageFlags MOJO_WRITE_MESSAGE_FLAG_NONE = 0;
-#else
-#define MOJO_WRITE_MESSAGE_FLAG_NONE ((MojoWriteMessageFlags) 0)
-#endif
-
-// |MojoReadMessageFlags|: Used to specify different modes to
-// |MojoReadMessage()|.
-// |MOJO_READ_MESSAGE_FLAG_NONE| - No flags; default mode.
-// |MOJO_READ_MESSAGE_FLAG_MAY_DISCARD| - If the message is unable to be read
-// for whatever reason (e.g., the caller-supplied buffer is too small),
-// discard the message (i.e., simply dequeue it).
-
-typedef uint32_t MojoReadMessageFlags;
-
-#ifdef __cplusplus
-const MojoReadMessageFlags MOJO_READ_MESSAGE_FLAG_NONE = 0;
-const MojoReadMessageFlags MOJO_READ_MESSAGE_FLAG_MAY_DISCARD = 1 << 0;
-#else
-#define MOJO_READ_MESSAGE_FLAG_NONE ((MojoReadMessageFlags) 0)
-#define MOJO_READ_MESSAGE_FLAG_MAY_DISCARD ((MojoReadMessageFlags) 1 << 0)
-#endif
-
// Data pipe:
// |MojoCreateDataPipeOptions|: Used to specify creation parameters for a data
@@ -207,105 +175,12 @@ const MojoMapBufferFlags MOJO_MAP_BUFFER_FLAG_NONE = 0;
// Functions -------------------------------------------------------------------
-// Note: See the comment in functions.h about the meaning of the "optional"
-// label for pointer parameters.
-
#ifdef __cplusplus
extern "C" {
#endif
-// Message pipe:
-
-// Creates a message pipe, which is a bidirectional communication channel for
-// framed data (i.e., messages). Messages can contain plain data and/or Mojo
-// handles. On success, |*message_pipe_handle0| and |*message_pipe_handle1| are
-// set to handles for the two endpoints (ports) for the message pipe.
-//
-// Returns:
-// |MOJO_RESULT_OK| on success.
-// |MOJO_RESULT_INVALID_ARGUMENT| if |message_pipe_handle0| and/or
-// |message_pipe_handle1| do not appear to be valid pointers.
-// |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has
-// been reached.
-//
-// TODO(vtl): Add an options struct pointer argument.
-MOJO_SYSTEM_EXPORT MojoResult MojoCreateMessagePipe(
- MojoHandle* message_pipe_handle0, // Out.
- MojoHandle* message_pipe_handle1); // Out.
-
-// Writes a message to the message pipe endpoint given by |message_pipe_handle|,
-// with message data specified by |bytes| of size |num_bytes| and attached
-// handles specified by |handles| of count |num_handles|, and options specified
-// by |flags|. If there is no message data, |bytes| may be null, in which case
-// |num_bytes| must be zero. If there are no attached handles, |handles| may be
-// null, in which case |num_handles| must be zero.
-//
-// If handles are attached, on success the handles will no longer be valid (the
-// receiver will receive equivalent, but logically different, handles). Handles
-// to be sent should not be in simultaneous use (e.g., on another thread).
-//
-// Returns:
-// |MOJO_RESULT_OK| on success (i.e., the message was enqueued).
-// |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., if
-// |message_pipe_handle| is not a valid handle, or some of the
-// requirements above are not satisfied).
-// |MOJO_RESULT_RESOURCE_EXHAUSTED| if some system limit has been reached, or
-// the number of handles to send is too large (TODO(vtl): reconsider the
-// latter case).
-// |MOJO_RESULT_FAILED_PRECONDITION| if the other endpoint has been closed.
-// Note that closing an endpoint is not necessarily synchronous (e.g.,
-// across processes), so this function may be succeed even if the other
-// endpoint has been closed (in which case the message would be dropped).
-// |MOJO_RESULT_BUSY| if some handle to be sent is currently in use.
-//
-// TODO(vtl): Add a notion of capacity for message pipes, and return
-// |MOJO_RESULT_SHOULD_WAIT| if the message pipe is full.
-MOJO_SYSTEM_EXPORT MojoResult MojoWriteMessage(
- MojoHandle message_pipe_handle,
- const void* bytes, // Optional.
- uint32_t num_bytes,
- const MojoHandle* handles, // Optional.
- uint32_t num_handles,
- MojoWriteMessageFlags flags);
-
-// Reads a message from the message pipe endpoint given by
-// |message_pipe_handle|; also usable to query the size of the next message or
-// discard the next message. |bytes|/|*num_bytes| indicate the buffer/buffer
-// size to receive the message data (if any) and |handles|/|*num_handles|
-// indicate the buffer/maximum handle count to receive the attached handles (if
-// any).
-//
-// |num_bytes| and |num_handles| are optional "in-out" parameters. If non-null,
-// on return |*num_bytes| and |*num_handles| will usually indicate the number
-// of bytes and number of attached handles in the "next" message, respectively,
-// whether that message was read or not. (If null, the number of bytes/handles
-// is treated as zero.)
-//
-// If |bytes| is null, then |*num_bytes| must be zero, and similarly for
-// |handles| and |*num_handles|.
-//
-// Partial reads are NEVER done. Either a full read is done and |MOJO_RESULT_OK|
-// returned, or the read is NOT done and |MOJO_RESULT_RESOURCE_EXHAUSTED| is
-// returned (if |MOJO_READ_MESSAGE_FLAG_MAY_DISCARD| was set, the message is
-// also discarded in this case).
-//
-// Returns:
-// |MOJO_RESULT_OK| on success (i.e., a message was actually read).
-// |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid.
-// |MOJO_RESULT_FAILED_PRECONDITION| if the other endpoint has been closed.
-// |MOJO_RESULT_RESOURCE_EXHAUSTED| if one of the buffers to receive the
-// message/attached handles (|bytes|/|*num_bytes| or
-// |handles|/|*num_handles|) was too small. (TODO(vtl): Reconsider this
-// error code; should distinguish this from the hitting-system-limits
-// case.)
-// |MOJO_RESULT_SHOULD_WAIT| if no message was available to be read.
-MOJO_SYSTEM_EXPORT MojoResult MojoReadMessage(
- MojoHandle message_pipe_handle,
- void* bytes, // Optional out.
- uint32_t* num_bytes, // Optional in/out.
- MojoHandle* handles, // Optional out.
- uint32_t* num_handles, // Optional in/out.
- MojoReadMessageFlags flags);
+// Note: See the comment in functions.h about the meaning of the "optional"
+// label for pointer parameters.
// Data pipe:
diff --git a/mojo/public/c/system/functions.h b/mojo/public/c/system/functions.h
index fa2bd06..a0330fe 100644
--- a/mojo/public/c/system/functions.h
+++ b/mojo/public/c/system/functions.h
@@ -14,6 +14,10 @@
#include "mojo/public/c/system/system_export.h"
#include "mojo/public/c/system/types.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
// Note: Pointer parameters that are labelled "optional" may be null (at least
// under some circumstances). Non-const pointer parameters are also labeled
// "in", "out", or "in/out", to indicate how they are used. (Note that how/if
@@ -21,10 +25,6 @@
// operation's success/failure. E.g., a separate |flags| parameter may control
// whether a given "in/out" parameter is used for input, output, or both.)
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// Platform-dependent monotonically increasing tick count representing "right
// now." The resolution of this clock is ~1-15ms. Resolution varies depending
// on hardware/operating system configuration.
diff --git a/mojo/public/c/system/message_pipe.h b/mojo/public/c/system/message_pipe.h
new file mode 100644
index 0000000..ffedd9e
--- /dev/null
+++ b/mojo/public/c/system/message_pipe.h
@@ -0,0 +1,146 @@
+// Copyright 2014 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.
+
+// This file contains types/constants and functions specific to message pipes.
+
+// Note: This header should be compilable as C.
+
+#ifndef MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_
+#define MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_
+
+#include "mojo/public/c/system/system_export.h"
+#include "mojo/public/c/system/types.h"
+
+// |MojoWriteMessageFlags|: Used to specify different modes to
+// |MojoWriteMessage()|.
+// |MOJO_WRITE_MESSAGE_FLAG_NONE| - No flags; default mode.
+
+typedef uint32_t MojoWriteMessageFlags;
+
+#ifdef __cplusplus
+const MojoWriteMessageFlags MOJO_WRITE_MESSAGE_FLAG_NONE = 0;
+#else
+#define MOJO_WRITE_MESSAGE_FLAG_NONE ((MojoWriteMessageFlags) 0)
+#endif
+
+// |MojoReadMessageFlags|: Used to specify different modes to
+// |MojoReadMessage()|.
+// |MOJO_READ_MESSAGE_FLAG_NONE| - No flags; default mode.
+// |MOJO_READ_MESSAGE_FLAG_MAY_DISCARD| - If the message is unable to be read
+// for whatever reason (e.g., the caller-supplied buffer is too small),
+// discard the message (i.e., simply dequeue it).
+
+typedef uint32_t MojoReadMessageFlags;
+
+#ifdef __cplusplus
+const MojoReadMessageFlags MOJO_READ_MESSAGE_FLAG_NONE = 0;
+const MojoReadMessageFlags MOJO_READ_MESSAGE_FLAG_MAY_DISCARD = 1 << 0;
+#else
+#define MOJO_READ_MESSAGE_FLAG_NONE ((MojoReadMessageFlags) 0)
+#define MOJO_READ_MESSAGE_FLAG_MAY_DISCARD ((MojoReadMessageFlags) 1 << 0)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Note: See the comment in functions.h about the meaning of the "optional"
+// label for pointer parameters.
+
+// Creates a message pipe, which is a bidirectional communication channel for
+// framed data (i.e., messages). Messages can contain plain data and/or Mojo
+// handles. On success, |*message_pipe_handle0| and |*message_pipe_handle1| are
+// set to handles for the two endpoints (ports) for the message pipe.
+//
+// Returns:
+// |MOJO_RESULT_OK| on success.
+// |MOJO_RESULT_INVALID_ARGUMENT| if |message_pipe_handle0| and/or
+// |message_pipe_handle1| do not appear to be valid pointers.
+// |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has
+// been reached.
+//
+// TODO(vtl): Add an options struct pointer argument.
+MOJO_SYSTEM_EXPORT MojoResult MojoCreateMessagePipe(
+ MojoHandle* message_pipe_handle0, // Out.
+ MojoHandle* message_pipe_handle1); // Out.
+
+// Writes a message to the message pipe endpoint given by |message_pipe_handle|,
+// with message data specified by |bytes| of size |num_bytes| and attached
+// handles specified by |handles| of count |num_handles|, and options specified
+// by |flags|. If there is no message data, |bytes| may be null, in which case
+// |num_bytes| must be zero. If there are no attached handles, |handles| may be
+// null, in which case |num_handles| must be zero.
+//
+// If handles are attached, on success the handles will no longer be valid (the
+// receiver will receive equivalent, but logically different, handles). Handles
+// to be sent should not be in simultaneous use (e.g., on another thread).
+//
+// Returns:
+// |MOJO_RESULT_OK| on success (i.e., the message was enqueued).
+// |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., if
+// |message_pipe_handle| is not a valid handle, or some of the
+// requirements above are not satisfied).
+// |MOJO_RESULT_RESOURCE_EXHAUSTED| if some system limit has been reached, or
+// the number of handles to send is too large (TODO(vtl): reconsider the
+// latter case).
+// |MOJO_RESULT_FAILED_PRECONDITION| if the other endpoint has been closed.
+// Note that closing an endpoint is not necessarily synchronous (e.g.,
+// across processes), so this function may be succeed even if the other
+// endpoint has been closed (in which case the message would be dropped).
+// |MOJO_RESULT_BUSY| if some handle to be sent is currently in use.
+//
+// TODO(vtl): Add a notion of capacity for message pipes, and return
+// |MOJO_RESULT_SHOULD_WAIT| if the message pipe is full.
+MOJO_SYSTEM_EXPORT MojoResult MojoWriteMessage(
+ MojoHandle message_pipe_handle,
+ const void* bytes, // Optional.
+ uint32_t num_bytes,
+ const MojoHandle* handles, // Optional.
+ uint32_t num_handles,
+ MojoWriteMessageFlags flags);
+
+// Reads a message from the message pipe endpoint given by
+// |message_pipe_handle|; also usable to query the size of the next message or
+// discard the next message. |bytes|/|*num_bytes| indicate the buffer/buffer
+// size to receive the message data (if any) and |handles|/|*num_handles|
+// indicate the buffer/maximum handle count to receive the attached handles (if
+// any).
+//
+// |num_bytes| and |num_handles| are optional "in-out" parameters. If non-null,
+// on return |*num_bytes| and |*num_handles| will usually indicate the number
+// of bytes and number of attached handles in the "next" message, respectively,
+// whether that message was read or not. (If null, the number of bytes/handles
+// is treated as zero.)
+//
+// If |bytes| is null, then |*num_bytes| must be zero, and similarly for
+// |handles| and |*num_handles|.
+//
+// Partial reads are NEVER done. Either a full read is done and |MOJO_RESULT_OK|
+// returned, or the read is NOT done and |MOJO_RESULT_RESOURCE_EXHAUSTED| is
+// returned (if |MOJO_READ_MESSAGE_FLAG_MAY_DISCARD| was set, the message is
+// also discarded in this case).
+//
+// Returns:
+// |MOJO_RESULT_OK| on success (i.e., a message was actually read).
+// |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid.
+// |MOJO_RESULT_FAILED_PRECONDITION| if the other endpoint has been closed.
+// |MOJO_RESULT_RESOURCE_EXHAUSTED| if one of the buffers to receive the
+// message/attached handles (|bytes|/|*num_bytes| or
+// |handles|/|*num_handles|) was too small. (TODO(vtl): Reconsider this
+// error code; should distinguish this from the hitting-system-limits
+// case.)
+// |MOJO_RESULT_SHOULD_WAIT| if no message was available to be read.
+MOJO_SYSTEM_EXPORT MojoResult MojoReadMessage(
+ MojoHandle message_pipe_handle,
+ void* bytes, // Optional out.
+ uint32_t* num_bytes, // Optional in/out.
+ MojoHandle* handles, // Optional out.
+ uint32_t* num_handles, // Optional in/out.
+ MojoReadMessageFlags flags);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_
diff --git a/mojo/system/core.h b/mojo/system/core.h
index e97c61b..60c15db 100644
--- a/mojo/system/core.h
+++ b/mojo/system/core.h
@@ -10,6 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
#include "mojo/public/c/system/core.h"
+#include "mojo/public/c/system/message_pipe.h"
#include "mojo/public/c/system/types.h"
#include "mojo/system/handle_table.h"
#include "mojo/system/mapping_table.h"
diff --git a/mojo/system/dispatcher.h b/mojo/system/dispatcher.h
index c96dba8..eb26291 100644
--- a/mojo/system/dispatcher.h
+++ b/mojo/system/dispatcher.h
@@ -17,6 +17,8 @@
#include "mojo/embedder/platform_handle.h"
#include "mojo/embedder/platform_handle_vector.h"
#include "mojo/public/c/system/core.h"
+#include "mojo/public/c/system/message_pipe.h"
+#include "mojo/public/c/system/types.h"
#include "mojo/system/system_impl_export.h"
namespace mojo {
diff --git a/mojo/system/local_message_pipe_endpoint.h b/mojo/system/local_message_pipe_endpoint.h
index d30f54b..fdc3211 100644
--- a/mojo/system/local_message_pipe_endpoint.h
+++ b/mojo/system/local_message_pipe_endpoint.h
@@ -7,7 +7,6 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "mojo/public/c/system/core.h"
#include "mojo/system/message_in_transit_queue.h"
#include "mojo/system/message_pipe_endpoint.h"
#include "mojo/system/system_impl_export.h"
diff --git a/mojo/system/message_pipe.h b/mojo/system/message_pipe.h
index 10668da..ca0155d 100644
--- a/mojo/system/message_pipe.h
+++ b/mojo/system/message_pipe.h
@@ -11,7 +11,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
-#include "mojo/public/c/system/core.h"
+#include "mojo/public/c/system/message_pipe.h"
+#include "mojo/public/c/system/types.h"
#include "mojo/system/dispatcher.h"
#include "mojo/system/message_in_transit.h"
#include "mojo/system/message_pipe_endpoint.h"
diff --git a/mojo/system/message_pipe_endpoint.h b/mojo/system/message_pipe_endpoint.h
index 46a67e1..331d7af 100644
--- a/mojo/system/message_pipe_endpoint.h
+++ b/mojo/system/message_pipe_endpoint.h
@@ -12,7 +12,8 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "mojo/public/c/system/core.h"
+#include "mojo/public/c/system/message_pipe.h"
+#include "mojo/public/c/system/types.h"
#include "mojo/system/dispatcher.h"
#include "mojo/system/message_in_transit.h"
#include "mojo/system/system_impl_export.h"
diff --git a/mojo/system/proxy_message_pipe_endpoint.h b/mojo/system/proxy_message_pipe_endpoint.h
index 28b634d..f3e9b1d 100644
--- a/mojo/system/proxy_message_pipe_endpoint.h
+++ b/mojo/system/proxy_message_pipe_endpoint.h
@@ -10,7 +10,6 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "mojo/public/c/system/core.h"
#include "mojo/system/message_in_transit.h"
#include "mojo/system/message_in_transit_queue.h"
#include "mojo/system/message_pipe_endpoint.h"