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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/mojo/MojoSharedBufferMapping.h"
6
7 #include "core/dom/DOMArrayBuffer.h"
8 #include "mojo/public/cpp/system/core.h"
9
10 namespace blink {
11
12 MojoSharedBufferMapping::MojoSharedBufferMapping(void* data, unsigned numBytes)
13 : m_buffer(DOMArrayBuffer::create(data, numBytes)) {
14 // TODO(alokp): We need to create an ArrayBuffer that does not own data.
15 }
16
17 MojoSharedBufferMapping::~MojoSharedBufferMapping() {
18 unmap();
19 }
20
21 void MojoSharedBufferMapping::unmap() {
22 if (!m_buffer)
23 return;
24
25 MojoResult result = MojoUnmapBuffer(m_buffer->data());
26 DCHECK_EQ(MOJO_RESULT_OK, result);
27 // TODO(alokp): Neuter m_buffer.
28 m_buffer = nullptr;
29 }
30
31 DEFINE_TRACE(MojoSharedBufferMapping) {
32 visitor->trace(m_buffer);
33 }
34
35 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698