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
CreateCameraDevicePrivate(PP_Instance instance
) = 0;
128 virtual PP_Resource
CreateCompositor(PP_Instance instance
) = 0;
129 virtual PP_Resource
CreateFileChooser(PP_Instance instance
,
130 PP_FileChooserMode_Dev mode
,
131 const PP_Var
& accept_types
) = 0;
132 virtual PP_Resource
CreateGraphics2D(PP_Instance instance
,
134 PP_Bool is_always_opaque
) = 0;
135 virtual PP_Resource
CreateGraphics3D(PP_Instance instance
,
136 PP_Resource share_context
,
137 const int32_t* attrib_list
) = 0;
138 virtual PP_Resource
CreateGraphics3DRaw(
139 PP_Instance instance
,
140 PP_Resource share_context
,
141 const int32_t* attrib_list
,
142 gpu::Capabilities
* capabilities
,
143 base::SharedMemoryHandle
* shared_state
) = 0;
144 virtual PP_Resource
CreateHostResolver(PP_Instance instance
) = 0;
145 virtual PP_Resource
CreateHostResolverPrivate(PP_Instance instance
) = 0;
146 virtual PP_Resource
CreateImageData(PP_Instance instance
,
147 PP_ImageDataFormat format
,
149 PP_Bool init_to_zero
) = 0;
150 virtual PP_Resource
CreateImageDataSimple(PP_Instance instance
,
151 PP_ImageDataFormat format
,
153 PP_Bool init_to_zero
) = 0;
154 virtual PP_Resource
CreateMediaStreamVideoTrack(PP_Instance instance
) = 0;
155 virtual PP_Resource
CreateNetAddressFromIPv4Address(
156 PP_Instance instance
,
157 const PP_NetAddress_IPv4
* ipv4_addr
) = 0;
158 virtual PP_Resource
CreateNetAddressFromIPv6Address(
159 PP_Instance instance
,
160 const PP_NetAddress_IPv6
* ipv6_addr
) = 0;
161 virtual PP_Resource
CreateNetAddressFromNetAddressPrivate(
162 PP_Instance instance
,
163 const PP_NetAddress_Private
& private_addr
) = 0;
164 virtual PP_Resource
CreateNetworkMonitor(PP_Instance instance
) = 0;
165 virtual PP_Resource
CreateOutputProtectionPrivate(PP_Instance instance
) = 0;
166 virtual PP_Resource
CreatePrinting(PP_Instance instance
) = 0;
167 virtual PP_Resource
CreateTCPServerSocketPrivate(PP_Instance instance
) = 0;
168 virtual PP_Resource
CreateTCPSocket1_0(PP_Instance instace
) = 0;
169 virtual PP_Resource
CreateTCPSocket(PP_Instance instance
) = 0;
170 virtual PP_Resource
CreateTCPSocketPrivate(PP_Instance instace
) = 0;
171 virtual PP_Resource
CreateUDPSocket(PP_Instance instace
) = 0;
172 virtual PP_Resource
CreateUDPSocketPrivate(PP_Instance instace
) = 0;
173 virtual PP_Resource
CreateVideoDecoder(PP_Instance instance
) = 0;
174 virtual PP_Resource
CreateVideoDestination(PP_Instance instance
) = 0;
175 virtual PP_Resource
CreateVideoEncoder(PP_Instance instance
) = 0;
176 virtual PP_Resource
CreateVideoSource(PP_Instance instance
) = 0;
177 virtual PP_Resource
CreateWebSocket(PP_Instance instance
) = 0;
178 virtual PP_Resource
CreateX509CertificatePrivate(PP_Instance instance
) = 0;
179 #if !defined(OS_NACL)
180 virtual PP_Resource
CreateAudioInput(PP_Instance instance
) = 0;
181 virtual PP_Resource
CreateBroker(PP_Instance instance
) = 0;
182 virtual PP_Resource
CreateBrowserFont(
183 PP_Instance instance
,
184 const PP_BrowserFont_Trusted_Description
* description
) = 0;
185 virtual PP_Resource
CreateBuffer(PP_Instance instance
, uint32_t size
) = 0;
186 virtual PP_Resource
CreateFlashDRM(PP_Instance instance
) = 0;
187 virtual PP_Resource
CreateFlashFontFile(
188 PP_Instance instance
,
189 const PP_BrowserFont_Trusted_Description
* description
,
190 PP_PrivateFontCharset charset
) = 0;
191 virtual PP_Resource
CreateFlashMenu(PP_Instance instance
,
192 const PP_Flash_Menu
* menu_data
) = 0;
193 virtual PP_Resource
CreateFlashMessageLoop(PP_Instance instance
) = 0;
194 virtual PP_Resource
CreatePlatformVerificationPrivate(
195 PP_Instance instance
) = 0;
196 virtual PP_Resource
CreateScrollbar(PP_Instance instance
,
197 PP_Bool vertical
) = 0;
198 virtual PP_Resource
CreateTalk(PP_Instance instance
) = 0;
199 virtual PP_Resource
CreateVideoCapture(PP_Instance instance
) = 0;
200 virtual PP_Resource
CreateVideoDecoderDev(
201 PP_Instance instance
,
202 PP_Resource context3d_id
,
203 PP_VideoDecoder_Profile profile
) = 0;
204 #endif // !defined(OS_NACL)
206 static const ApiID kApiID
= API_ID_RESOURCE_CREATION
;
212 #endif // PPAPI_THUNK_RESOURCE_CREATION_API_H_