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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
13 #include "base/trace_event/process_memory_dump.h" | 14 #include "base/trace_event/process_memory_dump.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
17 | 18 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 226 } |
226 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); | 227 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory); |
227 if (!shared_memory->CreateAndMapAnonymous(buffer_size)) { | 228 if (!shared_memory->CreateAndMapAnonymous(buffer_size)) { |
228 LOG(ERROR) << "Cannot create shared memory buffer"; | 229 LOG(ERROR) << "Cannot create shared memory buffer"; |
229 *shared_memory_handle = base::SharedMemory::NULLHandle(); | 230 *shared_memory_handle = base::SharedMemory::NULLHandle(); |
230 return; | 231 return; |
231 } | 232 } |
232 | 233 |
233 scoped_refptr<BitmapData> data( | 234 scoped_refptr<BitmapData> data( |
234 new BitmapData(process_handle, buffer_size)); | 235 new BitmapData(process_handle, buffer_size)); |
235 data->memory = shared_memory.Pass(); | 236 data->memory = std::move(shared_memory); |
236 | 237 |
237 handle_map_[id] = data; | 238 handle_map_[id] = data; |
238 if (!data->memory->ShareToProcess(process_handle, shared_memory_handle)) { | 239 if (!data->memory->ShareToProcess(process_handle, shared_memory_handle)) { |
239 LOG(ERROR) << "Cannot share shared memory buffer"; | 240 LOG(ERROR) << "Cannot share shared memory buffer"; |
240 *shared_memory_handle = base::SharedMemory::NULLHandle(); | 241 *shared_memory_handle = base::SharedMemory::NULLHandle(); |
241 return; | 242 return; |
242 } | 243 } |
243 data->memory->Close(); | 244 data->memory->Close(); |
244 } | 245 } |
245 | 246 |
246 void HostSharedBitmapManager::ChildDeletedSharedBitmap( | 247 void HostSharedBitmapManager::ChildDeletedSharedBitmap( |
247 const cc::SharedBitmapId& id) { | 248 const cc::SharedBitmapId& id) { |
248 base::AutoLock lock(lock_); | 249 base::AutoLock lock(lock_); |
249 handle_map_.erase(id); | 250 handle_map_.erase(id); |
250 } | 251 } |
251 | 252 |
252 size_t HostSharedBitmapManager::AllocatedBitmapCount() const { | 253 size_t HostSharedBitmapManager::AllocatedBitmapCount() const { |
253 base::AutoLock lock(lock_); | 254 base::AutoLock lock(lock_); |
254 return handle_map_.size(); | 255 return handle_map_.size(); |
255 } | 256 } |
256 | 257 |
257 void HostSharedBitmapManager::FreeSharedMemoryFromMap( | 258 void HostSharedBitmapManager::FreeSharedMemoryFromMap( |
258 const cc::SharedBitmapId& id) { | 259 const cc::SharedBitmapId& id) { |
259 base::AutoLock lock(lock_); | 260 base::AutoLock lock(lock_); |
260 handle_map_.erase(id); | 261 handle_map_.erase(id); |
261 } | 262 } |
262 | 263 |
263 } // namespace content | 264 } // namespace content |
OLD | NEW |