OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/pepper/host_array_buffer_var.h" | 5 #include "content/renderer/pepper/host_array_buffer_var.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
| 10 #include <memory> |
| 11 |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
13 #include "base/process/process_handle.h" | 14 #include "base/process/process_handle.h" |
14 #include "content/common/pepper_file_util.h" | 15 #include "content/common/pepper_file_util.h" |
15 #include "content/common/sandbox_util.h" | 16 #include "content/common/sandbox_util.h" |
16 #include "content/renderer/pepper/host_globals.h" | 17 #include "content/renderer/pepper/host_globals.h" |
17 #include "content/renderer/pepper/plugin_module.h" | 18 #include "content/renderer/pepper/plugin_module.h" |
18 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 19 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
19 #include "content/renderer/render_thread_impl.h" | 20 #include "content/renderer/render_thread_impl.h" |
20 #include "ppapi/c/pp_instance.h" | 21 #include "ppapi/c/pp_instance.h" |
21 | 22 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 56 } |
56 | 57 |
57 uint32_t HostArrayBufferVar::ByteLength() { | 58 uint32_t HostArrayBufferVar::ByteLength() { |
58 return buffer_.byteLength(); | 59 return buffer_.byteLength(); |
59 } | 60 } |
60 | 61 |
61 bool HostArrayBufferVar::CopyToNewShmem( | 62 bool HostArrayBufferVar::CopyToNewShmem( |
62 PP_Instance instance, | 63 PP_Instance instance, |
63 int* host_shm_handle_id, | 64 int* host_shm_handle_id, |
64 base::SharedMemoryHandle* plugin_shm_handle) { | 65 base::SharedMemoryHandle* plugin_shm_handle) { |
65 scoped_ptr<base::SharedMemory> shm( | 66 std::unique_ptr<base::SharedMemory> shm( |
66 RenderThread::Get() | 67 RenderThread::Get() |
67 ->HostAllocateSharedMemoryBuffer(ByteLength()) | 68 ->HostAllocateSharedMemoryBuffer(ByteLength()) |
68 .release()); | 69 .release()); |
69 if (!shm) | 70 if (!shm) |
70 return false; | 71 return false; |
71 | 72 |
72 shm->Map(ByteLength()); | 73 shm->Map(ByteLength()); |
73 memcpy(shm->memory(), Map(), ByteLength()); | 74 memcpy(shm->memory(), Map(), ByteLength()); |
74 shm->Unmap(); | 75 shm->Unmap(); |
75 | 76 |
76 // Duplicate the handle here; the SharedMemory destructor closes | 77 // Duplicate the handle here; the SharedMemory destructor closes |
77 // its handle on us. | 78 // its handle on us. |
78 HostGlobals* hg = HostGlobals::Get(); | 79 HostGlobals* hg = HostGlobals::Get(); |
79 PluginModule* pm = hg->GetModule(hg->GetModuleForInstance(instance)); | 80 PluginModule* pm = hg->GetModule(hg->GetModuleForInstance(instance)); |
80 | 81 |
81 *plugin_shm_handle = | 82 *plugin_shm_handle = |
82 pm->renderer_ppapi_host()->ShareSharedMemoryHandleWithRemote( | 83 pm->renderer_ppapi_host()->ShareSharedMemoryHandleWithRemote( |
83 shm->handle()); | 84 shm->handle()); |
84 *host_shm_handle_id = -1; | 85 *host_shm_handle_id = -1; |
85 return true; | 86 return true; |
86 } | 87 } |
87 | 88 |
88 } // namespace content | 89 } // namespace content |
OLD | NEW |