Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / webkit / plugins / ppapi / host_array_buffer_var.h
blob646adf81c147c5b5ead49b25a478df6071c2831b
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 PPAPI_WEBKIT_PLUGINS_PPAPI_HOST_ARRAY_BUFFER_VAR_H_
6 #define PPAPI_WEBKIT_PLUGINS_PPAPI_HOST_ARRAY_BUFFER_VAR_H_
8 #include "base/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/Source/WebKit/chromium/public/WebArrayBuffer.h"
14 namespace webkit {
15 namespace ppapi {
17 // Represents a host-side ArrayBufferVar.
18 class HostArrayBufferVar : public ::ppapi::ArrayBufferVar {
19 public:
20 explicit HostArrayBufferVar(uint32 size_in_bytes);
21 explicit HostArrayBufferVar(const WebKit::WebArrayBuffer& buffer);
22 explicit HostArrayBufferVar(uint32 size_in_bytes,
23 base::SharedMemoryHandle handle);
24 virtual ~HostArrayBufferVar();
26 // ArrayBufferVar implementation.
27 virtual void* Map() OVERRIDE;
28 virtual void Unmap() OVERRIDE;
29 virtual uint32 ByteLength() OVERRIDE;
30 virtual bool CopyToNewShmem(
31 PP_Instance instance,
32 int* host_shm_handle_id,
33 base::SharedMemoryHandle* plugin_shm_handle) OVERRIDE;
35 WebKit::WebArrayBuffer& webkit_buffer() { return buffer_; }
37 private:
38 WebKit::WebArrayBuffer buffer_;
39 // Tracks whether the data in the buffer is valid.
40 bool valid_;
42 DISALLOW_COPY_AND_ASSIGN(HostArrayBufferVar);
45 } // namespace ppapi
46 } // namespace webkit
48 #endif // PPAPI_WEBKIT_PLUGINS_PPAPI_HOST_ARRAY_BUFFER_VAR_H_