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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 return scoped_ptr<cc::SharedBitmap>(); | 47 return scoped_ptr<cc::SharedBitmap>(); |
48 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); | 48 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); |
49 scoped_ptr<base::SharedMemory> memory; | 49 scoped_ptr<base::SharedMemory> memory; |
50 #if defined(OS_POSIX) | 50 #if defined(OS_POSIX) |
51 base::SharedMemoryHandle handle; | 51 base::SharedMemoryHandle handle; |
52 sender_->Send(new ChildProcessHostMsg_SyncAllocateSharedBitmap( | 52 sender_->Send(new ChildProcessHostMsg_SyncAllocateSharedBitmap( |
53 memory_size, id, &handle)); | 53 memory_size, id, &handle)); |
54 memory = make_scoped_ptr(new base::SharedMemory(handle, false)); | 54 memory = make_scoped_ptr(new base::SharedMemory(handle, false)); |
55 CHECK(memory->Map(memory_size)); | 55 CHECK(memory->Map(memory_size)); |
56 #else | 56 #else |
57 memory.reset(ChildThread::AllocateSharedMemory(memory_size, sender_)); | 57 memory.reset(ChildThread::AllocateSharedMemory(memory_size, sender_.get())); |
58 CHECK(memory); | 58 CHECK(memory); |
59 base::SharedMemoryHandle handle_to_send = memory->handle(); | 59 base::SharedMemoryHandle handle_to_send = memory->handle(); |
60 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( | 60 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( |
61 memory_size, handle_to_send, id)); | 61 memory_size, handle_to_send, id)); |
62 #endif | 62 #endif |
63 return scoped_ptr<cc::SharedBitmap>(new cc::SharedBitmap( | 63 return scoped_ptr<cc::SharedBitmap>(new cc::SharedBitmap( |
64 memory.release(), id, base::Bind(&FreeSharedMemory, sender_))); | 64 memory.release(), id, base::Bind(&FreeSharedMemory, sender_))); |
65 } | 65 } |
66 | 66 |
67 scoped_ptr<cc::SharedBitmap> ChildSharedBitmapManager::GetSharedBitmapFromId( | 67 scoped_ptr<cc::SharedBitmap> ChildSharedBitmapManager::GetSharedBitmapFromId( |
(...skipping 13 matching lines...) Expand all Loading... |
81 #endif | 81 #endif |
82 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( | 82 sender_->Send(new ChildProcessHostMsg_AllocatedSharedBitmap( |
83 mem->mapped_size(), handle_to_send, id)); | 83 mem->mapped_size(), handle_to_send, id)); |
84 // The compositor owning the SharedBitmap will be closed before the | 84 // The compositor owning the SharedBitmap will be closed before the |
85 // ChildThread containng this, making the use of base::Unretained safe. | 85 // ChildThread containng this, making the use of base::Unretained safe. |
86 return scoped_ptr<cc::SharedBitmap>( | 86 return scoped_ptr<cc::SharedBitmap>( |
87 new cc::SharedBitmap(mem, id, base::Bind(&ReleaseSharedBitmap, sender_))); | 87 new cc::SharedBitmap(mem, id, base::Bind(&ReleaseSharedBitmap, sender_))); |
88 } | 88 } |
89 | 89 |
90 } // namespace content | 90 } // namespace content |
OLD | NEW |