[email protected] | 47ef614 | 2012-01-26 21:04:10 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 8cc26a4 | 2011-12-15 21:22:31 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef PPAPI_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_ | ||||
6 | #define PPAPI_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_ | ||||
7 | |||||
dcheng | ced9224 | 2016-04-07 00:00:12 | [diff] [blame] | 8 | #include <memory> |
[email protected] | 8cc26a4 | 2011-12-15 21:22:31 | [diff] [blame] | 9 | #include <vector> |
10 | |||||
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 11 | #include "base/macros.h" |
[email protected] | 8299b71 | 2013-07-17 19:55:23 | [diff] [blame] | 12 | #include "base/memory/shared_memory.h" |
[email protected] | 30e1cb75 | 2013-03-19 20:42:33 | [diff] [blame] | 13 | #include "ppapi/c/pp_instance.h" |
[email protected] | 8cc26a4 | 2011-12-15 21:22:31 | [diff] [blame] | 14 | #include "ppapi/c/pp_stdint.h" |
15 | #include "ppapi/shared_impl/var.h" | ||||
16 | |||||
17 | namespace ppapi { | ||||
18 | |||||
19 | // Represents a plugin-side ArrayBufferVar. In the plugin process, it's | ||||
20 | // owned as a vector. | ||||
21 | class PluginArrayBufferVar : public ArrayBufferVar { | ||||
22 | public: | ||||
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 23 | explicit PluginArrayBufferVar(uint32_t size_in_bytes); |
24 | PluginArrayBufferVar(uint32_t size_in_bytes, | ||||
[email protected] | 30e1cb75 | 2013-03-19 20:42:33 | [diff] [blame] | 25 | base::SharedMemoryHandle plugin_handle); |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 26 | ~PluginArrayBufferVar() override; |
[email protected] | 8cc26a4 | 2011-12-15 21:22:31 | [diff] [blame] | 27 | |
28 | // ArrayBufferVar implementation. | ||||
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 29 | void* Map() override; |
30 | void Unmap() override; | ||||
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 31 | uint32_t ByteLength() override; |
nick | e478443 | 2015-04-23 14:01:48 | [diff] [blame] | 32 | bool CopyToNewShmem( |
[email protected] | 30e1cb75 | 2013-03-19 20:42:33 | [diff] [blame] | 33 | PP_Instance instance, |
34 | int* host_handle, | ||||
mostynb | 699af3c | 2014-10-06 18:03:34 | [diff] [blame] | 35 | base::SharedMemoryHandle* plugin_handle) override; |
[email protected] | 8cc26a4 | 2011-12-15 21:22:31 | [diff] [blame] | 36 | |
37 | private: | ||||
[email protected] | 30e1cb75 | 2013-03-19 20:42:33 | [diff] [blame] | 38 | // Non-shared memory |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 39 | std::vector<uint8_t> buffer_; |
[email protected] | 8cc26a4 | 2011-12-15 21:22:31 | [diff] [blame] | 40 | |
[email protected] | 30e1cb75 | 2013-03-19 20:42:33 | [diff] [blame] | 41 | // Shared memory |
42 | base::SharedMemoryHandle plugin_handle_; | ||||
dcheng | ced9224 | 2016-04-07 00:00:12 | [diff] [blame] | 43 | std::unique_ptr<base::SharedMemory> shmem_; |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 44 | uint32_t size_in_bytes_; |
[email protected] | 30e1cb75 | 2013-03-19 20:42:33 | [diff] [blame] | 45 | |
[email protected] | 8cc26a4 | 2011-12-15 21:22:31 | [diff] [blame] | 46 | DISALLOW_COPY_AND_ASSIGN(PluginArrayBufferVar); |
47 | }; | ||||
48 | |||||
49 | } // namespace ppapi | ||||
50 | |||||
51 | #endif // PPAPI_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_ |