| OLD | NEW |
| 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 "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
| 10 #include "ui/gfx/size.h" | 10 #include "ui/gfx/size.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 HostSharedBitmapManager* manager) | 38 HostSharedBitmapManager* manager) |
| 39 : SharedBitmap(pixels, id), | 39 : SharedBitmap(pixels, id), |
| 40 bitmap_data_(bitmap_data), | 40 bitmap_data_(bitmap_data), |
| 41 manager_(manager) {} | 41 manager_(manager) {} |
| 42 | 42 |
| 43 ~HostSharedBitmap() override { | 43 ~HostSharedBitmap() override { |
| 44 if (manager_) | 44 if (manager_) |
| 45 manager_->FreeSharedMemoryFromMap(id()); | 45 manager_->FreeSharedMemoryFromMap(id()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 base::SharedMemory* memory() override { return bitmap_data_->memory.get(); } | |
| 49 | |
| 50 private: | 48 private: |
| 51 scoped_refptr<BitmapData> bitmap_data_; | 49 scoped_refptr<BitmapData> bitmap_data_; |
| 52 HostSharedBitmapManager* manager_; | 50 HostSharedBitmapManager* manager_; |
| 53 }; | 51 }; |
| 54 | 52 |
| 55 } // namespace | 53 } // namespace |
| 56 | 54 |
| 57 base::LazyInstance<HostSharedBitmapManager> g_shared_memory_manager = | 55 base::LazyInstance<HostSharedBitmapManager> g_shared_memory_manager = |
| 58 LAZY_INSTANCE_INITIALIZER; | 56 LAZY_INSTANCE_INITIALIZER; |
| 59 | 57 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return handle_map_.size(); | 199 return handle_map_.size(); |
| 202 } | 200 } |
| 203 | 201 |
| 204 void HostSharedBitmapManager::FreeSharedMemoryFromMap( | 202 void HostSharedBitmapManager::FreeSharedMemoryFromMap( |
| 205 const cc::SharedBitmapId& id) { | 203 const cc::SharedBitmapId& id) { |
| 206 base::AutoLock lock(lock_); | 204 base::AutoLock lock(lock_); |
| 207 handle_map_.erase(id); | 205 handle_map_.erase(id); |
| 208 } | 206 } |
| 209 | 207 |
| 210 } // namespace content | 208 } // namespace content |
| OLD | NEW |