blob: 57c8d5aa2f352b848fe2c4d34d7d2d727833b838 [file] [log] [blame]
[email protected]47ef6142012-01-26 21:04:101// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]8cc26a42011-12-15 21:22:312// 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
dchengced92242016-04-07 00:00:128#include <memory>
[email protected]8cc26a42011-12-15 21:22:319#include <vector>
10
avie029c4132015-12-23 06:45:2211#include "base/macros.h"
[email protected]8299b712013-07-17 19:55:2312#include "base/memory/shared_memory.h"
[email protected]30e1cb752013-03-19 20:42:3313#include "ppapi/c/pp_instance.h"
[email protected]8cc26a42011-12-15 21:22:3114#include "ppapi/c/pp_stdint.h"
15#include "ppapi/shared_impl/var.h"
16
17namespace ppapi {
18
19// Represents a plugin-side ArrayBufferVar. In the plugin process, it's
20// owned as a vector.
21class PluginArrayBufferVar : public ArrayBufferVar {
22 public:
avie029c4132015-12-23 06:45:2223 explicit PluginArrayBufferVar(uint32_t size_in_bytes);
24 PluginArrayBufferVar(uint32_t size_in_bytes,
[email protected]30e1cb752013-03-19 20:42:3325 base::SharedMemoryHandle plugin_handle);
nicke4784432015-04-23 14:01:4826 ~PluginArrayBufferVar() override;
[email protected]8cc26a42011-12-15 21:22:3127
28 // ArrayBufferVar implementation.
nicke4784432015-04-23 14:01:4829 void* Map() override;
30 void Unmap() override;
avie029c4132015-12-23 06:45:2231 uint32_t ByteLength() override;
nicke4784432015-04-23 14:01:4832 bool CopyToNewShmem(
[email protected]30e1cb752013-03-19 20:42:3333 PP_Instance instance,
34 int* host_handle,
mostynb699af3c2014-10-06 18:03:3435 base::SharedMemoryHandle* plugin_handle) override;
[email protected]8cc26a42011-12-15 21:22:3136
37 private:
[email protected]30e1cb752013-03-19 20:42:3338 // Non-shared memory
avie029c4132015-12-23 06:45:2239 std::vector<uint8_t> buffer_;
[email protected]8cc26a42011-12-15 21:22:3140
[email protected]30e1cb752013-03-19 20:42:3341 // Shared memory
42 base::SharedMemoryHandle plugin_handle_;
dchengced92242016-04-07 00:00:1243 std::unique_ptr<base::SharedMemory> shmem_;
avie029c4132015-12-23 06:45:2244 uint32_t size_in_bytes_;
[email protected]30e1cb752013-03-19 20:42:3345
[email protected]8cc26a42011-12-15 21:22:3146 DISALLOW_COPY_AND_ASSIGN(PluginArrayBufferVar);
47};
48
49} // namespace ppapi
50
51#endif // PPAPI_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_