diff options
author | jbauman <jbauman@chromium.org> | 2014-09-24 16:06:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-24 23:07:07 +0000 |
commit | b86d19a65aa6e002f7421a724f5fe29f62a016ae (patch) | |
tree | 485a593d13a71f26af00da5c27e9dff244007809 | |
parent | da4b14f0affb40a6c4d3452a148f2383a48eefce (diff) | |
download | chromium_src-b86d19a65aa6e002f7421a724f5fe29f62a016ae.zip chromium_src-b86d19a65aa6e002f7421a724f5fe29f62a016ae.tar.gz chromium_src-b86d19a65aa6e002f7421a724f5fe29f62a016ae.tar.bz2 |
Fix race in HostSharedBitmapManager::AllocatedBitmapCount
This race should be benign, because the count is just used for a heuristic and can't truly be synchronized anyway, but best to use a lock with the access.
BUG=417194
Review URL: https://codereview.chromium.org/604583002
Cr-Commit-Position: refs/heads/master@{#296554}
-rw-r--r-- | content/common/host_shared_bitmap_manager.cc | 5 | ||||
-rw-r--r-- | content/common/host_shared_bitmap_manager.h | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/content/common/host_shared_bitmap_manager.cc b/content/common/host_shared_bitmap_manager.cc index ac1478f..66f7215 100644 --- a/content/common/host_shared_bitmap_manager.cc +++ b/content/common/host_shared_bitmap_manager.cc @@ -187,6 +187,11 @@ void HostSharedBitmapManager::ProcessRemoved( process_map_.erase(proc_it); } +size_t HostSharedBitmapManager::AllocatedBitmapCount() const { + base::AutoLock lock(lock_); + return handle_map_.size(); +} + void HostSharedBitmapManager::FreeSharedMemoryFromMap( cc::SharedBitmap* bitmap) { base::AutoLock lock(lock_); diff --git a/content/common/host_shared_bitmap_manager.h b/content/common/host_shared_bitmap_manager.h index 08245b3..5559a85 100644 --- a/content/common/host_shared_bitmap_manager.h +++ b/content/common/host_shared_bitmap_manager.h @@ -65,12 +65,12 @@ class CONTENT_EXPORT HostSharedBitmapManager : public cc::SharedBitmapManager { void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id); void ProcessRemoved(base::ProcessHandle process_handle); - size_t AllocatedBitmapCount() const { return handle_map_.size(); } + size_t AllocatedBitmapCount() const; private: void FreeSharedMemoryFromMap(cc::SharedBitmap* bitmap); - base::Lock lock_; + mutable base::Lock lock_; typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> > BitmapMap; |