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