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

Side by Side Diff: content/common/host_shared_bitmap_manager.cc

Issue 1464383004: Add lock around modification of HostSharedBitmapManagerClient::owned_bitmaps_ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « content/common/host_shared_bitmap_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/common/host_shared_bitmap_manager.h" 5 #include "content/common/host_shared_bitmap_manager.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/trace_event/process_memory_dump.h" 10 #include "base/trace_event/process_memory_dump.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 base::LazyInstance<HostSharedBitmapManager> g_shared_memory_manager = 57 base::LazyInstance<HostSharedBitmapManager> g_shared_memory_manager =
58 LAZY_INSTANCE_INITIALIZER; 58 LAZY_INSTANCE_INITIALIZER;
59 59
60 HostSharedBitmapManagerClient::HostSharedBitmapManagerClient( 60 HostSharedBitmapManagerClient::HostSharedBitmapManagerClient(
61 HostSharedBitmapManager* manager) 61 HostSharedBitmapManager* manager)
62 : manager_(manager) { 62 : manager_(manager) {
63 } 63 }
64 64
65 HostSharedBitmapManagerClient::~HostSharedBitmapManagerClient() { 65 HostSharedBitmapManagerClient::~HostSharedBitmapManagerClient() {
66 base::AutoLock lock(lock_);
66 for (const auto& id : owned_bitmaps_) 67 for (const auto& id : owned_bitmaps_)
67 manager_->ChildDeletedSharedBitmap(id); 68 manager_->ChildDeletedSharedBitmap(id);
68 } 69 }
69 70
70 void HostSharedBitmapManagerClient::AllocateSharedBitmapForChild( 71 void HostSharedBitmapManagerClient::AllocateSharedBitmapForChild(
71 base::ProcessHandle process_handle, 72 base::ProcessHandle process_handle,
72 size_t buffer_size, 73 size_t buffer_size,
73 const cc::SharedBitmapId& id, 74 const cc::SharedBitmapId& id,
74 base::SharedMemoryHandle* shared_memory_handle) { 75 base::SharedMemoryHandle* shared_memory_handle) {
76 base::AutoLock lock(lock_);
piman 2015/11/24 01:39:58 Is it possible to lock only when accessing the map
75 manager_->AllocateSharedBitmapForChild(process_handle, buffer_size, id, 77 manager_->AllocateSharedBitmapForChild(process_handle, buffer_size, id,
76 shared_memory_handle); 78 shared_memory_handle);
77 owned_bitmaps_.insert(id); 79 owned_bitmaps_.insert(id);
78 } 80 }
79 81
80 void HostSharedBitmapManagerClient::ChildAllocatedSharedBitmap( 82 void HostSharedBitmapManagerClient::ChildAllocatedSharedBitmap(
81 size_t buffer_size, 83 size_t buffer_size,
82 const base::SharedMemoryHandle& handle, 84 const base::SharedMemoryHandle& handle,
83 base::ProcessHandle process_handle, 85 base::ProcessHandle process_handle,
84 const cc::SharedBitmapId& id) { 86 const cc::SharedBitmapId& id) {
87 base::AutoLock lock(lock_);
85 manager_->ChildAllocatedSharedBitmap(buffer_size, handle, process_handle, id); 88 manager_->ChildAllocatedSharedBitmap(buffer_size, handle, process_handle, id);
86 owned_bitmaps_.insert(id); 89 owned_bitmaps_.insert(id);
87 } 90 }
88 91
89 void HostSharedBitmapManagerClient::ChildDeletedSharedBitmap( 92 void HostSharedBitmapManagerClient::ChildDeletedSharedBitmap(
90 const cc::SharedBitmapId& id) { 93 const cc::SharedBitmapId& id) {
94 base::AutoLock lock(lock_);
91 manager_->ChildDeletedSharedBitmap(id); 95 manager_->ChildDeletedSharedBitmap(id);
92 owned_bitmaps_.erase(id); 96 owned_bitmaps_.erase(id);
93 } 97 }
94 98
95 HostSharedBitmapManager::HostSharedBitmapManager() {} 99 HostSharedBitmapManager::HostSharedBitmapManager() {}
96 HostSharedBitmapManager::~HostSharedBitmapManager() { 100 HostSharedBitmapManager::~HostSharedBitmapManager() {
97 DCHECK(handle_map_.empty()); 101 DCHECK(handle_map_.empty());
98 } 102 }
99 103
100 HostSharedBitmapManager* HostSharedBitmapManager::current() { 104 HostSharedBitmapManager* HostSharedBitmapManager::current() {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return handle_map_.size(); 244 return handle_map_.size();
241 } 245 }
242 246
243 void HostSharedBitmapManager::FreeSharedMemoryFromMap( 247 void HostSharedBitmapManager::FreeSharedMemoryFromMap(
244 const cc::SharedBitmapId& id) { 248 const cc::SharedBitmapId& id) {
245 base::AutoLock lock(lock_); 249 base::AutoLock lock(lock_);
246 handle_map_.erase(id); 250 handle_map_.erase(id);
247 } 251 }
248 252
249 } // namespace content 253 } // namespace content
OLDNEW
« no previous file with comments | « content/common/host_shared_bitmap_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698