[email protected] | 16b7b27 | 2012-07-25 21:54:49 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 0a6d5f6 | 2011-11-11 08:04:07 | [diff] [blame] | 5 | #ifndef PPAPI_PROXY_PPB_BUFFER_PROXY_H_ |
6 | #define PPAPI_PROXY_PPB_BUFFER_PROXY_H_ | ||||
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 7 | |
[email protected] | 3252338 | 2011-06-10 02:30:00 | [diff] [blame] | 8 | #include "base/shared_memory.h" |
[email protected] | 859a7f3 | 2011-01-15 03:44:13 | [diff] [blame] | 9 | #include "ppapi/c/pp_instance.h" |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 10 | #include "ppapi/proxy/interface_proxy.h" |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 11 | #include "ppapi/shared_impl/resource.h" |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 12 | #include "ppapi/thunk/ppb_buffer_api.h" |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 13 | |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 14 | namespace ppapi { |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 15 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 16 | class HostResource; |
17 | |||||
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 18 | namespace proxy { |
19 | |||||
[email protected] | eb5960da | 2013-01-16 23:23:53 | [diff] [blame^] | 20 | class SerializedHandle; |
21 | |||||
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 22 | class Buffer : public thunk::PPB_Buffer_API, public Resource { |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 23 | public: |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 24 | Buffer(const HostResource& resource, |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 25 | const base::SharedMemoryHandle& shm_handle, |
26 | uint32_t size); | ||||
27 | virtual ~Buffer(); | ||||
28 | |||||
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 29 | // Resource overrides. |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 30 | virtual thunk::PPB_Buffer_API* AsPPB_Buffer_API() OVERRIDE; |
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 31 | |
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; | ||||
37 | |||||
38 | private: | ||||
39 | base::SharedMemory shm_; | ||||
40 | uint32_t size_; | ||||
[email protected] | 7ace8ad | 2011-08-06 03:23:58 | [diff] [blame] | 41 | int map_count_; |
42 | |||||
43 | DISALLOW_COPY_AND_ASSIGN(Buffer); | ||||
44 | }; | ||||
45 | |||||
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 46 | class PPB_Buffer_Proxy : public InterfaceProxy { |
47 | public: | ||||
[email protected] | 0a6d5f6 | 2011-11-11 08:04:07 | [diff] [blame] | 48 | explicit PPB_Buffer_Proxy(Dispatcher* dispatcher); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 49 | virtual ~PPB_Buffer_Proxy(); |
50 | |||||
[email protected] | 9815108e | 2011-05-27 21:50:28 | [diff] [blame] | 51 | static PP_Resource CreateProxyResource(PP_Instance instance, |
52 | uint32_t size); | ||||
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 53 | static PP_Resource AddProxyResource(const HostResource& resource, |
[email protected] | 0fa46e8 | 2011-08-09 07:31:49 | [diff] [blame] | 54 | base::SharedMemoryHandle shm_handle, |
55 | uint32_t size); | ||||
[email protected] | 9815108e | 2011-05-27 21:50:28 | [diff] [blame] | 56 | |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 57 | // InterfaceProxy implementation. |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 58 | virtual bool OnMessageReceived(const IPC::Message& msg); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 59 | |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 60 | static const ApiID kApiID = API_ID_PPB_BUFFER; |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 61 | |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 62 | private: |
63 | // Message handlers. | ||||
[email protected] | 859a7f3 | 2011-01-15 03:44:13 | [diff] [blame] | 64 | void OnMsgCreate(PP_Instance instance, |
[email protected] | 867b76d63 | 2010-12-02 00:09:07 | [diff] [blame] | 65 | uint32_t size, |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 66 | HostResource* result_resource, |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 67 | ppapi::proxy::SerializedHandle* result_shm_handle); |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 68 | }; |
69 | |||||
70 | } // namespace proxy | ||||
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 71 | } // namespace ppapi |
[email protected] | 43a4020 | 2010-11-12 16:25:01 | [diff] [blame] | 72 | |
[email protected] | 0a6d5f6 | 2011-11-11 08:04:07 | [diff] [blame] | 73 | #endif // PPAPI_PROXY_PPB_BUFFER_PROXY_H_ |