Chromium Code Reviews| Index: mojo/public/c/system/buffer.h |
| diff --git a/mojo/public/c/system/buffer.h b/mojo/public/c/system/buffer.h |
| index 7c5bceca67bdcacf430bb34523b3edbbd92d4009..8aa25a5bf300789fd31999d0b64324536603d268 100644 |
| --- a/mojo/public/c/system/buffer.h |
| +++ b/mojo/public/c/system/buffer.h |
| @@ -41,7 +41,7 @@ MOJO_STATIC_ASSERT(sizeof(MojoCreateSharedBufferOptions) == 8, |
| "MojoCreateSharedBufferOptions has wrong size"); |
| // |MojoDuplicateBufferHandleOptions|: Used to specify parameters in duplicating |
| -// access to a shared buffer to |MojoDuplicateBufferHandle()|. |
| +// access to a buffer to |MojoDuplicateBufferHandle()|. |
| // |uint32_t struct_size|: Set to the size of the |
| // |MojoDuplicateBufferHandleOptions| struct. (Used to allow for future |
| // extensions.) |
| @@ -56,13 +56,34 @@ typedef uint32_t MojoDuplicateBufferHandleOptionsFlags; |
| #define MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE \ |
| ((MojoDuplicateBufferHandleOptionsFlags)0) |
| -struct MojoDuplicateBufferHandleOptions { |
| +struct MOJO_ALIGNAS(8) MojoDuplicateBufferHandleOptions { |
|
viettrungluu
2016/03/01 20:36:20
This is an ABI-breaking change, but luckily, no on
|
| uint32_t struct_size; |
| MojoDuplicateBufferHandleOptionsFlags flags; |
| }; |
| MOJO_STATIC_ASSERT(sizeof(MojoDuplicateBufferHandleOptions) == 8, |
| "MojoDuplicateBufferHandleOptions has wrong size"); |
| +// |MojoBufferInformation|: Used to provide information about a buffer (see |
| +// |MojoGetBufferInformation()|. |
| +// |uint32_t struct_size|: Set to the size of the |MojoBufferInformation| |
| +// struct. (Used to allow for future extensions.) |
| +// |MojoBufferInformationFlags flags|: Reserved for future use. |
| +// |uint64_t num_bytes|: Size of the buffer. |
| +// |
| +// TODO(vtl): Add flags to indicate writability, etc.? Also, type of buffer? |
| + |
| +typedef uint32_t MojoBufferInformationFlags; |
| + |
| +#define MOJO_BUFFER_INFORMATION_FLAG_NONE ((MojoBufferInformationFlags)0) |
| + |
| +struct MOJO_ALIGNAS(8) MojoBufferInformation { |
| + uint32_t struct_size; |
| + MojoBufferInformationFlags flags; |
| + uint64_t num_bytes; |
| +}; |
| +MOJO_STATIC_ASSERT(sizeof(MojoBufferInformation) == 16, |
| + "MojoBufferInformation has wrong size"); |
| + |
| // |MojoMapBufferFlags|: Used to specify different modes to |MojoMapBuffer()|. |
| // |MOJO_MAP_BUFFER_FLAG_NONE| - No flags; default mode. |
| @@ -125,6 +146,23 @@ MojoResult MojoDuplicateBufferHandle( |
| const struct MojoDuplicateBufferHandleOptions* options, // Optional. |
| MojoHandle* new_buffer_handle); // Out. |
| +// Gets information about the buffer with handle |buffer_handle|. |info| should |
| +// be non-null and point to a buffer of size |info_num_bytes|; |info_num_bytes| |
| +// should be at least the size of |struct MojoBufferInformation| (if/when the |
| +// definition of this struct is extended, sizes of previous definitions will |
| +// still be accepted and |*info| filled accordingly). |
| +// |
| +// On success, |*info| will be filled with information about the given buffer. |
| +// |
| +// Returns: |
| +// |MOJO_RESULT_OK| on success. |
| +// |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., |
| +// |buffer_handle| is not a valid buffer handle, |*info| is null, or |
| +// |info_num_bytes| is too small). |
|
jamesr
2016/03/07 19:26:36
hm, buffer too small is a MOJO_RESULT_RESOURCE_EXH
viettrungluu
2016/03/07 20:44:22
See the parenthetical comment in the first paragra
jamesr
2016/03/07 21:42:35
Do we have any definition for what "old valid size
|
| +MojoResult MojoGetBufferInformation(MojoHandle buffer_handle, |
| + struct MojoBufferInformation* info, // Out. |
| + uint32_t info_num_bytes); // In. |
|
jamesr
2016/03/07 19:26:36
inparams before outparams?
viettrungluu
2016/03/07 20:44:23
I'm following existing (arguably-bad[*]) precedent
jamesr
2016/03/07 21:42:35
Read's params are in/out except for flags which co
|
| + |
| // Maps the part (at offset |offset| of length |num_bytes|) of the buffer given |
| // by |buffer_handle| into memory, with options specified by |flags|. |offset + |
| // num_bytes| must be less than or equal to the size of the buffer. On success, |