OLD | NEW |
| (Empty) |
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 | |
5 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" | |
6 | |
7 #include "ppapi/c/private/ppb_proxy_private.h" | |
8 #include "ppapi/thunk/enter.h" | |
9 #include "ppapi/thunk/ppb_image_data_api.h" | |
10 #include "webkit/plugins/ppapi/host_globals.h" | |
11 #include "webkit/plugins/ppapi/plugin_module.h" | |
12 | |
13 using ppapi::PpapiGlobals; | |
14 using ppapi::thunk::EnterResource; | |
15 using ppapi::thunk::PPB_URLLoader_API; | |
16 | |
17 namespace webkit { | |
18 namespace ppapi { | |
19 | |
20 namespace { | |
21 | |
22 void PluginCrashed(PP_Module module) { | |
23 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); | |
24 if (plugin_module) | |
25 plugin_module->PluginCrashed(); | |
26 } | |
27 | |
28 PP_Instance GetInstanceForResource(PP_Resource resource) { | |
29 ::ppapi::Resource* obj = | |
30 PpapiGlobals::Get()->GetResourceTracker()->GetResource(resource); | |
31 if (!obj) | |
32 return 0; | |
33 return obj->pp_instance(); | |
34 } | |
35 | |
36 void SetReserveInstanceIDCallback(PP_Module module, | |
37 PP_Bool (*reserve)(PP_Module, PP_Instance)) { | |
38 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); | |
39 if (plugin_module) | |
40 plugin_module->SetReserveInstanceIDCallback(reserve); | |
41 } | |
42 | |
43 void AddRefModule(PP_Module module) { | |
44 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); | |
45 if (plugin_module) | |
46 plugin_module->AddRef(); | |
47 } | |
48 | |
49 void ReleaseModule(PP_Module module) { | |
50 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); | |
51 if (plugin_module) | |
52 plugin_module->Release(); | |
53 } | |
54 | |
55 PP_Bool IsInModuleDestructor(PP_Module module) { | |
56 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module); | |
57 if (plugin_module) | |
58 return PP_FromBool(plugin_module->is_in_destructor()); | |
59 return PP_FALSE; | |
60 } | |
61 | |
62 const PPB_Proxy_Private ppb_proxy = { | |
63 &PluginCrashed, | |
64 &GetInstanceForResource, | |
65 &SetReserveInstanceIDCallback, | |
66 &AddRefModule, | |
67 &ReleaseModule, | |
68 &IsInModuleDestructor | |
69 }; | |
70 | |
71 } // namespace | |
72 | |
73 // static | |
74 const PPB_Proxy_Private* PPB_Proxy_Impl::GetInterface() { | |
75 return &ppb_proxy; | |
76 } | |
77 | |
78 } // namespace ppapi | |
79 } // namespace webkit | |
OLD | NEW |