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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/host_shared_bitmap_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/host_shared_bitmap_manager.cc
diff --git a/content/common/host_shared_bitmap_manager.cc b/content/common/host_shared_bitmap_manager.cc
index f913dba71bf0b5b31916fed5e5e431846837a4ac..6a9595e137c6dfbd0775e4701729fdb41e470be2 100644
--- a/content/common/host_shared_bitmap_manager.cc
+++ b/content/common/host_shared_bitmap_manager.cc
@@ -74,7 +74,10 @@ void HostSharedBitmapManagerClient::AllocateSharedBitmapForChild(
base::SharedMemoryHandle* shared_memory_handle) {
manager_->AllocateSharedBitmapForChild(process_handle, buffer_size, id,
shared_memory_handle);
- owned_bitmaps_.insert(id);
+ if (*shared_memory_handle != base::SharedMemory::NULLHandle()) {
+ base::AutoLock lock(lock_);
+ owned_bitmaps_.insert(id);
+ }
}
void HostSharedBitmapManagerClient::ChildAllocatedSharedBitmap(
@@ -82,14 +85,20 @@ void HostSharedBitmapManagerClient::ChildAllocatedSharedBitmap(
const base::SharedMemoryHandle& handle,
base::ProcessHandle process_handle,
const cc::SharedBitmapId& id) {
- manager_->ChildAllocatedSharedBitmap(buffer_size, handle, process_handle, id);
- owned_bitmaps_.insert(id);
+ if (manager_->ChildAllocatedSharedBitmap(buffer_size, handle, process_handle,
+ id)) {
+ base::AutoLock lock(lock_);
+ owned_bitmaps_.insert(id);
+ }
}
void HostSharedBitmapManagerClient::ChildDeletedSharedBitmap(
const cc::SharedBitmapId& id) {
manager_->ChildDeletedSharedBitmap(id);
- owned_bitmaps_.erase(id);
+ {
+ base::AutoLock lock(lock_);
+ owned_bitmaps_.erase(id);
+ }
}
HostSharedBitmapManager::HostSharedBitmapManager() {}
@@ -176,14 +185,14 @@ bool HostSharedBitmapManager::OnMemoryDump(
return true;
}
-void HostSharedBitmapManager::ChildAllocatedSharedBitmap(
+bool HostSharedBitmapManager::ChildAllocatedSharedBitmap(
size_t buffer_size,
const base::SharedMemoryHandle& handle,
base::ProcessHandle process_handle,
const cc::SharedBitmapId& id) {
base::AutoLock lock(lock_);
if (handle_map_.find(id) != handle_map_.end())
- return;
+ return false;
scoped_refptr<BitmapData> data(
new BitmapData(process_handle, buffer_size));
@@ -195,8 +204,9 @@ void HostSharedBitmapManager::ChildAllocatedSharedBitmap(
data->memory =
make_scoped_ptr(new base::SharedMemory(handle, false));
#endif
- data->memory->Map(data->buffer_size);
- data->memory->Close();
+ data->memory->Map(data->buffer_size);
+ data->memory->Close();
+ return true;
}
void HostSharedBitmapManager::AllocateSharedBitmapForChild(
« 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