| 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" |
| 19 #include "ppapi/proxy/ppb_font_proxy.h" | 22 #include "ppapi/proxy/ppb_font_proxy.h" |
| 20 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" | 23 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" |
| 21 #include "ppapi/proxy/ppb_image_data_proxy.h" | 24 #include "ppapi/proxy/ppb_image_data_proxy.h" |
| 22 #include "ppapi/shared_impl/font_impl.h" | 25 #include "ppapi/shared_impl/font_impl.h" |
| 23 #include "ppapi/shared_impl/function_group_base.h" | 26 #include "ppapi/shared_impl/function_group_base.h" |
| 24 #include "ppapi/thunk/enter.h" | 27 #include "ppapi/thunk/enter.h" |
| 25 #include "ppapi/thunk/ppb_image_data_api.h" | 28 #include "ppapi/thunk/ppb_image_data_api.h" |
| 26 | 29 |
| 27 using ppapi::thunk::ResourceCreationAPI; | 30 using ppapi::thunk::ResourceCreationAPI; |
| 28 | 31 |
| 29 namespace pp { | 32 namespace pp { |
| 30 namespace proxy { | 33 namespace proxy { |
| 31 | 34 |
| 32 ResourceCreationProxy::ResourceCreationProxy(Dispatcher* dispatcher) | 35 ResourceCreationProxy::ResourceCreationProxy(Dispatcher* dispatcher) |
| 33 : dispatcher_(dispatcher) { | 36 : dispatcher_(dispatcher) { |
| 34 } | 37 } |
| 35 | 38 |
| 36 ResourceCreationProxy::~ResourceCreationProxy() { | 39 ResourceCreationProxy::~ResourceCreationProxy() { |
| 37 } | 40 } |
| 38 | 41 |
| 39 ::ppapi::thunk::ResourceCreationAPI* | 42 ::ppapi::thunk::ResourceCreationAPI* |
| 40 ResourceCreationProxy::AsResourceCreation() { | 43 ResourceCreationProxy::AsResourceCreationAPI() { |
| 41 return this; | 44 return this; |
| 42 } | 45 } |
| 43 | 46 |
| 44 PP_Resource ResourceCreationProxy::CreateAudio( | 47 PP_Resource ResourceCreationProxy::CreateAudio( |
| 45 PP_Instance instance, | 48 PP_Instance instance, |
| 46 PP_Resource config_id, | 49 PP_Resource config_id, |
| 47 PPB_Audio_Callback audio_callback, | 50 PPB_Audio_Callback audio_callback, |
| 48 void* user_data) { | 51 void* user_data) { |
| 49 return PPB_Audio_Proxy::CreateProxyResource(instance, config_id, | 52 return PPB_Audio_Proxy::CreateProxyResource(instance, config_id, |
| 50 audio_callback, user_data); | 53 audio_callback, user_data); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 | 68 |
| 66 PP_Resource ResourceCreationProxy::CreateBroker(PP_Instance instance) { | 69 PP_Resource ResourceCreationProxy::CreateBroker(PP_Instance instance) { |
| 67 return PPB_Broker_Proxy::CreateProxyResource(instance); | 70 return PPB_Broker_Proxy::CreateProxyResource(instance); |
| 68 } | 71 } |
| 69 | 72 |
| 70 PP_Resource ResourceCreationProxy::CreateBuffer(PP_Instance instance, | 73 PP_Resource ResourceCreationProxy::CreateBuffer(PP_Instance instance, |
| 71 uint32_t size) { | 74 uint32_t size) { |
| 72 return PPB_Buffer_Proxy::CreateProxyResource(instance, size); | 75 return PPB_Buffer_Proxy::CreateProxyResource(instance, size); |
| 73 } | 76 } |
| 74 | 77 |
| 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 |
| 75 PP_Resource ResourceCreationProxy::CreateFontObject( | 106 PP_Resource ResourceCreationProxy::CreateFontObject( |
| 76 PP_Instance instance, | 107 PP_Instance instance, |
| 77 const PP_FontDescription_Dev* description) { | 108 const PP_FontDescription_Dev* description) { |
| 78 if (!ppapi::FontImpl::IsPPFontDescriptionValid(*description)) | 109 if (!ppapi::FontImpl::IsPPFontDescriptionValid(*description)) |
| 79 return 0; | 110 return 0; |
| 80 | 111 |
| 81 linked_ptr<Font> object(new Font(HostResource::MakeInstanceOnly(instance), | 112 linked_ptr<Font> object(new Font(HostResource::MakeInstanceOnly(instance), |
| 82 *description)); | 113 *description)); |
| 83 return PluginResourceTracker::GetInstance()->AddResource(object); | 114 return PluginResourceTracker::GetInstance()->AddResource(object); |
| 84 } | 115 } |
| 85 | 116 |
| 86 PP_Resource ResourceCreationProxy::CreateGraphics2D(PP_Instance pp_instance, | 117 PP_Resource ResourceCreationProxy::CreateGraphics2D(PP_Instance instance, |
| 87 const PP_Size& size, | 118 const PP_Size& size, |
| 88 PP_Bool is_always_opaque) { | 119 PP_Bool is_always_opaque) { |
| 89 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance); | 120 return PPB_Graphics2D_Proxy::CreateProxyResource(instance, size, |
| 90 if (!dispatcher) | 121 is_always_opaque); |
| 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); | |
| 102 } | 122 } |
| 103 | 123 |
| 104 PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance, | 124 PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance, |
| 105 PP_ImageDataFormat format, | 125 PP_ImageDataFormat format, |
| 106 const PP_Size& size, | 126 const PP_Size& size, |
| 107 PP_Bool init_to_zero) { | 127 PP_Bool init_to_zero) { |
| 108 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 128 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 109 if (!dispatcher) | 129 if (!dispatcher) |
| 110 return 0; | 130 return 0; |
| 111 | 131 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 *result_image_handle = dispatcher_->ShareHandleWithRemote(ih, false); | 216 *result_image_handle = dispatcher_->ShareHandleWithRemote(ih, false); |
| 197 #else | 217 #else |
| 198 *result_image_handle = ImageData::HandleFromInt(handle); | 218 *result_image_handle = ImageData::HandleFromInt(handle); |
| 199 #endif | 219 #endif |
| 200 } | 220 } |
| 201 } | 221 } |
| 202 } | 222 } |
| 203 | 223 |
| 204 } // namespace proxy | 224 } // namespace proxy |
| 205 } // namespace pp | 225 } // namespace pp |
| OLD | NEW |