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. 4 5 #ifndef PPAPI_THUNK_RESOURCE_CREATION_API_H_ 6 #define PPAPI_THUNK_RESOURCE_CREATION_API_H_ 7 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" 25 26 struct PP_Flash_Menu; 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; 32 struct PP_Size; 33 34 namespace ppapi { 35 36 struct FileRefCreateInfo; 37 struct URLRequestInfoData; 38 struct URLResponseInfoData; 39 40 namespace thunk { 41 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 { 48 public: ~ResourceCreationAPI()49 virtual ~ResourceCreationAPI() {} 50 51 virtual PP_Resource CreateFileIO(PP_Instance instance) = 0; 52 virtual PP_Resource CreateFileRef( 53 PP_Instance instance, 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, 60 struct PP_Var text, 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( 67 PP_Instance instance, 68 PP_InputEvent_Type type, 69 PP_TimeTicks time_stamp, 70 uint32_t modifiers, 71 uint32_t key_code, 72 struct PP_Var character_text) = 0; 73 virtual PP_Resource CreateKeyboardInputEvent_1_2( 74 PP_Instance instance, 75 PP_InputEvent_Type type, 76 PP_TimeTicks time_stamp, 77 uint32_t modifiers, 78 uint32_t key_code, 79 struct PP_Var character_text, 80 struct PP_Var code) = 0; 81 virtual PP_Resource CreateMouseInputEvent( 82 PP_Instance instance, 83 PP_InputEvent_Type type, 84 PP_TimeTicks time_stamp, 85 uint32_t modifiers, 86 PP_InputEvent_MouseButton mouse_button, 87 const PP_Point* mouse_position, 88 int32_t click_count, 89 const PP_Point* mouse_movement) = 0; 90 virtual PP_Resource CreateTouchInputEvent( 91 PP_Instance instance, 92 PP_InputEvent_Type type, 93 PP_TimeTicks time_stamp, 94 uint32_t modifiers) = 0; 95 virtual PP_Resource CreateTrueTypeFont( 96 PP_Instance instance, 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; 101 102 virtual PP_Resource CreateWheelInputEvent( 103 PP_Instance instance, 104 PP_TimeTicks time_stamp, 105 uint32_t modifiers, 106 const PP_FloatPoint* wheel_delta, 107 const PP_FloatPoint* wheel_ticks, 108 PP_Bool scroll_by_page) = 0; 109 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 CreateCompositor(PP_Instance instance) = 0; 123 virtual PP_Resource CreateFileChooser(PP_Instance instance, 124 PP_FileChooserMode_Dev mode, 125 const PP_Var& accept_types) = 0; 126 virtual PP_Resource CreateGraphics2D(PP_Instance instance, 127 const PP_Size* size, 128 PP_Bool is_always_opaque) = 0; 129 virtual PP_Resource CreateGraphics3D(PP_Instance instance, 130 PP_Resource share_context, 131 const int32_t* attrib_list) = 0; 132 virtual PP_Resource CreateGraphics3DRaw(PP_Instance instance, 133 PP_Resource share_context, 134 const int32_t* attrib_list) = 0; 135 virtual PP_Resource CreateHostResolver(PP_Instance instance) = 0; 136 virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) = 0; 137 virtual PP_Resource CreateImageData(PP_Instance instance, 138 PP_ImageDataFormat format, 139 const PP_Size* size, 140 PP_Bool init_to_zero) = 0; 141 virtual PP_Resource CreateImageDataSimple(PP_Instance instance, 142 PP_ImageDataFormat format, 143 const PP_Size* size, 144 PP_Bool init_to_zero) = 0; 145 virtual PP_Resource CreateMediaStreamVideoTrack(PP_Instance instance) = 0; 146 virtual PP_Resource CreateNetAddressFromIPv4Address( 147 PP_Instance instance, 148 const PP_NetAddress_IPv4* ipv4_addr) = 0; 149 virtual PP_Resource CreateNetAddressFromIPv6Address( 150 PP_Instance instance, 151 const PP_NetAddress_IPv6* ipv6_addr) = 0; 152 virtual PP_Resource CreateNetAddressFromNetAddressPrivate( 153 PP_Instance instance, 154 const PP_NetAddress_Private& private_addr) = 0; 155 virtual PP_Resource CreateNetworkMonitor(PP_Instance instance) = 0; 156 virtual PP_Resource CreateOutputProtectionPrivate(PP_Instance instance) = 0; 157 virtual PP_Resource CreatePrinting(PP_Instance instance) = 0; 158 virtual PP_Resource CreateTCPServerSocketPrivate(PP_Instance instance) = 0; 159 virtual PP_Resource CreateTCPSocket1_0(PP_Instance instace) = 0; 160 virtual PP_Resource CreateTCPSocket(PP_Instance instance) = 0; 161 virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instace) = 0; 162 virtual PP_Resource CreateUDPSocket(PP_Instance instace) = 0; 163 virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instace) = 0; 164 virtual PP_Resource CreateVideoDecoder(PP_Instance instance) = 0; 165 virtual PP_Resource CreateVideoDestination(PP_Instance instance) = 0; 166 virtual PP_Resource CreateVideoSource(PP_Instance instance) = 0; 167 virtual PP_Resource CreateWebSocket(PP_Instance instance) = 0; 168 virtual PP_Resource CreateX509CertificatePrivate(PP_Instance instance) = 0; 169 #if !defined(OS_NACL) 170 virtual PP_Resource CreateAudioInput(PP_Instance instance) = 0; 171 virtual PP_Resource CreateBroker(PP_Instance instance) = 0; 172 virtual PP_Resource CreateBrowserFont( 173 PP_Instance instance, 174 const PP_BrowserFont_Trusted_Description* description) = 0; 175 virtual PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) = 0; 176 virtual PP_Resource CreateFlashDRM(PP_Instance instance) = 0; 177 virtual PP_Resource CreateFlashFontFile( 178 PP_Instance instance, 179 const PP_BrowserFont_Trusted_Description* description, 180 PP_PrivateFontCharset charset) = 0; 181 virtual PP_Resource CreateFlashMenu(PP_Instance instance, 182 const PP_Flash_Menu* menu_data) = 0; 183 virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) = 0; 184 virtual PP_Resource CreatePlatformVerificationPrivate( 185 PP_Instance instance) = 0; 186 virtual PP_Resource CreateScrollbar(PP_Instance instance, 187 PP_Bool vertical) = 0; 188 virtual PP_Resource CreateTalk(PP_Instance instance) = 0; 189 virtual PP_Resource CreateVideoCapture(PP_Instance instance) = 0; 190 virtual PP_Resource CreateVideoDecoderDev( 191 PP_Instance instance, 192 PP_Resource context3d_id, 193 PP_VideoDecoder_Profile profile) = 0; 194 #endif // !defined(OS_NACL) 195 196 static const ApiID kApiID = API_ID_RESOURCE_CREATION; 197 }; 198 199 } // namespace thunk 200 } // namespace ppapi 201 202 #endif // PPAPI_THUNK_RESOURCE_CREATION_API_H_ 203