| 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 "webkit/plugins/ppapi/host_array_buffer_var.h" | 5 #include "webkit/plugins/ppapi/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 "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
| 14 #include "webkit/plugins/ppapi/host_globals.h" | 14 #include "webkit/plugins/ppapi/host_globals.h" |
| 15 #include "webkit/plugins/ppapi/plugin_module.h" | 15 #include "webkit/plugins/ppapi/plugin_module.h" |
| 16 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 16 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h" |
| 17 | 17 |
| 18 using ppapi::ArrayBufferVar; | 18 using ppapi::ArrayBufferVar; |
| 19 using WebKit::WebArrayBuffer; | 19 using WebKit::WebArrayBuffer; |
| 20 | 20 |
| 21 namespace webkit { | 21 namespace webkit { |
| 22 namespace ppapi { | 22 namespace ppapi { |
| 23 | 23 |
| 24 HostArrayBufferVar::HostArrayBufferVar(uint32 size_in_bytes) | 24 HostArrayBufferVar::HostArrayBufferVar(uint32 size_in_bytes) |
| 25 : buffer_(WebArrayBuffer::create(size_in_bytes, 1 /* element_size */)), | 25 : buffer_(WebArrayBuffer::create(size_in_bytes, 1 /* element_size */)), |
| 26 valid_(true) { | 26 valid_(true) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 uint32 HostArrayBufferVar::ByteLength() { | 58 uint32 HostArrayBufferVar::ByteLength() { |
| 59 return buffer_.byteLength(); | 59 return buffer_.byteLength(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool HostArrayBufferVar::CopyToNewShmem( | 62 bool HostArrayBufferVar::CopyToNewShmem( |
| 63 PP_Instance instance, | 63 PP_Instance instance, |
| 64 int* host_shm_handle_id, | 64 int* host_shm_handle_id, |
| 65 base::SharedMemoryHandle* plugin_shm_handle) { | 65 base::SharedMemoryHandle* plugin_shm_handle) { |
| 66 webkit::ppapi::PluginInstance* i = | 66 webkit::ppapi::PluginInstanceImpl* i = |
| 67 webkit::ppapi::HostGlobals::Get()->GetInstance(instance); | 67 webkit::ppapi::HostGlobals::Get()->GetInstance(instance); |
| 68 scoped_ptr<base::SharedMemory> shm(i->delegate()->CreateAnonymousSharedMemory( | 68 scoped_ptr<base::SharedMemory> shm(i->delegate()->CreateAnonymousSharedMemory( |
| 69 ByteLength())); | 69 ByteLength())); |
| 70 if (!shm) | 70 if (!shm) |
| 71 return false; | 71 return false; |
| 72 | 72 |
| 73 shm->Map(ByteLength()); | 73 shm->Map(ByteLength()); |
| 74 memcpy(shm->memory(), Map(), ByteLength()); | 74 memcpy(shm->memory(), Map(), ByteLength()); |
| 75 shm->Unmap(); | 75 shm->Unmap(); |
| 76 | 76 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 94 #endif | 94 #endif |
| 95 | 95 |
| 96 *plugin_shm_handle = | 96 *plugin_shm_handle = |
| 97 i->delegate()->ShareHandleWithRemote(platform_file, p, false); | 97 i->delegate()->ShareHandleWithRemote(platform_file, p, false); |
| 98 *host_shm_handle_id = -1; | 98 *host_shm_handle_id = -1; |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace ppapi | 102 } // namespace ppapi |
| 103 } // namespace webkit | 103 } // namespace webkit |
| OLD | NEW |