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
;
37 struct FileRefCreateInfo
;
38 struct URLRequestInfoData
;
39 struct URLResponseInfoData
;
43 // A functional API for creating resource types. Separating out the creation
44 // functions here allows us to implement most resources as a pure "resource
45 // API", meaning all calls are routed on a per-resource-object basis. The
46 // creation functions are not per-object (since there's no object during
47 // creation) so need functional routing based on the instance ID.
48 class ResourceCreationAPI
{
50 virtual ~ResourceCreationAPI() {}
52 virtual PP_Resource
CreateFileIO(PP_Instance instance
) = 0;
53 virtual PP_Resource
CreateFileRef(
55 const FileRefCreateInfo
& serialized
) = 0;
56 virtual PP_Resource
CreateFileSystem(PP_Instance instance
,
57 PP_FileSystemType type
) = 0;
58 virtual PP_Resource
CreateIMEInputEvent(PP_Instance instance
,
59 PP_InputEvent_Type type
,
60 PP_TimeTicks time_stamp
,
62 uint32_t segment_number
,
63 const uint32_t* segment_offsets
,
64 int32_t target_segment
,
65 uint32_t selection_start
,
66 uint32_t selection_end
) = 0;
67 virtual PP_Resource
CreateKeyboardInputEvent_1_0(
69 PP_InputEvent_Type type
,
70 PP_TimeTicks time_stamp
,
73 struct PP_Var character_text
) = 0;
74 virtual PP_Resource
CreateKeyboardInputEvent_1_2(
76 PP_InputEvent_Type type
,
77 PP_TimeTicks time_stamp
,
80 struct PP_Var character_text
,
81 struct PP_Var code
) = 0;
82 virtual PP_Resource
CreateMouseInputEvent(
84 PP_InputEvent_Type type
,
85 PP_TimeTicks time_stamp
,
87 PP_InputEvent_MouseButton mouse_button
,
88 const PP_Point
* mouse_position
,
90 const PP_Point
* mouse_movement
) = 0;
91 virtual PP_Resource
CreateTouchInputEvent(
93 PP_InputEvent_Type type
,
94 PP_TimeTicks time_stamp
,
95 uint32_t modifiers
) = 0;
96 virtual PP_Resource
CreateTrueTypeFont(
98 const PP_TrueTypeFontDesc_Dev
* desc
) = 0;
99 virtual PP_Resource
CreateURLLoader(PP_Instance instance
) = 0;
100 virtual PP_Resource
CreateURLRequestInfo(
101 PP_Instance instance
) = 0;
103 virtual PP_Resource
CreateWheelInputEvent(
104 PP_Instance instance
,
105 PP_TimeTicks time_stamp
,
107 const PP_FloatPoint
* wheel_delta
,
108 const PP_FloatPoint
* wheel_ticks
,
109 PP_Bool scroll_by_page
) = 0;
111 virtual PP_Resource
CreateAudio1_0(PP_Instance instance
,
112 PP_Resource config_id
,
113 PPB_Audio_Callback_1_0 audio_callback
,
114 void* user_data
) = 0;
115 virtual PP_Resource
CreateAudio(PP_Instance instance
,
116 PP_Resource config_id
,
117 PPB_Audio_Callback audio_callback
,
118 void* user_data
) = 0;
119 virtual PP_Resource
CreateAudioTrusted(PP_Instance instance
) = 0;
120 virtual PP_Resource
CreateAudioConfig(PP_Instance instance
,
121 PP_AudioSampleRate sample_rate
,
122 uint32_t sample_frame_count
) = 0;
123 virtual PP_Resource
CreateCompositor(PP_Instance instance
) = 0;
124 virtual PP_Resource
CreateFileChooser(PP_Instance instance
,
125 PP_FileChooserMode_Dev mode
,
126 const PP_Var
& accept_types
) = 0;
127 virtual PP_Resource
CreateGraphics2D(PP_Instance instance
,
129 PP_Bool is_always_opaque
) = 0;
130 virtual PP_Resource
CreateGraphics3D(PP_Instance instance
,
131 PP_Resource share_context
,
132 const int32_t* attrib_list
) = 0;
133 virtual PP_Resource
CreateGraphics3DRaw(
134 PP_Instance instance
,
135 PP_Resource share_context
,
136 const int32_t* attrib_list
,
137 base::SharedMemoryHandle
* shared_state
) = 0;
138 virtual PP_Resource
CreateHostResolver(PP_Instance instance
) = 0;
139 virtual PP_Resource
CreateHostResolverPrivate(PP_Instance instance
) = 0;
140 virtual PP_Resource
CreateImageData(PP_Instance instance
,
141 PP_ImageDataFormat format
,
143 PP_Bool init_to_zero
) = 0;
144 virtual PP_Resource
CreateImageDataSimple(PP_Instance instance
,
145 PP_ImageDataFormat format
,
147 PP_Bool init_to_zero
) = 0;
148 virtual PP_Resource
CreateMediaStreamVideoTrack(PP_Instance instance
) = 0;
149 virtual PP_Resource
CreateNetAddressFromIPv4Address(
150 PP_Instance instance
,
151 const PP_NetAddress_IPv4
* ipv4_addr
) = 0;
152 virtual PP_Resource
CreateNetAddressFromIPv6Address(
153 PP_Instance instance
,
154 const PP_NetAddress_IPv6
* ipv6_addr
) = 0;
155 virtual PP_Resource
CreateNetAddressFromNetAddressPrivate(
156 PP_Instance instance
,
157 const PP_NetAddress_Private
& private_addr
) = 0;
158 virtual PP_Resource
CreateNetworkMonitor(PP_Instance instance
) = 0;
159 virtual PP_Resource
CreateOutputProtectionPrivate(PP_Instance instance
) = 0;
160 virtual PP_Resource
CreatePrinting(PP_Instance instance
) = 0;
161 virtual PP_Resource
CreateTCPServerSocketPrivate(PP_Instance instance
) = 0;
162 virtual PP_Resource
CreateTCPSocket1_0(PP_Instance instace
) = 0;
163 virtual PP_Resource
CreateTCPSocket(PP_Instance instance
) = 0;
164 virtual PP_Resource
CreateTCPSocketPrivate(PP_Instance instace
) = 0;
165 virtual PP_Resource
CreateUDPSocket(PP_Instance instace
) = 0;
166 virtual PP_Resource
CreateUDPSocketPrivate(PP_Instance instace
) = 0;
167 virtual PP_Resource
CreateVideoDecoder(PP_Instance instance
) = 0;
168 virtual PP_Resource
CreateVideoDestination(PP_Instance instance
) = 0;
169 virtual PP_Resource
CreateVideoSource(PP_Instance instance
) = 0;
170 virtual PP_Resource
CreateWebSocket(PP_Instance instance
) = 0;
171 virtual PP_Resource
CreateX509CertificatePrivate(PP_Instance instance
) = 0;
172 #if !defined(OS_NACL)
173 virtual PP_Resource
CreateAudioInput(PP_Instance instance
) = 0;
174 virtual PP_Resource
CreateBroker(PP_Instance instance
) = 0;
175 virtual PP_Resource
CreateBrowserFont(
176 PP_Instance instance
,
177 const PP_BrowserFont_Trusted_Description
* description
) = 0;
178 virtual PP_Resource
CreateBuffer(PP_Instance instance
, uint32_t size
) = 0;
179 virtual PP_Resource
CreateFlashDRM(PP_Instance instance
) = 0;
180 virtual PP_Resource
CreateFlashFontFile(
181 PP_Instance instance
,
182 const PP_BrowserFont_Trusted_Description
* description
,
183 PP_PrivateFontCharset charset
) = 0;
184 virtual PP_Resource
CreateFlashMenu(PP_Instance instance
,
185 const PP_Flash_Menu
* menu_data
) = 0;
186 virtual PP_Resource
CreateFlashMessageLoop(PP_Instance instance
) = 0;
187 virtual PP_Resource
CreatePlatformVerificationPrivate(
188 PP_Instance instance
) = 0;
189 virtual PP_Resource
CreateScrollbar(PP_Instance instance
,
190 PP_Bool vertical
) = 0;
191 virtual PP_Resource
CreateTalk(PP_Instance instance
) = 0;
192 virtual PP_Resource
CreateVideoCapture(PP_Instance instance
) = 0;
193 virtual PP_Resource
CreateVideoDecoderDev(
194 PP_Instance instance
,
195 PP_Resource context3d_id
,
196 PP_VideoDecoder_Profile profile
) = 0;
197 #endif // !defined(OS_NACL)
199 static const ApiID kApiID
= API_ID_RESOURCE_CREATION
;
205 #endif // PPAPI_THUNK_RESOURCE_CREATION_API_H_