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

Unified Diff: third_party/WebKit/Source/core/mojo/MojoSharedBufferMapping.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/MojoSharedBufferMapping.cpp
diff --git a/third_party/WebKit/Source/core/mojo/MojoSharedBufferMapping.cpp b/third_party/WebKit/Source/core/mojo/MojoSharedBufferMapping.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0070f9eb94787a9597f7ed9e582e69f34fa0e8f6
--- /dev/null
+++ b/third_party/WebKit/Source/core/mojo/MojoSharedBufferMapping.cpp
@@ -0,0 +1,35 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/mojo/MojoSharedBufferMapping.h"
+
+#include "core/dom/DOMArrayBuffer.h"
+#include "mojo/public/cpp/system/core.h"
+
+namespace blink {
+
+MojoSharedBufferMapping::MojoSharedBufferMapping(void* data, unsigned numBytes)
+ : m_buffer(DOMArrayBuffer::create(data, numBytes)) {
+ // TODO(alokp): We need to create an ArrayBuffer that does not own data.
+}
+
+MojoSharedBufferMapping::~MojoSharedBufferMapping() {
+ unmap();
+}
+
+void MojoSharedBufferMapping::unmap() {
+ if (!m_buffer)
+ return;
+
+ MojoResult result = MojoUnmapBuffer(m_buffer->data());
+ DCHECK_EQ(MOJO_RESULT_OK, result);
+ // TODO(alokp): Neuter m_buffer.
+ m_buffer = nullptr;
+}
+
+DEFINE_TRACE(MojoSharedBufferMapping) {
+ visitor->trace(m_buffer);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698