1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file. 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/common/host_shared_bitmap_manager.h" 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/lazy_instance.h" 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/memory/ref_counted.h" 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/common/view_messages.h" 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/gfx/size.h" 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace content { 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class BitmapData : public base::RefCountedThreadSafe<BitmapData> { 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public: 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) BitmapData(base::ProcessHandle process_handle, 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::SharedMemoryHandle memory_handle, 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) size_t buffer_size) 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) : process_handle(process_handle), 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) memory_handle(memory_handle), 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) buffer_size(buffer_size) {} 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::ProcessHandle process_handle; 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::SharedMemoryHandle memory_handle; 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<base::SharedMemory> memory; 25cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) scoped_ptr<uint8[]> pixels; 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) size_t buffer_size; 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) private: 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) friend class base::RefCountedThreadSafe<BitmapData>; 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ~BitmapData() {} 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(BitmapData); 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}; 33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Holds a reference on the memory to keep it alive. 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void FreeSharedMemory(scoped_refptr<BitmapData> data, 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) cc::SharedBitmap* bitmap) {} 37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)base::LazyInstance<HostSharedBitmapManager> g_shared_memory_manager = 39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) LAZY_INSTANCE_INITIALIZER; 40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)HostSharedBitmapManager::HostSharedBitmapManager() {} 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)HostSharedBitmapManager::~HostSharedBitmapManager() {} 43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)HostSharedBitmapManager* HostSharedBitmapManager::current() { 45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return g_shared_memory_manager.Pointer(); 46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::AllocateSharedBitmap( 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const gfx::Size& size) { 50cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) base::AutoLock lock(lock_); 51cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) size_t bitmap_size; 52cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) if (!cc::SharedBitmap::SizeInBytes(size, &bitmap_size)) 53cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return scoped_ptr<cc::SharedBitmap>(); 54cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 55cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) scoped_refptr<BitmapData> data( 56cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) new BitmapData(base::GetCurrentProcessHandle(), 57cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) base::SharedMemory::NULLHandle(), 58cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) bitmap_size)); 59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Bitmaps allocated in host don't need to be shared to other processes, so 60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // allocate them with new instead. 61cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) data->pixels = scoped_ptr<uint8[]>(new uint8[bitmap_size]); 62cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 63cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); 64cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) handle_map_[id] = data; 65cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return make_scoped_ptr(new cc::SharedBitmap( 6646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) data->pixels.get(), 6746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) id, 6846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) base::Bind(&HostSharedBitmapManager::FreeSharedMemoryFromMap, 6946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) base::Unretained(this)))); 70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 72a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::GetSharedBitmapFromId( 73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const gfx::Size& size, 74a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const cc::SharedBitmapId& id) { 75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::AutoLock lock(lock_); 76a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) BitmapMap::iterator it = handle_map_.find(id); 77a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (it == handle_map_.end()) 78a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return scoped_ptr<cc::SharedBitmap>(); 79a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 80a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) BitmapData* data = it->second.get(); 81a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 82a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) size_t bitmap_size; 83c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch if (!cc::SharedBitmap::SizeInBytes(size, &bitmap_size) || 84a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bitmap_size > data->buffer_size) 85a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return scoped_ptr<cc::SharedBitmap>(); 86a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 87cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) if (data->pixels) { 88cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return make_scoped_ptr(new cc::SharedBitmap( 89cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) data->pixels.get(), id, base::Bind(&FreeSharedMemory, it->second))); 90cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) } 91a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!data->memory->memory()) { 92a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) TRACE_EVENT0("renderer_host", 93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "HostSharedBitmapManager::GetSharedBitmapFromId"); 94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!data->memory->Map(data->buffer_size)) { 95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return scoped_ptr<cc::SharedBitmap>(); 96a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 97a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<cc::SharedBitmap> bitmap(new cc::SharedBitmap( 100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) data->memory.get(), id, base::Bind(&FreeSharedMemory, it->second))); 101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return bitmap.Pass(); 103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::GetBitmapForSharedMemory( 106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::SharedMemory*) { 107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return scoped_ptr<cc::SharedBitmap>(); 108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 109a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void HostSharedBitmapManager::ChildAllocatedSharedBitmap( 111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) size_t buffer_size, 112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const base::SharedMemoryHandle& handle, 113a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::ProcessHandle process_handle, 114a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const cc::SharedBitmapId& id) { 115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::AutoLock lock(lock_); 116a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (handle_map_.find(id) != handle_map_.end()) 117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_refptr<BitmapData> data( 119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) new BitmapData(process_handle, handle, buffer_size)); 120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 121a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) handle_map_[id] = data; 122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) process_map_[process_handle].insert(id); 123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#if defined(OS_WIN) 124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) data->memory = make_scoped_ptr( 125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) new base::SharedMemory(data->memory_handle, false, data->process_handle)); 126a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#else 127a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) data->memory = 128a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) make_scoped_ptr(new base::SharedMemory(data->memory_handle, false)); 129a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif 130a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 131a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 132a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void HostSharedBitmapManager::AllocateSharedBitmapForChild( 133a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::ProcessHandle process_handle, 134a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) size_t buffer_size, 135a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const cc::SharedBitmapId& id, 136a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::SharedMemoryHandle* shared_memory_handle) { 137a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::AutoLock lock(lock_); 138a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (handle_map_.find(id) != handle_map_.end()) { 139a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) *shared_memory_handle = base::SharedMemory::NULLHandle(); 140a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 141a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); 143a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!shared_memory->CreateAndMapAnonymous(buffer_size)) { 144a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) LOG(ERROR) << "Cannot create shared memory buffer"; 145a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) *shared_memory_handle = base::SharedMemory::NULLHandle(); 146a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 147a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 148a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 149a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_refptr<BitmapData> data( 150a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) new BitmapData(process_handle, shared_memory->handle(), buffer_size)); 151a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) data->memory = shared_memory.Pass(); 152a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 153a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) handle_map_[id] = data; 154a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) process_map_[process_handle].insert(id); 155a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!data->memory->ShareToProcess(process_handle, shared_memory_handle)) { 156a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) LOG(ERROR) << "Cannot share shared memory buffer"; 157a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) *shared_memory_handle = base::SharedMemory::NULLHandle(); 158a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 159a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 160a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 161a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 162a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void HostSharedBitmapManager::ChildDeletedSharedBitmap( 163a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const cc::SharedBitmapId& id) { 164a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::AutoLock lock(lock_); 165a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) BitmapMap::iterator it = handle_map_.find(id); 166a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (it == handle_map_.end()) 167a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 168a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::hash_set<cc::SharedBitmapId>& res = 169a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) process_map_[it->second->process_handle]; 170a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) res.erase(id); 171a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) handle_map_.erase(it); 172a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 173a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 174a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void HostSharedBitmapManager::ProcessRemoved( 175a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::ProcessHandle process_handle) { 176a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::AutoLock lock(lock_); 177a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ProcessMap::iterator proc_it = process_map_.find(process_handle); 178a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (proc_it == process_map_.end()) 179a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 180a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::hash_set<cc::SharedBitmapId>& res = proc_it->second; 181a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 182a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (base::hash_set<cc::SharedBitmapId>::iterator it = res.begin(); 183a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) it != res.end(); 184a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ++it) { 185a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) handle_map_.erase(*it); 186a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) process_map_.erase(proc_it); 188a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccisize_t HostSharedBitmapManager::AllocatedBitmapCount() const { 1911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::AutoLock lock(lock_); 1921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return handle_map_.size(); 1931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 1941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 19546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)void HostSharedBitmapManager::FreeSharedMemoryFromMap( 19646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) cc::SharedBitmap* bitmap) { 19746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) base::AutoLock lock(lock_); 19846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) handle_map_.erase(bitmap->id()); 19946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)} 20046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 201a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace content 202