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 "ppapi/proxy/plugin_array_buffer_var.h" | 5 #include "ppapi/proxy/plugin_array_buffer_var.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 using base::SharedMemory; | 22 using base::SharedMemory; |
23 using base::SharedMemoryHandle; | 23 using base::SharedMemoryHandle; |
24 using ppapi::proxy::PluginGlobals; | 24 using ppapi::proxy::PluginGlobals; |
25 using ppapi::proxy::PluginResourceTracker; | 25 using ppapi::proxy::PluginResourceTracker; |
26 | 26 |
27 namespace ppapi { | 27 namespace ppapi { |
28 | 28 |
29 PluginArrayBufferVar::PluginArrayBufferVar(uint32_t size_in_bytes) | 29 PluginArrayBufferVar::PluginArrayBufferVar(uint32_t size_in_bytes) |
30 : buffer_(size_in_bytes), | 30 : buffer_(size_in_bytes), |
31 plugin_handle_(base::SharedMemory::NULLHandle()), | |
32 size_in_bytes_(size_in_bytes) {} | 31 size_in_bytes_(size_in_bytes) {} |
33 | 32 |
34 PluginArrayBufferVar::PluginArrayBufferVar(uint32_t size_in_bytes, | 33 PluginArrayBufferVar::PluginArrayBufferVar(uint32_t size_in_bytes, |
35 SharedMemoryHandle plugin_handle) | 34 SharedMemoryHandle plugin_handle) |
36 : plugin_handle_(plugin_handle), size_in_bytes_(size_in_bytes) {} | 35 : plugin_handle_(plugin_handle), size_in_bytes_(size_in_bytes) {} |
37 | 36 |
38 PluginArrayBufferVar::~PluginArrayBufferVar() { | 37 PluginArrayBufferVar::~PluginArrayBufferVar() { |
39 Unmap(); | 38 Unmap(); |
40 | 39 |
41 if (shmem_.get() == NULL) { | 40 if (shmem_.get() == NULL) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 base::SharedMemoryHandle tmp_handle = plugin_handle.shmem(); | 91 base::SharedMemoryHandle tmp_handle = plugin_handle.shmem(); |
93 SharedMemory s(tmp_handle, false); | 92 SharedMemory s(tmp_handle, false); |
94 if (!s.Map(ByteLength())) | 93 if (!s.Map(ByteLength())) |
95 return false; | 94 return false; |
96 memcpy(s.memory(), Map(), ByteLength()); | 95 memcpy(s.memory(), Map(), ByteLength()); |
97 s.Unmap(); | 96 s.Unmap(); |
98 | 97 |
99 // We don't need to keep the shared memory around on the plugin side; | 98 // We don't need to keep the shared memory around on the plugin side; |
100 // we've already copied all our data into it. We'll make it invalid | 99 // we've already copied all our data into it. We'll make it invalid |
101 // just to be safe. | 100 // just to be safe. |
102 *plugin_out_handle = base::SharedMemory::NULLHandle(); | 101 *plugin_out_handle = base::SharedMemoryHandle(); |
103 | 102 |
104 return true; | 103 return true; |
105 } | 104 } |
106 | 105 |
107 } // namespace ppapi | 106 } // namespace ppapi |
OLD | NEW |