blob: cc8f59821a9da2348dc0c0f4b5b28c288e105ac8 [file] [log] [blame]
[email protected]16b7b272012-07-25 21:54:491// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]43a40202010-11-12 16:25:012// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]0a6d5f62011-11-11 08:04:075#ifndef PPAPI_PROXY_PPB_BUFFER_PROXY_H_
6#define PPAPI_PROXY_PPB_BUFFER_PROXY_H_
[email protected]43a40202010-11-12 16:25:017
[email protected]32523382011-06-10 02:30:008#include "base/shared_memory.h"
[email protected]859a7f32011-01-15 03:44:139#include "ppapi/c/pp_instance.h"
[email protected]43a40202010-11-12 16:25:0110#include "ppapi/proxy/interface_proxy.h"
[email protected]7f8b26b2011-08-18 15:41:0111#include "ppapi/shared_impl/resource.h"
[email protected]7ace8ad2011-08-06 03:23:5812#include "ppapi/thunk/ppb_buffer_api.h"
[email protected]43a40202010-11-12 16:25:0113
[email protected]be0a84b2011-08-13 04:18:4414namespace ppapi {
[email protected]be0a84b2011-08-13 04:18:4415
[email protected]4d2efd22011-08-18 21:58:0216class HostResource;
17
[email protected]43a40202010-11-12 16:25:0118namespace proxy {
19
[email protected]4d2efd22011-08-18 21:58:0220class Buffer : public thunk::PPB_Buffer_API, public Resource {
[email protected]7ace8ad2011-08-06 03:23:5821 public:
[email protected]4d2efd22011-08-18 21:58:0222 Buffer(const HostResource& resource,
[email protected]7ace8ad2011-08-06 03:23:5823 const base::SharedMemoryHandle& shm_handle,
24 uint32_t size);
25 virtual ~Buffer();
26
[email protected]7f8b26b2011-08-18 15:41:0127 // Resource overrides.
[email protected]4d2efd22011-08-18 21:58:0228 virtual thunk::PPB_Buffer_API* AsPPB_Buffer_API() OVERRIDE;
[email protected]7ace8ad2011-08-06 03:23:5829
30 // PPB_Buffer_API implementation.
31 virtual PP_Bool Describe(uint32_t* size_in_bytes) OVERRIDE;
32 virtual PP_Bool IsMapped() OVERRIDE;
33 virtual void* Map() OVERRIDE;
34 virtual void Unmap() OVERRIDE;
35
36 private:
37 base::SharedMemory shm_;
38 uint32_t size_;
[email protected]7ace8ad2011-08-06 03:23:5839 int map_count_;
40
41 DISALLOW_COPY_AND_ASSIGN(Buffer);
42};
43
[email protected]43a40202010-11-12 16:25:0144class PPB_Buffer_Proxy : public InterfaceProxy {
45 public:
[email protected]0a6d5f62011-11-11 08:04:0746 explicit PPB_Buffer_Proxy(Dispatcher* dispatcher);
[email protected]43a40202010-11-12 16:25:0147 virtual ~PPB_Buffer_Proxy();
48
[email protected]9815108e2011-05-27 21:50:2849 static PP_Resource CreateProxyResource(PP_Instance instance,
50 uint32_t size);
[email protected]4d2efd22011-08-18 21:58:0251 static PP_Resource AddProxyResource(const HostResource& resource,
[email protected]0fa46e82011-08-09 07:31:4952 base::SharedMemoryHandle shm_handle,
53 uint32_t size);
[email protected]9815108e2011-05-27 21:50:2854
[email protected]43a40202010-11-12 16:25:0155 // InterfaceProxy implementation.
[email protected]a95986a82010-12-24 06:19:2856 virtual bool OnMessageReceived(const IPC::Message& msg);
[email protected]43a40202010-11-12 16:25:0157
[email protected]ac4b54d2011-10-20 23:09:2858 static const ApiID kApiID = API_ID_PPB_BUFFER;
[email protected]5c966022011-09-13 18:09:3759
[email protected]43a40202010-11-12 16:25:0160 private:
61 // Message handlers.
[email protected]859a7f32011-01-15 03:44:1362 void OnMsgCreate(PP_Instance instance,
[email protected]867b76d632010-12-02 00:09:0763 uint32_t size,
[email protected]4d2efd22011-08-18 21:58:0264 HostResource* result_resource,
[email protected]32523382011-06-10 02:30:0065 base::SharedMemoryHandle* result_shm_handle);
[email protected]43a40202010-11-12 16:25:0166};
67
68} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0269} // namespace ppapi
[email protected]43a40202010-11-12 16:25:0170
[email protected]0a6d5f62011-11-11 08:04:0771#endif // PPAPI_PROXY_PPB_BUFFER_PROXY_H_