| 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 "webkit/plugins/ppapi/ppb_proxy_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" |
| 6 | 6 |
| 7 #include "ppapi/c/private/ppb_proxy_private.h" | 7 #include "ppapi/c/private/ppb_proxy_private.h" |
| 8 #include "ppapi/thunk/enter.h" | 8 #include "ppapi/thunk/enter.h" |
| 9 #include "ppapi/thunk/ppb_image_data_api.h" | 9 #include "ppapi/thunk/ppb_image_data_api.h" |
| 10 #include "webkit/plugins/ppapi/host_globals.h" | 10 #include "webkit/plugins/ppapi/host_globals.h" |
| 11 #include "webkit/plugins/ppapi/plugin_module.h" | 11 #include "webkit/plugins/ppapi/plugin_module.h" |
| 12 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 12 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 13 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" | |
| 14 | 13 |
| 15 using ppapi::PpapiGlobals; | 14 using ppapi::PpapiGlobals; |
| 16 using ppapi::thunk::EnterResource; | 15 using ppapi::thunk::EnterResource; |
| 17 using ppapi::thunk::PPB_URLLoader_API; | 16 using ppapi::thunk::PPB_URLLoader_API; |
| 18 | 17 |
| 19 namespace webkit { | 18 namespace webkit { |
| 20 namespace ppapi { | 19 namespace ppapi { |
| 21 | 20 |
| 22 namespace { | 21 namespace { |
| 23 | 22 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 35 return obj->pp_instance(); | 34 return obj->pp_instance(); |
| 36 } | 35 } |
| 37 | 36 |
| 38 void SetReserveInstanceIDCallback(PP_Module module, | 37 void SetReserveInstanceIDCallback(PP_Module module, |
| 39 PP_Bool (*reserve)(PP_Module, PP_Instance)) { | 38 PP_Bool (*reserve)(PP_Module, PP_Instance)) { |
| 40 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); | 39 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); |
| 41 if (plugin_module) | 40 if (plugin_module) |
| 42 plugin_module->SetReserveInstanceIDCallback(reserve); | 41 plugin_module->SetReserveInstanceIDCallback(reserve); |
| 43 } | 42 } |
| 44 | 43 |
| 45 int32_t GetURLLoaderBufferedBytes(PP_Resource url_loader) { | |
| 46 EnterResource<PPB_URLLoader_API> enter(url_loader, true); | |
| 47 if (enter.succeeded()) | |
| 48 return static_cast<PPB_URLLoader_Impl*>(enter.object())->buffer_size(); | |
| 49 return 0; | |
| 50 } | |
| 51 | |
| 52 void AddRefModule(PP_Module module) { | 44 void AddRefModule(PP_Module module) { |
| 53 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); | 45 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); |
| 54 if (plugin_module) | 46 if (plugin_module) |
| 55 plugin_module->AddRef(); | 47 plugin_module->AddRef(); |
| 56 } | 48 } |
| 57 | 49 |
| 58 void ReleaseModule(PP_Module module) { | 50 void ReleaseModule(PP_Module module) { |
| 59 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); | 51 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); |
| 60 if (plugin_module) | 52 if (plugin_module) |
| 61 plugin_module->Release(); | 53 plugin_module->Release(); |
| 62 } | 54 } |
| 63 | 55 |
| 64 PP_Bool IsInModuleDestructor(PP_Module module) { | 56 PP_Bool IsInModuleDestructor(PP_Module module) { |
| 65 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); | 57 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); |
| 66 if (plugin_module) | 58 if (plugin_module) |
| 67 return PP_FromBool(plugin_module->is_in_destructor()); | 59 return PP_FromBool(plugin_module->is_in_destructor()); |
| 68 return PP_FALSE; | 60 return PP_FALSE; |
| 69 } | 61 } |
| 70 | 62 |
| 71 const PPB_Proxy_Private ppb_proxy = { | 63 const PPB_Proxy_Private ppb_proxy = { |
| 72 &PluginCrashed, | 64 &PluginCrashed, |
| 73 &GetInstanceForResource, | 65 &GetInstanceForResource, |
| 74 &SetReserveInstanceIDCallback, | 66 &SetReserveInstanceIDCallback, |
| 75 &GetURLLoaderBufferedBytes, | |
| 76 &AddRefModule, | 67 &AddRefModule, |
| 77 &ReleaseModule, | 68 &ReleaseModule, |
| 78 &IsInModuleDestructor | 69 &IsInModuleDestructor |
| 79 }; | 70 }; |
| 80 | 71 |
| 81 } // namespace | 72 } // namespace |
| 82 | 73 |
| 83 // static | 74 // static |
| 84 const PPB_Proxy_Private* PPB_Proxy_Impl::GetInterface() { | 75 const PPB_Proxy_Private* PPB_Proxy_Impl::GetInterface() { |
| 85 return &ppb_proxy; | 76 return &ppb_proxy; |
| 86 } | 77 } |
| 87 | 78 |
| 88 } // namespace ppapi | 79 } // namespace ppapi |
| 89 } // namespace webkit | 80 } // namespace webkit |
| OLD | NEW |