| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/ui/common/mojo_buffer_backing.h" | 5 #include "services/ui/public/cpp/mojo_buffer_backing.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| 11 | 11 |
| 12 MojoBufferBacking::MojoBufferBacking(mojo::ScopedSharedBufferMapping mapping, | 12 MojoBufferBacking::MojoBufferBacking(mojo::ScopedSharedBufferMapping mapping, |
| 13 size_t size) | 13 size_t size) |
| 14 : mapping_(std::move(mapping)), size_(size) {} | 14 : mapping_(std::move(mapping)), size_(size) {} |
| 15 | 15 |
| 16 MojoBufferBacking::~MojoBufferBacking() = default; | 16 MojoBufferBacking::~MojoBufferBacking() = default; |
| 17 | 17 |
| 18 // static | 18 // static |
| 19 std::unique_ptr<gpu::BufferBacking> MojoBufferBacking::Create( | 19 std::unique_ptr<gpu::BufferBacking> MojoBufferBacking::Create( |
| 20 mojo::ScopedSharedBufferHandle handle, | 20 mojo::ScopedSharedBufferHandle handle, |
| 21 size_t size) { | 21 size_t size) { |
| 22 mojo::ScopedSharedBufferMapping mapping = handle->Map(size); | 22 mojo::ScopedSharedBufferMapping mapping = handle->Map(size); |
| 23 if (!mapping) | 23 if (!mapping) |
| 24 return nullptr; | 24 return nullptr; |
| 25 return base::MakeUnique<MojoBufferBacking>(std::move(mapping), size); | 25 return base::MakeUnique<MojoBufferBacking>(std::move(mapping), size); |
| 26 } | 26 } |
| 27 void* MojoBufferBacking::GetMemory() const { | 27 void* MojoBufferBacking::GetMemory() const { |
| 28 return mapping_.get(); | 28 return mapping_.get(); |
| 29 } | 29 } |
| 30 size_t MojoBufferBacking::GetSize() const { | 30 size_t MojoBufferBacking::GetSize() const { |
| 31 return size_; | 31 return size_; |
| 32 } | 32 } |
| 33 | 33 |
| 34 } // namespace ui | 34 } // namespace ui |
| OLD | NEW |