Factorize media/audio into new GN.
[chromium-blink-merge.git] / ppapi / proxy / plugin_array_buffer_var.h
blob84d9d217708e6a9c408cd64ed1b2c4225ee26172
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_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_
6 #define PPAPI_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/shared_memory.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_stdint.h"
15 #include "ppapi/shared_impl/var.h"
17 namespace ppapi {
19 // Represents a plugin-side ArrayBufferVar. In the plugin process, it's
20 // owned as a vector.
21 class PluginArrayBufferVar : public ArrayBufferVar {
22 public:
23 explicit PluginArrayBufferVar(uint32 size_in_bytes);
24 PluginArrayBufferVar(uint32 size_in_bytes,
25 base::SharedMemoryHandle plugin_handle);
26 virtual ~PluginArrayBufferVar();
28 // ArrayBufferVar implementation.
29 virtual void* Map() OVERRIDE;
30 virtual void Unmap() OVERRIDE;
31 virtual uint32 ByteLength() OVERRIDE;
32 virtual bool CopyToNewShmem(
33 PP_Instance instance,
34 int* host_handle,
35 base::SharedMemoryHandle* plugin_handle) OVERRIDE;
37 private:
38 // Non-shared memory
39 std::vector<uint8> buffer_;
41 // Shared memory
42 base::SharedMemoryHandle plugin_handle_;
43 scoped_ptr<base::SharedMemory> shmem_;
44 uint32 size_in_bytes_;
46 DISALLOW_COPY_AND_ASSIGN(PluginArrayBufferVar);
49 } // namespace ppapi
51 #endif // PPAPI_PROXY_PLUGIN_ARRAY_BUFFER_VAR_H_