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

Unified Diff: third_party/WebKit/Source/core/mojo/MojoHandle.cpp

Issue 2720873002: Implements JS bindings for mojo shared buffer. (Closed)
Patch Set: unmap upon destruction Created 3 years, 10 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: third_party/WebKit/Source/core/mojo/MojoHandle.cpp
diff --git a/third_party/WebKit/Source/core/mojo/MojoHandle.cpp b/third_party/WebKit/Source/core/mojo/MojoHandle.cpp
index 0ae42778335411c744034c169d24a21ffa984f91..110fd6b7e1635a58d3873d7d55d2c1f65b8f70dc 100644
--- a/third_party/WebKit/Source/core/mojo/MojoHandle.cpp
+++ b/third_party/WebKit/Source/core/mojo/MojoHandle.cpp
@@ -8,8 +8,10 @@
#include "bindings/core/v8/ScriptState.h"
#include "core/dom/DOMArrayBuffer.h"
#include "core/dom/DOMArrayBufferView.h"
+#include "core/mojo/MojoMapBufferResult.h"
#include "core/mojo/MojoReadMessageFlags.h"
#include "core/mojo/MojoReadMessageResult.h"
+#include "core/mojo/MojoSharedBufferMapping.h"
#include "core/mojo/MojoWatcher.h"
// Mojo messages typically do not contain many handles. In fact most
@@ -92,4 +94,18 @@ void MojoHandle::readMessage(const MojoReadMessageFlags& flagsDict,
resultDict.setHandles(handles);
}
+void MojoHandle::mapBuffer(unsigned offset,
+ unsigned numBytes,
+ MojoMapBufferResult& resultDict) {
+ void* data = nullptr;
+ MojoResult result = MojoMapBuffer(m_handle->value(), offset, numBytes, &data,
+ MOJO_MAP_BUFFER_FLAG_NONE);
+ resultDict.setResult(result);
+ if (result == MOJO_RESULT_OK) {
+ // TODO(alokp): Check if we need to track all mappings so that they can be
+ // unmapped when this handle is closed.
+ resultDict.setBuffer(new MojoSharedBufferMapping(data, numBytes));
+ }
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/mojo/MojoHandle.h ('k') | third_party/WebKit/Source/core/mojo/MojoHandle.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698