| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 "services/ui/public/cpp/mojo_buffer_backing.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/memory/ptr_util.h" | |
| 9 | |
| 10 namespace ui { | |
| 11 | |
| 12 MojoBufferBacking::MojoBufferBacking(mojo::ScopedSharedBufferMapping mapping, | |
| 13 size_t size) | |
| 14 : mapping_(std::move(mapping)), size_(size) {} | |
| 15 | |
| 16 MojoBufferBacking::~MojoBufferBacking() = default; | |
| 17 | |
| 18 // static | |
| 19 std::unique_ptr<gpu::BufferBacking> MojoBufferBacking::Create( | |
| 20 mojo::ScopedSharedBufferHandle handle, | |
| 21 size_t size) { | |
| 22 mojo::ScopedSharedBufferMapping mapping = handle->Map(size); | |
| 23 if (!mapping) | |
| 24 return nullptr; | |
| 25 return base::MakeUnique<MojoBufferBacking>(std::move(mapping), size); | |
| 26 } | |
| 27 void* MojoBufferBacking::GetMemory() const { | |
| 28 return mapping_.get(); | |
| 29 } | |
| 30 size_t MojoBufferBacking::GetSize() const { | |
| 31 return size_; | |
| 32 } | |
| 33 | |
| 34 } // namespace ui | |
| OLD | NEW |