[email protected] | 4f15d284 | 2011-02-15 17:36:33 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 20790a22 | 2013-07-25 02:23:05 | [diff] [blame] | 5 | #include "content/renderer/pepper/ppb_proxy_impl.h" |
[email protected] | 4f15d284 | 2011-02-15 17:36:33 | [diff] [blame] | 6 | |
7 | #include "ppapi/c/private/ppb_proxy_private.h" | ||||
[email protected] | e18e639 | 2011-06-22 20:57:00 | [diff] [blame] | 8 | #include "ppapi/thunk/enter.h" |
9 | #include "ppapi/thunk/ppb_image_data_api.h" | ||||
[email protected] | 20790a22 | 2013-07-25 02:23:05 | [diff] [blame] | 10 | #include "content/renderer/pepper/host_globals.h" |
11 | #include "content/renderer/pepper/plugin_module.h" | ||||
[email protected] | 4f15d284 | 2011-02-15 17:36:33 | [diff] [blame] | 12 | |
[email protected] | 794d83cd | 2011-10-20 19:09:20 | [diff] [blame] | 13 | using ppapi::PpapiGlobals; |
[email protected] | e18e639 | 2011-06-22 20:57:00 | [diff] [blame] | 14 | using ppapi::thunk::EnterResource; |
15 | using ppapi::thunk::PPB_URLLoader_API; | ||||
16 | |||||
[email protected] | adab233 | 2013-07-25 18:04:32 | [diff] [blame] | 17 | namespace content { |
[email protected] | 4f15d284 | 2011-02-15 17:36:33 | [diff] [blame] | 18 | |
19 | namespace { | ||||
20 | |||||
21 | void PluginCrashed(PP_Module module) { | ||||
[email protected] | 2f59e38 | 2011-10-20 22:51:01 | [diff] [blame] | 22 | PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); |
[email protected] | 4f15d284 | 2011-02-15 17:36:33 | [diff] [blame] | 23 | if (plugin_module) |
24 | plugin_module->PluginCrashed(); | ||||
25 | } | ||||
26 | |||||
[email protected] | 4deeb43 | 2011-02-17 23:59:39 | [diff] [blame] | 27 | PP_Instance GetInstanceForResource(PP_Resource resource) { |
[email protected] | 49323b3 | 2013-08-09 16:05:06 | [diff] [blame] | 28 | ppapi::Resource* obj = |
[email protected] | 794d83cd | 2011-10-20 19:09:20 | [diff] [blame] | 29 | PpapiGlobals::Get()->GetResourceTracker()->GetResource(resource); |
[email protected] | 4deeb43 | 2011-02-17 23:59:39 | [diff] [blame] | 30 | if (!obj) |
31 | return 0; | ||||
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 32 | return obj->pp_instance(); |
[email protected] | 4deeb43 | 2011-02-17 23:59:39 | [diff] [blame] | 33 | } |
34 | |||||
[email protected] | 2cc06224 | 2011-03-10 21:16:34 | [diff] [blame] | 35 | void SetReserveInstanceIDCallback(PP_Module module, |
36 | PP_Bool (*reserve)(PP_Module, PP_Instance)) { | ||||
[email protected] | 2f59e38 | 2011-10-20 22:51:01 | [diff] [blame] | 37 | PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); |
[email protected] | 2cc06224 | 2011-03-10 21:16:34 | [diff] [blame] | 38 | if (plugin_module) |
39 | plugin_module->SetReserveInstanceIDCallback(reserve); | ||||
40 | } | ||||
41 | |||||
[email protected] | 3502a9969 | 2011-04-18 20:51:18 | [diff] [blame] | 42 | void AddRefModule(PP_Module module) { |
[email protected] | 2f59e38 | 2011-10-20 22:51:01 | [diff] [blame] | 43 | PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); |
[email protected] | 3502a9969 | 2011-04-18 20:51:18 | [diff] [blame] | 44 | if (plugin_module) |
45 | plugin_module->AddRef(); | ||||
46 | } | ||||
47 | |||||
48 | void ReleaseModule(PP_Module module) { | ||||
[email protected] | 2f59e38 | 2011-10-20 22:51:01 | [diff] [blame] | 49 | PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); |
[email protected] | 3502a9969 | 2011-04-18 20:51:18 | [diff] [blame] | 50 | if (plugin_module) |
51 | plugin_module->Release(); | ||||
52 | } | ||||
53 | |||||
[email protected] | e396907 | 2011-10-11 04:17:06 | [diff] [blame] | 54 | PP_Bool IsInModuleDestructor(PP_Module module) { |
[email protected] | 2f59e38 | 2011-10-20 22:51:01 | [diff] [blame] | 55 | PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); |
[email protected] | e396907 | 2011-10-11 04:17:06 | [diff] [blame] | 56 | if (plugin_module) |
57 | return PP_FromBool(plugin_module->is_in_destructor()); | ||||
58 | return PP_FALSE; | ||||
59 | } | ||||
60 | |||||
[email protected] | 4f15d284 | 2011-02-15 17:36:33 | [diff] [blame] | 61 | const PPB_Proxy_Private ppb_proxy = { |
[email protected] | ad63b5c | 2014-04-11 21:12:36 | [diff] [blame] | 62 | &PluginCrashed, &GetInstanceForResource, &SetReserveInstanceIDCallback, |
63 | &AddRefModule, &ReleaseModule, &IsInModuleDestructor}; | ||||
[email protected] | 4f15d284 | 2011-02-15 17:36:33 | [diff] [blame] | 64 | |
65 | } // namespace | ||||
66 | |||||
67 | // static | ||||
[email protected] | ad63b5c | 2014-04-11 21:12:36 | [diff] [blame] | 68 | const PPB_Proxy_Private* PPB_Proxy_Impl::GetInterface() { return &ppb_proxy; } |
[email protected] | 4f15d284 | 2011-02-15 17:36:33 | [diff] [blame] | 69 | |
[email protected] | adab233 | 2013-07-25 18:04:32 | [diff] [blame] | 70 | } // namespace content |