| OLD | NEW | 
|---|
| (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 | 
| OLD | NEW | 
|---|