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

Side by Side Diff: cc/test/test_shared_bitmap_manager.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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
« no previous file with comments | « cc/test/test_shared_bitmap_manager.h ('k') | cc/test/test_texture.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/test/test_shared_bitmap_manager.h" 5 #include "cc/test/test_shared_bitmap_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
10 11
11 namespace cc { 12 namespace cc {
12 13
13 namespace { 14 namespace {
14 class OwnedSharedBitmap : public SharedBitmap { 15 class OwnedSharedBitmap : public SharedBitmap {
15 public: 16 public:
16 OwnedSharedBitmap(scoped_ptr<base::SharedMemory> shared_memory, 17 OwnedSharedBitmap(std::unique_ptr<base::SharedMemory> shared_memory,
17 const SharedBitmapId& id) 18 const SharedBitmapId& id)
18 : SharedBitmap(static_cast<uint8_t*>(shared_memory->memory()), id), 19 : SharedBitmap(static_cast<uint8_t*>(shared_memory->memory()), id),
19 shared_memory_(std::move(shared_memory)) {} 20 shared_memory_(std::move(shared_memory)) {}
20 21
21 ~OwnedSharedBitmap() override {} 22 ~OwnedSharedBitmap() override {}
22 23
23 private: 24 private:
24 scoped_ptr<base::SharedMemory> shared_memory_; 25 std::unique_ptr<base::SharedMemory> shared_memory_;
25 }; 26 };
26 27
27 } // namespace 28 } // namespace
28 29
29 TestSharedBitmapManager::TestSharedBitmapManager() {} 30 TestSharedBitmapManager::TestSharedBitmapManager() {}
30 31
31 TestSharedBitmapManager::~TestSharedBitmapManager() {} 32 TestSharedBitmapManager::~TestSharedBitmapManager() {}
32 33
33 scoped_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap( 34 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap(
34 const gfx::Size& size) { 35 const gfx::Size& size) {
35 base::AutoLock lock(lock_); 36 base::AutoLock lock(lock_);
36 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory); 37 std::unique_ptr<base::SharedMemory> memory(new base::SharedMemory);
37 memory->CreateAndMapAnonymous(size.GetArea() * 4); 38 memory->CreateAndMapAnonymous(size.GetArea() * 4);
38 SharedBitmapId id = SharedBitmap::GenerateId(); 39 SharedBitmapId id = SharedBitmap::GenerateId();
39 bitmap_map_[id] = memory.get(); 40 bitmap_map_[id] = memory.get();
40 return make_scoped_ptr(new OwnedSharedBitmap(std::move(memory), id)); 41 return base::WrapUnique(new OwnedSharedBitmap(std::move(memory), id));
41 } 42 }
42 43
43 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId( 44 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId(
44 const gfx::Size&, 45 const gfx::Size&,
45 const SharedBitmapId& id) { 46 const SharedBitmapId& id) {
46 base::AutoLock lock(lock_); 47 base::AutoLock lock(lock_);
47 if (bitmap_map_.find(id) == bitmap_map_.end()) 48 if (bitmap_map_.find(id) == bitmap_map_.end())
48 return nullptr; 49 return nullptr;
49 uint8_t* pixels = static_cast<uint8_t*>(bitmap_map_[id]->memory()); 50 uint8_t* pixels = static_cast<uint8_t*>(bitmap_map_[id]->memory());
50 return make_scoped_ptr(new SharedBitmap(pixels, id)); 51 return base::WrapUnique(new SharedBitmap(pixels, id));
51 } 52 }
52 53
53 } // namespace cc 54 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_shared_bitmap_manager.h ('k') | cc/test/test_texture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698