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_THUNK_RESOURCE_CREATION_API_H_
6 #define PPAPI_THUNK_RESOURCE_CREATION_API_H_
8 #include "base/memory/shared_memory.h"
9 #include "ppapi/c/dev/pp_video_dev.h"
10 #include "ppapi/c/dev/ppb_file_chooser_dev.h"
11 #include "ppapi/c/dev/ppb_truetype_font_dev.h"
12 #include "ppapi/c/pp_bool.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/c/ppb_audio.h"
16 #include "ppapi/c/ppb_audio_config.h"
17 #include "ppapi/c/ppb_file_system.h"
18 #include "ppapi/c/ppb_graphics_3d.h"
19 #include "ppapi/c/ppb_image_data.h"
20 #include "ppapi/c/ppb_input_event.h"
21 #include "ppapi/c/ppb_network_monitor.h"
22 #include "ppapi/c/ppb_websocket.h"
23 #include "ppapi/c/private/pp_private_font_charset.h"
24 #include "ppapi/shared_impl/api_id.h"
25 #include "ppapi/shared_impl/ppb_image_data_shared.h"
28 struct PP_FontDescription_Dev
;
29 struct PP_BrowserFont_Trusted_Description
;
30 struct PP_NetAddress_IPv4
;
31 struct PP_NetAddress_IPv6
;
32 struct PP_NetAddress_Private
;
41 struct FileRefCreateInfo
;
42 struct URLRequestInfoData
;
43 struct URLResponseInfoData
;
47 // A functional API for creating resource types. Separating out the creation
48 // functions here allows us to implement most resources as a pure "resource
49 // API", meaning all calls are routed on a per-resource-object basis. The
50 // creation functions are not per-object (since there's no object during
51 // creation) so need functional routing based on the instance ID.
52 class ResourceCreationAPI
{
54 virtual ~ResourceCreationAPI() {}
56 virtual PP_Resource
CreateFileIO(PP_Instance instance
) = 0;
57 virtual PP_Resource
CreateFileRef(
59 const FileRefCreateInfo
& serialized
) = 0;
60 virtual PP_Resource
CreateFileSystem(PP_Instance instance
,
61 PP_FileSystemType type
) = 0;
62 virtual PP_Resource
CreateIMEInputEvent(PP_Instance instance
,
63 PP_InputEvent_Type type
,
64 PP_TimeTicks time_stamp
,
66 uint32_t segment_number
,
67 const uint32_t* segment_offsets
,
68 int32_t target_segment
,
69 uint32_t selection_start
,
70 uint32_t selection_end
) = 0;
71 virtual PP_Resource
CreateKeyboardInputEvent_1_0(
73 PP_InputEvent_Type type
,
74 PP_TimeTicks time_stamp
,
77 struct PP_Var character_text
) = 0;
78 virtual PP_Resource
CreateKeyboardInputEvent_1_2(
80 PP_InputEvent_Type type
,
81 PP_TimeTicks time_stamp
,
84 struct PP_Var character_text
,
85 struct PP_Var code
) = 0;
86 virtual PP_Resource
CreateMouseInputEvent(
88 PP_InputEvent_Type type
,
89 PP_TimeTicks time_stamp
,
91 PP_InputEvent_MouseButton mouse_button
,
92 const PP_Point
* mouse_position
,
94 const PP_Point
* mouse_movement
) = 0;
95 virtual PP_Resource
CreateTouchInputEvent(
97 PP_InputEvent_Type type
,
98 PP_TimeTicks time_stamp
,
99 uint32_t modifiers
) = 0;
100 virtual PP_Resource
CreateTrueTypeFont(
101 PP_Instance instance
,
102 const PP_TrueTypeFontDesc_Dev
* desc
) = 0;
103 virtual PP_Resource
CreateURLLoader(PP_Instance instance
) = 0;
104 virtual PP_Resource
CreateURLRequestInfo(
105 PP_Instance instance
) = 0;
107 virtual PP_Resource
CreateWheelInputEvent(
108 PP_Instance instance
,
109 PP_TimeTicks time_stamp
,
111 const PP_FloatPoint
* wheel_delta
,
112 const PP_FloatPoint
* wheel_ticks
,
113 PP_Bool scroll_by_page
) = 0;
115 virtual PP_Resource
CreateAudio1_0(PP_Instance instance
,
116 PP_Resource config_id
,
117 PPB_Audio_Callback_1_0 audio_callback
,
118 void* user_data
) = 0;
119 virtual PP_Resource
CreateAudio(PP_Instance instance
,
120 PP_Resource config_id
,
121 PPB_Audio_Callback audio_callback
,
122 void* user_data
) = 0;
123 virtual PP_Resource
CreateAudioTrusted(PP_Instance instance
) = 0;
124 virtual PP_Resource
CreateAudioConfig(PP_Instance instance
,
125 PP_AudioSampleRate sample_rate
,
126 uint32_t sample_frame_count
) = 0;
127 virtual PP_Resource
CreateCompositor(PP_Instance instance
) = 0;
128 virtual PP_Resource
CreateFileChooser(PP_Instance instance
,
129 PP_FileChooserMode_Dev mode
,
130 const PP_Var
& accept_types
) = 0;
131 virtual PP_Resource
CreateGraphics2D(PP_Instance instance
,
133 PP_Bool is_always_opaque
) = 0;
134 virtual PP_Resource
CreateGraphics3D(PP_Instance instance
,
135 PP_Resource share_context
,
136 const int32_t* attrib_list
) = 0;
137 virtual PP_Resource
CreateGraphics3DRaw(
138 PP_Instance instance
,
139 PP_Resource share_context
,
140 const int32_t* attrib_list
,
141 gpu::Capabilities
* capabilities
,
142 base::SharedMemoryHandle
* shared_state
) = 0;
143 virtual PP_Resource
CreateHostResolver(PP_Instance instance
) = 0;
144 virtual PP_Resource
CreateHostResolverPrivate(PP_Instance instance
) = 0;
145 virtual PP_Resource
CreateImageData(PP_Instance instance
,
146 PP_ImageDataFormat format
,
148 PP_Bool init_to_zero
) = 0;
149 virtual PP_Resource
CreateImageDataSimple(PP_Instance instance
,
150 PP_ImageDataFormat format
,
152 PP_Bool init_to_zero
) = 0;
153 virtual PP_Resource
CreateMediaStreamVideoTrack(PP_Instance instance
) = 0;
154 virtual PP_Resource
CreateNetAddressFromIPv4Address(
155 PP_Instance instance
,
156 const PP_NetAddress_IPv4
* ipv4_addr
) = 0;
157 virtual PP_Resource
CreateNetAddressFromIPv6Address(
158 PP_Instance instance
,
159 const PP_NetAddress_IPv6
* ipv6_addr
) = 0;
160 virtual PP_Resource
CreateNetAddressFromNetAddressPrivate(
161 PP_Instance instance
,
162 const PP_NetAddress_Private
& private_addr
) = 0;
163 virtual PP_Resource
CreateNetworkMonitor(PP_Instance instance
) = 0;
164 virtual PP_Resource
CreateOutputProtectionPrivate(PP_Instance instance
) = 0;
165 virtual PP_Resource
CreatePrinting(PP_Instance instance
) = 0;
166 virtual PP_Resource
CreateTCPServerSocketPrivate(PP_Instance instance
) = 0;
167 virtual PP_Resource
CreateTCPSocket1_0(PP_Instance instace
) = 0;
168 virtual PP_Resource
CreateTCPSocket(PP_Instance instance
) = 0;
169 virtual PP_Resource
CreateTCPSocketPrivate(PP_Instance instace
) = 0;
170 virtual PP_Resource
CreateUDPSocket(PP_Instance instace
) = 0;
171 virtual PP_Resource
CreateUDPSocketPrivate(PP_Instance instace
) = 0;
172 virtual PP_Resource
CreateVideoDecoder(PP_Instance instance
) = 0;
173 virtual PP_Resource
CreateVideoDestination(PP_Instance instance
) = 0;
174 virtual PP_Resource
CreateVideoSource(PP_Instance instance
) = 0;
175 virtual PP_Resource
CreateWebSocket(PP_Instance instance
) = 0;
176 virtual PP_Resource
CreateX509CertificatePrivate(PP_Instance instance
) = 0;
177 #if !defined(OS_NACL)
178 virtual PP_Resource
CreateAudioInput(PP_Instance instance
) = 0;
179 virtual PP_Resource
CreateBroker(PP_Instance instance
) = 0;
180 virtual PP_Resource
CreateBrowserFont(
181 PP_Instance instance
,
182 const PP_BrowserFont_Trusted_Description
* description
) = 0;
183 virtual PP_Resource
CreateBuffer(PP_Instance instance
, uint32_t size
) = 0;
184 virtual PP_Resource
CreateFlashDRM(PP_Instance instance
) = 0;
185 virtual PP_Resource
CreateFlashFontFile(
186 PP_Instance instance
,
187 const PP_BrowserFont_Trusted_Description
* description
,
188 PP_PrivateFontCharset charset
) = 0;
189 virtual PP_Resource
CreateFlashMenu(PP_Instance instance
,
190 const PP_Flash_Menu
* menu_data
) = 0;
191 virtual PP_Resource
CreateFlashMessageLoop(PP_Instance instance
) = 0;
192 virtual PP_Resource
CreatePlatformVerificationPrivate(
193 PP_Instance instance
) = 0;
194 virtual PP_Resource
CreateScrollbar(PP_Instance instance
,
195 PP_Bool vertical
) = 0;
196 virtual PP_Resource
CreateTalk(PP_Instance instance
) = 0;
197 virtual PP_Resource
CreateVideoCapture(PP_Instance instance
) = 0;
198 virtual PP_Resource
CreateVideoDecoderDev(
199 PP_Instance instance
,
200 PP_Resource context3d_id
,
201 PP_VideoDecoder_Profile profile
) = 0;
202 #endif // !defined(OS_NACL)
204 static const ApiID kApiID
= API_ID_RESOURCE_CREATION
;
210 #endif // PPAPI_THUNK_RESOURCE_CREATION_API_H_