blob: aeae7f300f1278a897d27e3473c627b2df42fb9d [file] [log] [blame]
[email protected]4f15d2842011-02-15 17:36:331// 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]20790a222013-07-25 02:23:055#include "content/renderer/pepper/ppb_proxy_impl.h"
[email protected]4f15d2842011-02-15 17:36:336
7#include "ppapi/c/private/ppb_proxy_private.h"
[email protected]e18e6392011-06-22 20:57:008#include "ppapi/thunk/enter.h"
9#include "ppapi/thunk/ppb_image_data_api.h"
[email protected]20790a222013-07-25 02:23:0510#include "content/renderer/pepper/host_globals.h"
11#include "content/renderer/pepper/plugin_module.h"
[email protected]4f15d2842011-02-15 17:36:3312
[email protected]794d83cd2011-10-20 19:09:2013using ppapi::PpapiGlobals;
[email protected]e18e6392011-06-22 20:57:0014using ppapi::thunk::EnterResource;
15using ppapi::thunk::PPB_URLLoader_API;
16
[email protected]adab2332013-07-25 18:04:3217namespace content {
[email protected]4f15d2842011-02-15 17:36:3318
19namespace {
20
21void PluginCrashed(PP_Module module) {
[email protected]2f59e382011-10-20 22:51:0122 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
[email protected]4f15d2842011-02-15 17:36:3323 if (plugin_module)
24 plugin_module->PluginCrashed();
25}
26
[email protected]4deeb432011-02-17 23:59:3927PP_Instance GetInstanceForResource(PP_Resource resource) {
[email protected]49323b32013-08-09 16:05:0628 ppapi::Resource* obj =
[email protected]794d83cd2011-10-20 19:09:2029 PpapiGlobals::Get()->GetResourceTracker()->GetResource(resource);
[email protected]4deeb432011-02-17 23:59:3930 if (!obj)
31 return 0;
[email protected]7f8b26b2011-08-18 15:41:0132 return obj->pp_instance();
[email protected]4deeb432011-02-17 23:59:3933}
34
[email protected]2cc062242011-03-10 21:16:3435void SetReserveInstanceIDCallback(PP_Module module,
36 PP_Bool (*reserve)(PP_Module, PP_Instance)) {
[email protected]2f59e382011-10-20 22:51:0137 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
[email protected]2cc062242011-03-10 21:16:3438 if (plugin_module)
39 plugin_module->SetReserveInstanceIDCallback(reserve);
40}
41
[email protected]3502a99692011-04-18 20:51:1842void AddRefModule(PP_Module module) {
[email protected]2f59e382011-10-20 22:51:0143 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
[email protected]3502a99692011-04-18 20:51:1844 if (plugin_module)
45 plugin_module->AddRef();
46}
47
48void ReleaseModule(PP_Module module) {
[email protected]2f59e382011-10-20 22:51:0149 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
[email protected]3502a99692011-04-18 20:51:1850 if (plugin_module)
51 plugin_module->Release();
52}
53
[email protected]e3969072011-10-11 04:17:0654PP_Bool IsInModuleDestructor(PP_Module module) {
[email protected]2f59e382011-10-20 22:51:0155 PluginModule* plugin_module = HostGlobals::Get()->GetModule(module);
[email protected]e3969072011-10-11 04:17:0656 if (plugin_module)
57 return PP_FromBool(plugin_module->is_in_destructor());
58 return PP_FALSE;
59}
60
[email protected]4f15d2842011-02-15 17:36:3361const PPB_Proxy_Private ppb_proxy = {
[email protected]ad63b5c2014-04-11 21:12:3662 &PluginCrashed, &GetInstanceForResource, &SetReserveInstanceIDCallback,
63 &AddRefModule, &ReleaseModule, &IsInModuleDestructor};
[email protected]4f15d2842011-02-15 17:36:3364
65} // namespace
66
67// static
[email protected]ad63b5c2014-04-11 21:12:3668const PPB_Proxy_Private* PPB_Proxy_Impl::GetInterface() { return &ppb_proxy; }
[email protected]4f15d2842011-02-15 17:36:3369
[email protected]adab2332013-07-25 18:04:3270} // namespace content