| 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 "content/child/child_thread.h" | 7 #include "content/child/child_thread.h" |
| 8 #include "content/common/child_process_messages.h" | 8 #include "content/common/child_process_messages.h" |
| 9 #include "ui/gfx/size.h" | 9 #include "ui/gfx/size.h" |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 ChildSharedBitmapManager::ChildSharedBitmapManager( | 49 ChildSharedBitmapManager::ChildSharedBitmapManager( |
| 50 scoped_refptr<ThreadSafeSender> sender) | 50 scoped_refptr<ThreadSafeSender> sender) |
| 51 : sender_(sender) { | 51 : sender_(sender) { |
| 52 } | 52 } |
| 53 | 53 |
| 54 ChildSharedBitmapManager::~ChildSharedBitmapManager() {} | 54 ChildSharedBitmapManager::~ChildSharedBitmapManager() {} |
| 55 | 55 |
| 56 scoped_ptr<cc::SharedBitmap> ChildSharedBitmapManager::AllocateSharedBitmap( | 56 scoped_ptr<cc::SharedBitmap> ChildSharedBitmapManager::AllocateSharedBitmap( |
| 57 const gfx::Size& size) { | 57 const gfx::Size& size) { |
| 58 return AllocateSharedMemoryBitmap(size); | 58 scoped_ptr<SharedMemoryBitmap> bitmap = AllocateSharedMemoryBitmap(size); |
| 59 #if defined(OS_POSIX) |
| 60 // Close file descriptor to avoid running out. |
| 61 if (bitmap) |
| 62 bitmap->shared_memory()->Close(); |
| 63 #endif |
| 64 return bitmap.Pass(); |
| 59 } | 65 } |
| 60 | 66 |
| 61 scoped_ptr<SharedMemoryBitmap> | 67 scoped_ptr<SharedMemoryBitmap> |
| 62 ChildSharedBitmapManager::AllocateSharedMemoryBitmap(const gfx::Size& size) { | 68 ChildSharedBitmapManager::AllocateSharedMemoryBitmap(const gfx::Size& size) { |
| 63 TRACE_EVENT2("renderer", | 69 TRACE_EVENT2("renderer", |
| 64 "ChildSharedBitmapManager::AllocateSharedMemoryBitmap", "width", | 70 "ChildSharedBitmapManager::AllocateSharedMemoryBitmap", "width", |
| 65 size.width(), "height", size.height()); | 71 size.width(), "height", size.height()); |
| 66 size_t memory_size; | 72 size_t memory_size; |
| 67 if (!cc::SharedBitmap::SizeInBytes(size, &memory_size)) | 73 if (!cc::SharedBitmap::SizeInBytes(size, &memory_size)) |
| 68 return scoped_ptr<SharedMemoryBitmap>(); | 74 return scoped_ptr<SharedMemoryBitmap>(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send)) | 108 if (!mem->ShareToProcess(base::GetCurrentProcessHandle(), &handle_to_send)) |
| 103 return scoped_ptr<cc::SharedBitmap>(); | 109 return scoped_ptr<cc::SharedBitmap>(); |
| 104 #endif | 110 #endif |
| 105 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( | 111 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( |
| 106 mem->mapped_size(), handle_to_send, id)); | 112 mem->mapped_size(), handle_to_send, id)); |
| 107 | 113 |
| 108 return make_scoped_ptr(new ChildSharedBitmap(sender_, mem, id)); | 114 return make_scoped_ptr(new ChildSharedBitmap(sender_, mem, id)); |
| 109 } | 115 } |
| 110 | 116 |
| 111 } // namespace content | 117 } // namespace content |
| OLD | NEW |