summaryrefslogtreecommitdiff
path: root/mojo/public/c/system/buffer.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-03-24 10:38:40 +0900
committerQijiang Fan <fqj@google.com>2020-06-05 08:52:10 +0900
commit7d8c9b7952f774b8e60d23e3808b8f7521f23b53 (patch)
treed34137a018081a31b853a27932bdb2016351f13f /mojo/public/c/system/buffer.h
parentc2c9cfb27461019611de40444ca579ce41257b3e (diff)
downloadlibchrome-7d8c9b7952f774b8e60d23e3808b8f7521f23b53.tar.gz
Add a data length method to mojo::ScopedSharedBufferHandle.
BUG=788243 Change-Id: Icd243edd24295125599f09adbebcadec62487e89 Reviewed-on: https://chromium-review.googlesource.com/976689 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ken Rockot <rockot@chromium.org> Cr-Commit-Position: refs/heads/master@{#545656} CrOS-Libchrome-Original-Commit: 7b818885624401be6df25eff4cb6f3e16e43296d
Diffstat (limited to 'mojo/public/c/system/buffer.h')
-rw-r--r--mojo/public/c/system/buffer.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/mojo/public/c/system/buffer.h b/mojo/public/c/system/buffer.h
index 09f6d285f3..0e086fc3a2 100644
--- a/mojo/public/c/system/buffer.h
+++ b/mojo/public/c/system/buffer.h
@@ -43,6 +43,35 @@ struct MOJO_ALIGNAS(8) MojoCreateSharedBufferOptions {
MOJO_STATIC_ASSERT(sizeof(MojoCreateSharedBufferOptions) == 8,
"MojoCreateSharedBufferOptions has wrong size");
+// Flags passed to |MojoGetBufferInfo()| via |MojoSharedBufferOptions|.
+typedef uint32_t MojoSharedBufferOptionsFlags;
+
+#ifdef __cplusplus
+const MojoSharedBufferOptionsFlags MOJO_SHARED_BUFFER_OPTIONS_FLAG_NONE = 0;
+#else
+#define MOJO_SHARED_BUFFER_OPTIONS_FLAG_NONE ((MojoSharedBufferOptionsFlags)0)
+#endif
+
+struct MOJO_ALIGNAS(8) MojoSharedBufferOptions {
+ // The size of this structure, used for versioning.
+ uint32_t struct_size;
+
+ // See |MojoSharedBufferOptionsFlags|.
+ MojoSharedBufferOptionsFlags flags;
+};
+MOJO_STATIC_ASSERT(sizeof(MojoSharedBufferOptions) == 8,
+ "MojoSharedBufferOptions has wrong size");
+
+struct MOJO_ALIGNAS(8) MojoSharedBufferInfo {
+ // The size of this structure, used for versioning.
+ uint32_t struct_size;
+
+ // The size of the shared buffer.
+ uint64_t size;
+};
+MOJO_STATIC_ASSERT(sizeof(MojoSharedBufferInfo) == 16,
+ "MojoSharedBufferInfo has wrong size");
+
// |MojoDuplicateBufferHandleOptions|: Used to specify parameters in duplicating
// access to a shared buffer to |MojoDuplicateBufferHandle()|.
//
@@ -181,6 +210,21 @@ MOJO_SYSTEM_EXPORT MojoResult MojoMapBuffer(MojoHandle buffer_handle,
// result of |MojoMapBuffer()| or has already been unmapped).
MOJO_SYSTEM_EXPORT MojoResult MojoUnmapBuffer(void* buffer); // In.
+// Retrieve information about |buffer_handle| into |info|. |options| is optional
+// and reserved for future use.
+//
+// Returns:
+// |MOJO_RESULT_OK| on success.
+// |MOJO_RESULT_INVALID_ARGUMENT| if |buffer_handle| is invalid or if |info|
+// is NULL.
+//
+// On success, |info->size| will be set to the size of the buffer. On failure it
+// is not modified.
+MOJO_SYSTEM_EXPORT MojoResult
+MojoGetBufferInfo(MojoHandle buffer_handle,
+ const struct MojoSharedBufferOptions* options, // Optional.
+ struct MojoSharedBufferInfo* info); // Out.
+
#ifdef __cplusplus
} // extern "C"
#endif