Index: webkit/plugins/ppapi/plugin_module.cc |
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc |
index 9742f89b7fb582e65666f67579b8b8f08af44927..2f9f5212c9a0f22342e88d270cf043aa979373b2 100644 |
--- a/webkit/plugins/ppapi/plugin_module.cc |
+++ b/webkit/plugins/ppapi/plugin_module.cc |
@@ -90,6 +90,7 @@ |
#include "webkit/plugins/plugin_switches.h" |
#include "webkit/plugins/ppapi/callbacks.h" |
#include "webkit/plugins/ppapi/common.h" |
+#include "webkit/plugins/ppapi/host_globals.h" |
#include "webkit/plugins/ppapi/ppapi_interface_factory.h" |
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" |
@@ -114,6 +115,7 @@ |
#include "webkit/plugins/ppapi/resource_tracker.h" |
#include "webkit/plugins/ppapi/webkit_forwarding_impl.h" |
+using ppapi::PpapiGlobals; |
using ppapi::TimeTicksToPPTimeTicks; |
using ppapi::TimeToPPTime; |
using ppapi::thunk::EnterResource; |
@@ -124,6 +126,14 @@ namespace ppapi { |
namespace { |
+// Global tracking info for PPAPI plugins. This is lazily created before the |
+// first plugin is allocated, and leaked on shutdown. |
+// |
+// Note that we don't want a Singleton here since destroying this object will |
+// try to free some stuff that requires WebKit, and Singletons are destroyed |
+// after WebKit. |
+webkit::ppapi::HostGlobals* host_globals = NULL; |
+ |
// Maintains all currently loaded plugin libs for validating PP_Module |
// identifiers. |
typedef std::set<PluginModule*> PluginModuleSet; |
@@ -142,11 +152,11 @@ base::MessageLoopProxy* GetMainThreadMessageLoop() { |
// PPB_Core -------------------------------------------------------------------- |
void AddRefResource(PP_Resource resource) { |
- ResourceTracker::Get()->AddRefResource(resource); |
+ PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(resource); |
} |
void ReleaseResource(PP_Resource resource) { |
- ResourceTracker::Get()->ReleaseResource(resource); |
+ PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resource); |
} |
PP_Time GetTime() { |
@@ -205,7 +215,8 @@ void QuitMessageLoop(PP_Instance instance) { |
} |
uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { |
- return ResourceTracker::Get()->GetLiveObjectsForInstance(instance_id); |
+ return HostGlobals::Get()->host_resource_tracker()->GetLiveObjectsForInstance( |
+ instance_id); |
} |
PP_Bool IsOutOfProcess() { |
@@ -371,8 +382,12 @@ PluginModule::PluginModule(const std::string& name, |
name_(name), |
path_(path), |
reserve_instance_id_(NULL) { |
+ // Ensure the globals object is created. |
+ if (!host_globals) |
+ host_globals = new HostGlobals; |
+ |
memset(&entry_points_, 0, sizeof(entry_points_)); |
- pp_module_ = ResourceTracker::Get()->AddModule(this); |
+ pp_module_ = HostGlobals::Get()->host_resource_tracker()->AddModule(this); |
GetMainThreadMessageLoop(); // Initialize the main thread message loop. |
GetLivePluginSet()->insert(this); |
} |
@@ -398,7 +413,7 @@ PluginModule::~PluginModule() { |
base::UnloadNativeLibrary(library_); |
// Notifications that we've been deleted should be last. |
- ResourceTracker::Get()->ModuleDeleted(pp_module_); |
+ HostGlobals::Get()->host_resource_tracker()->ModuleDeleted(pp_module_); |
if (!is_crashed_) { |
// When the plugin crashes, we immediately tell the lifetime delegate that |
// we're gone, so we don't want to tell it again. |