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: 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( 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 CreateMouseInputEvent( 74 PP_Instance instance, 75 PP_InputEvent_Type type, 76 PP_TimeTicks time_stamp, 77 uint32_t modifiers, 78 PP_InputEvent_MouseButton mouse_button, 79 const PP_Point* mouse_position, 80 int32_t click_count, 81 const PP_Point* mouse_movement) = 0; 82 virtual PP_Resource CreateTouchInputEvent( 83 PP_Instance instance, 84 PP_InputEvent_Type type, 85 PP_TimeTicks time_stamp, 86 uint32_t modifiers) = 0; 87 virtual PP_Resource CreateResourceArray(PP_Instance instance, 88 const PP_Resource elements[], 89 uint32_t size) = 0; 90 virtual PP_Resource CreateTrueTypeFont( 91 PP_Instance instance, 92 const PP_TrueTypeFontDesc_Dev* desc) = 0; 93 virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0; 94 virtual PP_Resource CreateURLRequestInfo( 95 PP_Instance instance) = 0; 96 97 virtual PP_Resource CreateWheelInputEvent( 98 PP_Instance instance, 99 PP_TimeTicks time_stamp, 100 uint32_t modifiers, 101 const PP_FloatPoint* wheel_delta, 102 const PP_FloatPoint* wheel_ticks, 103 PP_Bool scroll_by_page) = 0; 104 105 virtual PP_Resource CreateAudio1_0(PP_Instance instance, 106 PP_Resource config_id, 107 PPB_Audio_Callback_1_0 audio_callback, 108 void* user_data) = 0; 109 virtual PP_Resource CreateAudio(PP_Instance instance, 110 PP_Resource config_id, 111 PPB_Audio_Callback audio_callback, 112 void* user_data) = 0; 113 virtual PP_Resource CreateAudioTrusted(PP_Instance instance) = 0; 114 virtual PP_Resource CreateAudioConfig(PP_Instance instance, 115 PP_AudioSampleRate sample_rate, 116 uint32_t sample_frame_count) = 0; 117 virtual PP_Resource CreateFileChooser(PP_Instance instance, 118 PP_FileChooserMode_Dev mode, 119 const PP_Var& accept_types) = 0; 120 virtual PP_Resource CreateGraphics2D(PP_Instance instance, 121 const PP_Size* size, 122 PP_Bool is_always_opaque) = 0; 123 virtual PP_Resource CreateGraphics3D(PP_Instance instance, 124 PP_Resource share_context, 125 const int32_t* attrib_list) = 0; 126 virtual PP_Resource CreateGraphics3DRaw(PP_Instance instance, 127 PP_Resource share_context, 128 const int32_t* attrib_list) = 0; 129 virtual PP_Resource CreateHostResolver(PP_Instance instance) = 0; 130 virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) = 0; 131 virtual PP_Resource CreateImageData(PP_Instance instance, 132 PP_ImageDataFormat format, 133 const PP_Size* size, 134 PP_Bool init_to_zero) = 0; 135 virtual PP_Resource CreateImageDataSimple(PP_Instance instance, 136 PP_ImageDataFormat format, 137 const PP_Size* size, 138 PP_Bool init_to_zero) = 0; 139 virtual PP_Resource CreateNetAddressFromIPv4Address( 140 PP_Instance instance, 141 const PP_NetAddress_IPv4* ipv4_addr) = 0; 142 virtual PP_Resource CreateNetAddressFromIPv6Address( 143 PP_Instance instance, 144 const PP_NetAddress_IPv6* ipv6_addr) = 0; 145 virtual PP_Resource CreateNetAddressFromNetAddressPrivate( 146 PP_Instance instance, 147 const PP_NetAddress_Private& private_addr) = 0; 148 virtual PP_Resource CreateNetworkMonitor(PP_Instance instance) = 0; 149 virtual PP_Resource CreateOutputProtectionPrivate(PP_Instance instance) = 0; 150 virtual PP_Resource CreatePrinting(PP_Instance instance) = 0; 151 virtual PP_Resource CreateTCPServerSocketPrivate(PP_Instance instance) = 0; 152 virtual PP_Resource CreateTCPSocket1_0(PP_Instance instace) = 0; 153 virtual PP_Resource CreateTCPSocket(PP_Instance instance) = 0; 154 virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instace) = 0; 155 virtual PP_Resource CreateUDPSocket(PP_Instance instace) = 0; 156 virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instace) = 0; 157 virtual PP_Resource CreateVideoDestination(PP_Instance instance) = 0; 158 virtual PP_Resource CreateVideoSource(PP_Instance instance) = 0; 159 virtual PP_Resource CreateWebSocket(PP_Instance instance) = 0; 160 virtual PP_Resource CreateX509CertificatePrivate(PP_Instance instance) = 0; 161 #if !defined(OS_NACL) 162 virtual PP_Resource CreateAudioInput(PP_Instance instance) = 0; 163 virtual PP_Resource CreateBroker(PP_Instance instance) = 0; 164 virtual PP_Resource CreateBrowserFont( 165 PP_Instance instance, 166 const PP_BrowserFont_Trusted_Description* description) = 0; 167 virtual PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) = 0; 168 virtual PP_Resource CreateFlashDRM(PP_Instance instance) = 0; 169 virtual PP_Resource CreateFlashFontFile( 170 PP_Instance instance, 171 const PP_BrowserFont_Trusted_Description* description, 172 PP_PrivateFontCharset charset) = 0; 173 virtual PP_Resource CreateFlashMenu(PP_Instance instance, 174 const PP_Flash_Menu* menu_data) = 0; 175 virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) = 0; 176 virtual PP_Resource CreatePlatformVerificationPrivate( 177 PP_Instance instance) = 0; 178 virtual PP_Resource CreateScrollbar(PP_Instance instance, 179 PP_Bool vertical) = 0; 180 virtual PP_Resource CreateTalk(PP_Instance instance) = 0; 181 virtual PP_Resource CreateVideoCapture(PP_Instance instance) = 0; 182 virtual PP_Resource CreateVideoDecoder( 183 PP_Instance instance, 184 PP_Resource context3d_id, 185 PP_VideoDecoder_Profile profile) = 0; 186 #endif // !defined(OS_NACL) 187 188 static const ApiID kApiID = API_ID_RESOURCE_CREATION; 189 }; 190 191 } // namespace thunk 192 } // namespace ppapi 193 194 #endif // PPAPI_THUNK_RESOURCE_CREATION_API_H_ 195