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