blob: f79497e97dc412cc66b6978538f201497ee808b0 [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
avie029c4132015-12-23 06:45:228#include <stdint.h>
9
10#include "base/macros.h"
Matthew Caryfc3757f2019-07-30 21:32:4611#include "base/memory/shared_memory_mapping.h"
12#include "base/memory/unsafe_shared_memory_region.h"
[email protected]859a7f32011-01-15 03:44:1313#include "ppapi/c/pp_instance.h"
[email protected]43a40202010-11-12 16:25:0114#include "ppapi/proxy/interface_proxy.h"
[email protected]7f8b26b2011-08-18 15:41:0115#include "ppapi/shared_impl/resource.h"
[email protected]7ace8ad2011-08-06 03:23:5816#include "ppapi/thunk/ppb_buffer_api.h"
[email protected]43a40202010-11-12 16:25:0117
[email protected]be0a84b2011-08-13 04:18:4418namespace ppapi {
[email protected]be0a84b2011-08-13 04:18:4419
[email protected]4d2efd22011-08-18 21:58:0220class HostResource;
21
[email protected]43a40202010-11-12 16:25:0122namespace proxy {
23
[email protected]eb5960da2013-01-16 23:23:5324class SerializedHandle;
25
[email protected]4d2efd22011-08-18 21:58:0226class Buffer : public thunk::PPB_Buffer_API, public Resource {
[email protected]7ace8ad2011-08-06 03:23:5827 public:
[email protected]4d2efd22011-08-18 21:58:0228 Buffer(const HostResource& resource,
Matthew Caryfc3757f2019-07-30 21:32:4629 base::UnsafeSharedMemoryRegion shm_handle);
nicke4784432015-04-23 14:01:4830 ~Buffer() override;
[email protected]7ace8ad2011-08-06 03:23:5831
[email protected]7f8b26b2011-08-18 15:41:0132 // Resource overrides.
nicke4784432015-04-23 14:01:4833 thunk::PPB_Buffer_API* AsPPB_Buffer_API() override;
[email protected]7ace8ad2011-08-06 03:23:5834
35 // PPB_Buffer_API implementation.
nicke4784432015-04-23 14:01:4836 PP_Bool Describe(uint32_t* size_in_bytes) override;
37 PP_Bool IsMapped() override;
38 void* Map() override;
39 void Unmap() override;
[email protected]7ace8ad2011-08-06 03:23:5840
[email protected]e3da4e802013-03-23 23:50:4941 // Trusted
Matthew Caryfc3757f2019-07-30 21:32:4642 int32_t GetSharedMemory(base::UnsafeSharedMemoryRegion** shm) override;
[email protected]e3da4e802013-03-23 23:50:4943
[email protected]7ace8ad2011-08-06 03:23:5844 private:
Matthew Caryfc3757f2019-07-30 21:32:4645 base::UnsafeSharedMemoryRegion shm_;
46 base::WritableSharedMemoryMapping mapping_;
[email protected]7ace8ad2011-08-06 03:23:5847 int map_count_;
48
49 DISALLOW_COPY_AND_ASSIGN(Buffer);
50};
51
[email protected]43a40202010-11-12 16:25:0152class PPB_Buffer_Proxy : public InterfaceProxy {
53 public:
[email protected]0a6d5f62011-11-11 08:04:0754 explicit PPB_Buffer_Proxy(Dispatcher* dispatcher);
Lei Zhang94f57fe32017-08-30 23:58:2455 ~PPB_Buffer_Proxy() override;
[email protected]43a40202010-11-12 16:25:0156
[email protected]9815108e2011-05-27 21:50:2857 static PP_Resource CreateProxyResource(PP_Instance instance,
58 uint32_t size);
Matthew Caryfc3757f2019-07-30 21:32:4659 static PP_Resource AddProxyResource(
60 const HostResource& resource,
61 base::UnsafeSharedMemoryRegion shm_region);
[email protected]9815108e2011-05-27 21:50:2862
[email protected]43a40202010-11-12 16:25:0163 // InterfaceProxy implementation.
Lei Zhang94f57fe32017-08-30 23:58:2464 bool OnMessageReceived(const IPC::Message& msg) override;
[email protected]43a40202010-11-12 16:25:0165
[email protected]ac4b54d2011-10-20 23:09:2866 static const ApiID kApiID = API_ID_PPB_BUFFER;
[email protected]5c966022011-09-13 18:09:3767
[email protected]43a40202010-11-12 16:25:0168 private:
69 // Message handlers.
[email protected]859a7f32011-01-15 03:44:1370 void OnMsgCreate(PP_Instance instance,
[email protected]867b76d632010-12-02 00:09:0771 uint32_t size,
[email protected]4d2efd22011-08-18 21:58:0272 HostResource* result_resource,
[email protected]246fc492012-08-27 20:28:1873 ppapi::proxy::SerializedHandle* result_shm_handle);
[email protected]43a40202010-11-12 16:25:0174};
75
76} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0277} // namespace ppapi
[email protected]43a40202010-11-12 16:25:0178
[email protected]0a6d5f62011-11-11 08:04:0779#endif // PPAPI_PROXY_PPB_BUFFER_PROXY_H_