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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_PEPPER_HOST_ARRAY_BUFFER_VAR_H_
6 #define CONTENT_RENDERER_PEPPER_HOST_ARRAY_BUFFER_VAR_H_
8 #include "base/memory/shared_memory.h"
9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/shared_impl/host_resource.h"
11 #include "ppapi/shared_impl/var.h"
12 #include "third_party/WebKit/public/web/WebArrayBuffer.h"
16 // Represents a host-side ArrayBufferVar.
17 class HostArrayBufferVar
: public ppapi::ArrayBufferVar
{
19 explicit HostArrayBufferVar(uint32 size_in_bytes
);
20 explicit HostArrayBufferVar(const blink::WebArrayBuffer
& buffer
);
21 explicit HostArrayBufferVar(uint32 size_in_bytes
,
22 base::SharedMemoryHandle handle
);
24 // ArrayBufferVar implementation.
26 void Unmap() override
;
27 uint32
ByteLength() override
;
28 bool CopyToNewShmem(PP_Instance instance
,
29 int* host_shm_handle_id
,
30 base::SharedMemoryHandle
* plugin_shm_handle
) override
;
32 blink::WebArrayBuffer
& webkit_buffer() { return buffer_
; }
35 ~HostArrayBufferVar() override
;
37 blink::WebArrayBuffer buffer_
;
38 // Tracks whether the data in the buffer is valid.
41 DISALLOW_COPY_AND_ASSIGN(HostArrayBufferVar
);
44 } // namespace content
46 #endif // CONTENT_RENDERER_PEPPER_HOST_ARRAY_BUFFER_VAR_H_