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

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

Issue 2775423003: Add ownership edges between HostSharedBitmap and shared memory
Patch Set: Fix comments Created 3 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/resources/shared_bitmap.cc ('k') | content/child/child_shared_bitmap_manager.cc » ('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/ptr_util.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 namespace { 14 namespace {
15 class OwnedSharedBitmap : public SharedBitmap { 15 class OwnedSharedBitmap : public SharedBitmap {
16 public: 16 public:
17 OwnedSharedBitmap(std::unique_ptr<base::SharedMemory> shared_memory, 17 OwnedSharedBitmap(std::unique_ptr<base::SharedMemory> shared_memory,
18 const SharedBitmapId& id) 18 const SharedBitmapId& id)
19 : SharedBitmap(static_cast<uint8_t*>(shared_memory->memory()), id), 19 : SharedBitmap(static_cast<uint8_t*>(shared_memory->memory()),
20 shared_memory.get(),
21 id),
20 shared_memory_(std::move(shared_memory)) {} 22 shared_memory_(std::move(shared_memory)) {}
21 23
22 ~OwnedSharedBitmap() override {} 24 ~OwnedSharedBitmap() override {}
23 25
24 private: 26 private:
25 std::unique_ptr<base::SharedMemory> shared_memory_; 27 std::unique_ptr<base::SharedMemory> shared_memory_;
26 }; 28 };
27 29
28 } // namespace 30 } // namespace
29 31
(...skipping 11 matching lines...) Expand all
41 return base::MakeUnique<OwnedSharedBitmap>(std::move(memory), id); 43 return base::MakeUnique<OwnedSharedBitmap>(std::move(memory), id);
42 } 44 }
43 45
44 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId( 46 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId(
45 const gfx::Size&, 47 const gfx::Size&,
46 const SharedBitmapId& id) { 48 const SharedBitmapId& id) {
47 base::AutoLock lock(lock_); 49 base::AutoLock lock(lock_);
48 if (bitmap_map_.find(id) == bitmap_map_.end()) 50 if (bitmap_map_.find(id) == bitmap_map_.end())
49 return nullptr; 51 return nullptr;
50 uint8_t* pixels = static_cast<uint8_t*>(bitmap_map_[id]->memory()); 52 uint8_t* pixels = static_cast<uint8_t*>(bitmap_map_[id]->memory());
51 return base::MakeUnique<SharedBitmap>(pixels, id); 53 return base::MakeUnique<SharedBitmap>(pixels, bitmap_map_[id], id);
52 } 54 }
53 55
54 } // namespace cc 56 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/shared_bitmap.cc ('k') | content/child/child_shared_bitmap_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698