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

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

Issue 2720873002: Implements JS bindings for mojo shared buffer. (Closed)
Patch Set: 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..77b1febecf95243ede19be7b1f0c544bd23407b8 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/MojoSharedBuffer.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
alokp 2017/02/27 19:50:45 yzshen@: The current js-binding implementation doe
yzshen1 2017/02/27 21:05:27 The lifetime of mappings is not tied to that of th
+ // unmapped when this handle is closed.
+ resultDict.setBuffer(new MojoSharedBuffer(data, numBytes));
+ }
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698