Make castv2 performance test work.
[chromium-blink-merge.git] / ppapi / proxy / ppb_buffer_proxy.h
blob7566c08cf1a4aa1fe1dfdd1103f299b9bc52b335
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_PPB_BUFFER_PROXY_H_
6 #define PPAPI_PROXY_PPB_BUFFER_PROXY_H_
8 #include "base/memory/shared_memory.h"
9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/proxy/interface_proxy.h"
11 #include "ppapi/shared_impl/resource.h"
12 #include "ppapi/thunk/ppb_buffer_api.h"
14 namespace ppapi {
16 class HostResource;
18 namespace proxy {
20 class SerializedHandle;
22 class Buffer : public thunk::PPB_Buffer_API, public Resource {
23 public:
24 Buffer(const HostResource& resource,
25 const base::SharedMemoryHandle& shm_handle,
26 uint32_t size);
27 virtual ~Buffer();
29 // Resource overrides.
30 virtual thunk::PPB_Buffer_API* AsPPB_Buffer_API() override;
32 // PPB_Buffer_API implementation.
33 virtual PP_Bool Describe(uint32_t* size_in_bytes) override;
34 virtual PP_Bool IsMapped() override;
35 virtual void* Map() override;
36 virtual void Unmap() override;
38 // Trusted
39 virtual int32_t GetSharedMemory(int* handle) override;
41 private:
42 base::SharedMemory shm_;
43 uint32_t size_;
44 int map_count_;
46 DISALLOW_COPY_AND_ASSIGN(Buffer);
49 class PPB_Buffer_Proxy : public InterfaceProxy {
50 public:
51 explicit PPB_Buffer_Proxy(Dispatcher* dispatcher);
52 virtual ~PPB_Buffer_Proxy();
54 static PP_Resource CreateProxyResource(PP_Instance instance,
55 uint32_t size);
56 static PP_Resource AddProxyResource(const HostResource& resource,
57 base::SharedMemoryHandle shm_handle,
58 uint32_t size);
60 // InterfaceProxy implementation.
61 virtual bool OnMessageReceived(const IPC::Message& msg);
63 static const ApiID kApiID = API_ID_PPB_BUFFER;
65 private:
66 // Message handlers.
67 void OnMsgCreate(PP_Instance instance,
68 uint32_t size,
69 HostResource* result_resource,
70 ppapi::proxy::SerializedHandle* result_shm_handle);
73 } // namespace proxy
74 } // namespace ppapi
76 #endif // PPAPI_PROXY_PPB_BUFFER_PROXY_H_