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/ppb_file_chooser_dev.h"
9 #include "ppapi/c/pp_bool.h"
10 #include "ppapi/c/pp_instance.h"
11 #include "ppapi/c/pp_resource.h"
12 #include "ppapi/c/ppb_audio.h"
13 #include "ppapi/c/ppb_audio_config.h"
14 #include "ppapi/c/ppb_file_system.h"
15 #include "ppapi/c/ppb_graphics_3d.h"
16 #include "ppapi/c/ppb_image_data.h"
17 #include "ppapi/c/ppb_input_event.h"
18 #include "ppapi/c/ppb_websocket.h"
19 #include "ppapi/c/dev/pp_video_dev.h"
20 #include "ppapi/c/dev/ppb_truetype_font_dev.h"
21 #include "ppapi/c/private/pp_private_font_charset.h"
22 #include "ppapi/c/private/ppb_network_monitor_private.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 PPB_FileRef_CreateInfo
;
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(PP_Instance instance
,
53 PP_Resource file_system
,
54 const char* path
) = 0;
55 // Like the above version but takes a serialized file ref. The resource
56 // in the serialized file ref is passed into this, which takes ownership of
57 // the reference. In the proxy, the return value will be a plugin resource.
58 // In the impl, the return value will be the same resource ID.
59 virtual PP_Resource
CreateFileRef(
60 const PPB_FileRef_CreateInfo
& serialized
) = 0;
61 virtual PP_Resource
CreateFileSystem(PP_Instance instance
,
62 PP_FileSystemType type
) = 0;
63 virtual PP_Resource
CreateIMEInputEvent(PP_Instance instance
,
64 PP_InputEvent_Type type
,
65 PP_TimeTicks time_stamp
,
67 uint32_t segment_number
,
68 const uint32_t* segment_offsets
,
69 int32_t target_segment
,
70 uint32_t selection_start
,
71 uint32_t selection_end
) = 0;
72 virtual PP_Resource
CreateKeyboardInputEvent(
74 PP_InputEvent_Type type
,
75 PP_TimeTicks time_stamp
,
78 struct PP_Var character_text
) = 0;
79 virtual PP_Resource
CreateMouseInputEvent(
81 PP_InputEvent_Type type
,
82 PP_TimeTicks time_stamp
,
84 PP_InputEvent_MouseButton mouse_button
,
85 const PP_Point
* mouse_position
,
87 const PP_Point
* mouse_movement
) = 0;
88 virtual PP_Resource
CreateTouchInputEvent(
90 PP_InputEvent_Type type
,
91 PP_TimeTicks time_stamp
,
92 uint32_t modifiers
) = 0;
93 virtual PP_Resource
CreateResourceArray(PP_Instance instance
,
94 const PP_Resource elements
[],
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
CreateAudio(PP_Instance instance
,
112 PP_Resource config_id
,
113 PPB_Audio_Callback audio_callback
,
114 void* user_data
) = 0;
115 virtual PP_Resource
CreateAudioTrusted(PP_Instance instance
) = 0;
116 virtual PP_Resource
CreateAudioConfig(PP_Instance instance
,
117 PP_AudioSampleRate sample_rate
,
118 uint32_t sample_frame_count
) = 0;
119 virtual PP_Resource
CreateFileChooser(PP_Instance instance
,
120 PP_FileChooserMode_Dev mode
,
121 const PP_Var
& accept_types
) = 0;
122 virtual PP_Resource
CreateGraphics2D(PP_Instance instance
,
124 PP_Bool is_always_opaque
) = 0;
125 virtual PP_Resource
CreateGraphics3D(PP_Instance instance
,
126 PP_Resource share_context
,
127 const int32_t* attrib_list
) = 0;
128 virtual PP_Resource
CreateGraphics3DRaw(PP_Instance instance
,
129 PP_Resource share_context
,
130 const int32_t* attrib_list
) = 0;
131 virtual PP_Resource
CreateHostResolver(PP_Instance instance
) = 0;
132 virtual PP_Resource
CreateHostResolverPrivate(PP_Instance instance
) = 0;
133 virtual PP_Resource
CreateImageData(PP_Instance instance
,
134 PP_ImageDataFormat format
,
136 PP_Bool init_to_zero
) = 0;
137 virtual PP_Resource
CreateImageDataSimple(PP_Instance instance
,
138 PP_ImageDataFormat format
,
140 PP_Bool init_to_zero
) = 0;
141 virtual PP_Resource
CreateNetAddressFromIPv4Address(
142 PP_Instance instance
,
143 const PP_NetAddress_IPv4
* ipv4_addr
) = 0;
144 virtual PP_Resource
CreateNetAddressFromIPv6Address(
145 PP_Instance instance
,
146 const PP_NetAddress_IPv6
* ipv6_addr
) = 0;
147 virtual PP_Resource
CreateNetAddressFromNetAddressPrivate(
148 PP_Instance instance
,
149 const PP_NetAddress_Private
& private_addr
) = 0;
150 virtual PP_Resource
CreateNetworkMonitor(
151 PP_Instance instance
,
152 PPB_NetworkMonitor_Callback callback
,
153 void* user_data
) = 0;
154 virtual PP_Resource
CreatePrinting(PP_Instance instance
) = 0;
155 virtual PP_Resource
CreateTCPServerSocketPrivate(PP_Instance instance
) = 0;
156 virtual PP_Resource
CreateTCPSocket(PP_Instance instace
) = 0;
157 virtual PP_Resource
CreateTCPSocketPrivate(PP_Instance instace
) = 0;
158 virtual PP_Resource
CreateUDPSocket(PP_Instance instace
) = 0;
159 virtual PP_Resource
CreateUDPSocketPrivate(PP_Instance instace
) = 0;
160 virtual PP_Resource
CreateVideoDestination(PP_Instance instance
) = 0;
161 virtual PP_Resource
CreateVideoSource(PP_Instance instance
) = 0;
162 virtual PP_Resource
CreateWebSocket(PP_Instance instance
) = 0;
163 virtual PP_Resource
CreateX509CertificatePrivate(PP_Instance instance
) = 0;
164 #if !defined(OS_NACL)
165 virtual PP_Resource
CreateAudioInput(PP_Instance instance
) = 0;
166 virtual PP_Resource
CreateBroker(PP_Instance instance
) = 0;
167 virtual PP_Resource
CreateBrowserFont(
168 PP_Instance instance
,
169 const PP_BrowserFont_Trusted_Description
* description
) = 0;
170 virtual PP_Resource
CreateBuffer(PP_Instance instance
, uint32_t size
) = 0;
171 virtual PP_Resource
CreateFlashDRM(PP_Instance instance
) = 0;
172 virtual PP_Resource
CreateFlashFontFile(
173 PP_Instance instance
,
174 const PP_BrowserFont_Trusted_Description
* description
,
175 PP_PrivateFontCharset charset
) = 0;
176 virtual PP_Resource
CreateFlashMenu(PP_Instance instance
,
177 const PP_Flash_Menu
* menu_data
) = 0;
178 virtual PP_Resource
CreateFlashMessageLoop(PP_Instance instance
) = 0;
179 virtual PP_Resource
CreateScrollbar(PP_Instance instance
,
180 PP_Bool vertical
) = 0;
181 virtual PP_Resource
CreateTalk(PP_Instance instance
) = 0;
182 virtual PP_Resource
CreateVideoCapture(PP_Instance instance
) = 0;
183 virtual PP_Resource
CreateVideoDecoder(
184 PP_Instance instance
,
185 PP_Resource context3d_id
,
186 PP_VideoDecoder_Profile profile
) = 0;
187 #endif // !defined(OS_NACL)
189 static const ApiID kApiID
= API_ID_RESOURCE_CREATION
;
195 #endif // PPAPI_THUNK_RESOURCE_CREATION_API_H_