| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/proxy/resource_creation_proxy.h" | 5 #include "ppapi/proxy/resource_creation_proxy.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/pp_size.h" | 8 #include "ppapi/c/pp_size.h" |
| 9 #include "ppapi/proxy/host_resource.h" | 9 #include "ppapi/proxy/host_resource.h" |
| 10 #include "ppapi/proxy/interface_id.h" | 10 #include "ppapi/proxy/interface_id.h" |
| 11 #include "ppapi/proxy/plugin_dispatcher.h" | 11 #include "ppapi/proxy/plugin_dispatcher.h" |
| 12 #include "ppapi/c/trusted/ppb_image_data_trusted.h" | 12 #include "ppapi/c/trusted/ppb_image_data_trusted.h" |
| 13 #include "ppapi/proxy/plugin_resource_tracker.h" | 13 #include "ppapi/proxy/plugin_resource_tracker.h" |
| 14 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
| 15 #include "ppapi/proxy/ppb_audio_config_proxy.h" | 15 #include "ppapi/proxy/ppb_audio_config_proxy.h" |
| 16 #include "ppapi/proxy/ppb_audio_proxy.h" | 16 #include "ppapi/proxy/ppb_audio_proxy.h" |
| 17 #include "ppapi/proxy/ppb_buffer_proxy.h" | 17 #include "ppapi/proxy/ppb_buffer_proxy.h" |
| 18 #include "ppapi/proxy/ppb_broker_proxy.h" | 18 #include "ppapi/proxy/ppb_broker_proxy.h" |
| 19 #include "ppapi/proxy/ppb_file_chooser_proxy.h" | |
| 20 #include "ppapi/proxy/ppb_file_ref_proxy.h" | |
| 21 #include "ppapi/proxy/ppb_file_system_proxy.h" | |
| 22 #include "ppapi/proxy/ppb_font_proxy.h" | 19 #include "ppapi/proxy/ppb_font_proxy.h" |
| 23 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" | 20 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" |
| 24 #include "ppapi/proxy/ppb_image_data_proxy.h" | 21 #include "ppapi/proxy/ppb_image_data_proxy.h" |
| 25 #include "ppapi/shared_impl/font_impl.h" | 22 #include "ppapi/shared_impl/font_impl.h" |
| 26 #include "ppapi/shared_impl/function_group_base.h" | 23 #include "ppapi/shared_impl/function_group_base.h" |
| 27 #include "ppapi/thunk/enter.h" | 24 #include "ppapi/thunk/enter.h" |
| 28 #include "ppapi/thunk/ppb_image_data_api.h" | 25 #include "ppapi/thunk/ppb_image_data_api.h" |
| 29 | 26 |
| 30 using ppapi::thunk::ResourceCreationAPI; | 27 using ppapi::thunk::ResourceCreationAPI; |
| 31 | 28 |
| 32 namespace pp { | 29 namespace pp { |
| 33 namespace proxy { | 30 namespace proxy { |
| 34 | 31 |
| 35 ResourceCreationProxy::ResourceCreationProxy(Dispatcher* dispatcher) | 32 ResourceCreationProxy::ResourceCreationProxy(Dispatcher* dispatcher) |
| 36 : dispatcher_(dispatcher) { | 33 : dispatcher_(dispatcher) { |
| 37 } | 34 } |
| 38 | 35 |
| 39 ResourceCreationProxy::~ResourceCreationProxy() { | 36 ResourceCreationProxy::~ResourceCreationProxy() { |
| 40 } | 37 } |
| 41 | 38 |
| 42 ::ppapi::thunk::ResourceCreationAPI* | 39 ::ppapi::thunk::ResourceCreationAPI* |
| 43 ResourceCreationProxy::AsResourceCreationAPI() { | 40 ResourceCreationProxy::AsResourceCreation() { |
| 44 return this; | 41 return this; |
| 45 } | 42 } |
| 46 | 43 |
| 47 PP_Resource ResourceCreationProxy::CreateAudio( | 44 PP_Resource ResourceCreationProxy::CreateAudio( |
| 48 PP_Instance instance, | 45 PP_Instance instance, |
| 49 PP_Resource config_id, | 46 PP_Resource config_id, |
| 50 PPB_Audio_Callback audio_callback, | 47 PPB_Audio_Callback audio_callback, |
| 51 void* user_data) { | 48 void* user_data) { |
| 52 return PPB_Audio_Proxy::CreateProxyResource(instance, config_id, | 49 return PPB_Audio_Proxy::CreateProxyResource(instance, config_id, |
| 53 audio_callback, user_data); | 50 audio_callback, user_data); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 | 65 |
| 69 PP_Resource ResourceCreationProxy::CreateBroker(PP_Instance instance) { | 66 PP_Resource ResourceCreationProxy::CreateBroker(PP_Instance instance) { |
| 70 return PPB_Broker_Proxy::CreateProxyResource(instance); | 67 return PPB_Broker_Proxy::CreateProxyResource(instance); |
| 71 } | 68 } |
| 72 | 69 |
| 73 PP_Resource ResourceCreationProxy::CreateBuffer(PP_Instance instance, | 70 PP_Resource ResourceCreationProxy::CreateBuffer(PP_Instance instance, |
| 74 uint32_t size) { | 71 uint32_t size) { |
| 75 return PPB_Buffer_Proxy::CreateProxyResource(instance, size); | 72 return PPB_Buffer_Proxy::CreateProxyResource(instance, size); |
| 76 } | 73 } |
| 77 | 74 |
| 78 PP_Resource ResourceCreationProxy::CreateDirectoryReader( | |
| 79 PP_Resource directory_ref) { | |
| 80 // Not proxied yet. | |
| 81 return 0; | |
| 82 } | |
| 83 | |
| 84 PP_Resource ResourceCreationProxy::CreateFileChooser( | |
| 85 PP_Instance instance, | |
| 86 const PP_FileChooserOptions_Dev* options) { | |
| 87 return PPB_FileChooser_Proxy::CreateProxyResource(instance, options); | |
| 88 } | |
| 89 | |
| 90 PP_Resource ResourceCreationProxy::CreateFileIO(PP_Instance instance) { | |
| 91 // Not proxied yet. | |
| 92 return 0; | |
| 93 } | |
| 94 | |
| 95 PP_Resource ResourceCreationProxy::CreateFileRef(PP_Resource file_system, | |
| 96 const char* path) { | |
| 97 return PPB_FileRef_Proxy::CreateProxyResource(file_system, path); | |
| 98 } | |
| 99 | |
| 100 PP_Resource ResourceCreationProxy::CreateFileSystem( | |
| 101 PP_Instance instance, | |
| 102 PP_FileSystemType_Dev type) { | |
| 103 return PPB_FileSystem_Proxy::CreateProxyResource(instance, type); | |
| 104 } | |
| 105 | |
| 106 PP_Resource ResourceCreationProxy::CreateFontObject( | 75 PP_Resource ResourceCreationProxy::CreateFontObject( |
| 107 PP_Instance instance, | 76 PP_Instance instance, |
| 108 const PP_FontDescription_Dev* description) { | 77 const PP_FontDescription_Dev* description) { |
| 109 if (!ppapi::FontImpl::IsPPFontDescriptionValid(*description)) | 78 if (!ppapi::FontImpl::IsPPFontDescriptionValid(*description)) |
| 110 return 0; | 79 return 0; |
| 111 | 80 |
| 112 linked_ptr<Font> object(new Font(HostResource::MakeInstanceOnly(instance), | 81 linked_ptr<Font> object(new Font(HostResource::MakeInstanceOnly(instance), |
| 113 *description)); | 82 *description)); |
| 114 return PluginResourceTracker::GetInstance()->AddResource(object); | 83 return PluginResourceTracker::GetInstance()->AddResource(object); |
| 115 } | 84 } |
| 116 | 85 |
| 117 PP_Resource ResourceCreationProxy::CreateGraphics2D(PP_Instance instance, | 86 PP_Resource ResourceCreationProxy::CreateGraphics2D(PP_Instance pp_instance, |
| 118 const PP_Size& size, | 87 const PP_Size& size, |
| 119 PP_Bool is_always_opaque) { | 88 PP_Bool is_always_opaque) { |
| 120 return PPB_Graphics2D_Proxy::CreateProxyResource(instance, size, | 89 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance); |
| 121 is_always_opaque); | 90 if (!dispatcher) |
| 91 return PP_ERROR_BADARGUMENT; |
| 92 |
| 93 HostResource result; |
| 94 dispatcher->Send(new PpapiHostMsg_ResourceCreation_Graphics2D( |
| 95 INTERFACE_ID_RESOURCE_CREATION, pp_instance, size, is_always_opaque, |
| 96 &result)); |
| 97 if (result.is_null()) |
| 98 return 0; |
| 99 linked_ptr<Graphics2D> graphics_2d(new Graphics2D(result, size, |
| 100 is_always_opaque)); |
| 101 return PluginResourceTracker::GetInstance()->AddResource(graphics_2d); |
| 122 } | 102 } |
| 123 | 103 |
| 124 PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance, | 104 PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance, |
| 125 PP_ImageDataFormat format, | 105 PP_ImageDataFormat format, |
| 126 const PP_Size& size, | 106 const PP_Size& size, |
| 127 PP_Bool init_to_zero) { | 107 PP_Bool init_to_zero) { |
| 128 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 108 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 129 if (!dispatcher) | 109 if (!dispatcher) |
| 130 return 0; | 110 return 0; |
| 131 | 111 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 *result_image_handle = dispatcher_->ShareHandleWithRemote(ih, false); | 196 *result_image_handle = dispatcher_->ShareHandleWithRemote(ih, false); |
| 217 #else | 197 #else |
| 218 *result_image_handle = ImageData::HandleFromInt(handle); | 198 *result_image_handle = ImageData::HandleFromInt(handle); |
| 219 #endif | 199 #endif |
| 220 } | 200 } |
| 221 } | 201 } |
| 222 } | 202 } |
| 223 | 203 |
| 224 } // namespace proxy | 204 } // namespace proxy |
| 225 } // namespace pp | 205 } // namespace pp |
| OLD | NEW |