| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/child/child_shared_bitmap_manager.h" | 5 #include "content/child/child_shared_bitmap_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 8 #include "base/process/memory.h" | 10 #include "base/process/memory.h" |
| 9 #include "base/process/process_metrics.h" | 11 #include "base/process/process_metrics.h" |
| 12 #include "build/build_config.h" |
| 10 #include "content/child/child_thread_impl.h" | 13 #include "content/child/child_thread_impl.h" |
| 11 #include "content/common/child_process_messages.h" | 14 #include "content/common/child_process_messages.h" |
| 12 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 13 | 16 |
| 14 namespace content { | 17 namespace content { |
| 15 | 18 |
| 16 namespace { | 19 namespace { |
| 17 | 20 |
| 18 class ChildSharedBitmap : public SharedMemoryBitmap { | 21 class ChildSharedBitmap : public SharedMemoryBitmap { |
| 19 public: | 22 public: |
| 20 ChildSharedBitmap(scoped_refptr<ThreadSafeSender> sender, | 23 ChildSharedBitmap(scoped_refptr<ThreadSafeSender> sender, |
| 21 base::SharedMemory* shared_memory, | 24 base::SharedMemory* shared_memory, |
| 22 const cc::SharedBitmapId& id) | 25 const cc::SharedBitmapId& id) |
| 23 : SharedMemoryBitmap(static_cast<uint8*>(shared_memory->memory()), | 26 : SharedMemoryBitmap(static_cast<uint8_t*>(shared_memory->memory()), |
| 24 id, | 27 id, |
| 25 shared_memory), | 28 shared_memory), |
| 26 sender_(sender) {} | 29 sender_(sender) {} |
| 27 | 30 |
| 28 ChildSharedBitmap(scoped_refptr<ThreadSafeSender> sender, | 31 ChildSharedBitmap(scoped_refptr<ThreadSafeSender> sender, |
| 29 scoped_ptr<base::SharedMemory> shared_memory_holder, | 32 scoped_ptr<base::SharedMemory> shared_memory_holder, |
| 30 const cc::SharedBitmapId& id) | 33 const cc::SharedBitmapId& id) |
| 31 : ChildSharedBitmap(sender, shared_memory_holder.get(), id) { | 34 : ChildSharedBitmap(sender, shared_memory_holder.get(), id) { |
| 32 shared_memory_holder_ = shared_memory_holder.Pass(); | 35 shared_memory_holder_ = shared_memory_holder.Pass(); |
| 33 } | 36 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 60 base::debug::Alias(&height); | 63 base::debug::Alias(&height); |
| 61 base::debug::Alias(&last_error); | 64 base::debug::Alias(&last_error); |
| 62 base::debug::Alias(&private_bytes); | 65 base::debug::Alias(&private_bytes); |
| 63 base::debug::Alias(&shared_bytes); | 66 base::debug::Alias(&shared_bytes); |
| 64 #endif | 67 #endif |
| 65 base::TerminateBecauseOutOfMemory(alloc_size); | 68 base::TerminateBecauseOutOfMemory(alloc_size); |
| 66 } | 69 } |
| 67 | 70 |
| 68 } // namespace | 71 } // namespace |
| 69 | 72 |
| 70 SharedMemoryBitmap::SharedMemoryBitmap(uint8* pixels, | 73 SharedMemoryBitmap::SharedMemoryBitmap(uint8_t* pixels, |
| 71 const cc::SharedBitmapId& id, | 74 const cc::SharedBitmapId& id, |
| 72 base::SharedMemory* shared_memory) | 75 base::SharedMemory* shared_memory) |
| 73 : SharedBitmap(pixels, id), shared_memory_(shared_memory) { | 76 : SharedBitmap(pixels, id), shared_memory_(shared_memory) {} |
| 74 } | |
| 75 | 77 |
| 76 ChildSharedBitmapManager::ChildSharedBitmapManager( | 78 ChildSharedBitmapManager::ChildSharedBitmapManager( |
| 77 scoped_refptr<ThreadSafeSender> sender) | 79 scoped_refptr<ThreadSafeSender> sender) |
| 78 : sender_(sender) { | 80 : sender_(sender) { |
| 79 } | 81 } |
| 80 | 82 |
| 81 ChildSharedBitmapManager::~ChildSharedBitmapManager() {} | 83 ChildSharedBitmapManager::~ChildSharedBitmapManager() {} |
| 82 | 84 |
| 83 scoped_ptr<cc::SharedBitmap> ChildSharedBitmapManager::AllocateSharedBitmap( | 85 scoped_ptr<cc::SharedBitmap> ChildSharedBitmapManager::AllocateSharedBitmap( |
| 84 const gfx::Size& size) { | 86 const gfx::Size& size) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send)) | 140 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send)) |
| 139 return scoped_ptr<cc::SharedBitmap>(); | 141 return scoped_ptr<cc::SharedBitmap>(); |
| 140 #endif | 142 #endif |
| 141 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( | 143 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( |
| 142 mem->mapped_size(), handle_to_send, id)); | 144 mem->mapped_size(), handle_to_send, id)); |
| 143 | 145 |
| 144 return make_scoped_ptr(new ChildSharedBitmap(sender_, mem, id)); | 146 return make_scoped_ptr(new ChildSharedBitmap(sender_, mem, id)); |
| 145 } | 147 } |
| 146 | 148 |
| 147 } // namespace content | 149 } // namespace content |
| OLD | NEW |