| 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
|
|
|