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

Unified Diff: mojo/edk/system/shared_buffer_dispatcher.cc

Issue 1776033002: Implement MojoGetBufferInformation(), part 1. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh Created 4 years, 9 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
« no previous file with comments | « mojo/edk/system/shared_buffer_dispatcher.h ('k') | mojo/edk/system/shared_buffer_dispatcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/shared_buffer_dispatcher.cc
diff --git a/mojo/edk/system/shared_buffer_dispatcher.cc b/mojo/edk/system/shared_buffer_dispatcher.cc
index 576a4283210a889c7d7b8f65747d818a7f39be46..4474c70ef9e8f0a25dfaca01bff7f02d846fea8a 100644
--- a/mojo/edk/system/shared_buffer_dispatcher.cc
+++ b/mojo/edk/system/shared_buffer_dispatcher.cc
@@ -232,6 +232,29 @@ MojoResult SharedBufferDispatcher::DuplicateBufferHandleImplNoLock(
return MOJO_RESULT_OK;
}
+MojoResult SharedBufferDispatcher::GetBufferInformationImplNoLock(
+ UserPointer<MojoBufferInformation> info,
+ uint32_t info_num_bytes) {
+ mutex().AssertHeld();
+
+ // Note: If/when |MojoBufferInformation| is extended beyond its initial
+ // definition, more work will be necessary. (See the definition of
+ // |MojoGetBufferInformation()| in mojo/public/c/system/buffer.h.)
+ static_assert(sizeof(MojoBufferInformation) == 16u,
+ "MojoBufferInformation has been extended!");
+
+ if (info_num_bytes < sizeof(MojoBufferInformation))
+ return MOJO_RESULT_INVALID_ARGUMENT;
+
+ MojoBufferInformation model_info = {
+ sizeof(MojoBufferInformation), // |struct_size|.
+ MOJO_BUFFER_INFORMATION_FLAG_NONE, // |flags|.
+ static_cast<uint64_t>(shared_buffer_->GetNumBytes()), // |num_bytes|.
+ };
+ info.Put(model_info);
+ return MOJO_RESULT_OK;
+}
+
MojoResult SharedBufferDispatcher::MapBufferImplNoLock(
uint64_t offset,
uint64_t num_bytes,
« no previous file with comments | « mojo/edk/system/shared_buffer_dispatcher.h ('k') | mojo/edk/system/shared_buffer_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698