diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 21:57:50 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 21:57:50 +0000 |
commit | 77ac44f19b5d1ead7c1b29900341fbfc07286ce6 (patch) | |
tree | a09b9951a19ca4a322fbd37a82438ed5e38ae44d /webkit | |
parent | 6b292e3db6ccdda0477289b3d8c713f2707ae9ff (diff) | |
download | chromium_src-77ac44f19b5d1ead7c1b29900341fbfc07286ce6.zip chromium_src-77ac44f19b5d1ead7c1b29900341fbfc07286ce6.tar.gz chromium_src-77ac44f19b5d1ead7c1b29900341fbfc07286ce6.tar.bz2 |
Add a new globals object for PPAPI tracking information.
This adds a specialization on the host and plugin side of the proxy. This
replaces the ad-hoc singleton tracking done by the resource and var trackers
with just being getters on this global object.
Most code can use the single PpapiGlobals class. I also allow code to get the
host and plugin specializations since some code needs access to some specific
features of each side.
In a later pass I'll move the other stuff out of TrackerBase and delete it.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/8316008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106142 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
22 files changed, 208 insertions, 147 deletions
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index 6ccde32..6f9b624 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -204,6 +204,8 @@ '../plugins/ppapi/file_type_conversions.cc', '../plugins/ppapi/file_type_conversions.h', '../plugins/ppapi/fullscreen_container.h', + '../plugins/ppapi/host_globals.cc', + '../plugins/ppapi/host_globals.h', '../plugins/ppapi/message_channel.cc', '../plugins/ppapi/message_channel.h', '../plugins/ppapi/npapi_glue.cc', diff --git a/webkit/plugins/ppapi/callbacks_unittest.cc b/webkit/plugins/ppapi/callbacks_unittest.cc index 30e534b..b11c725 100644 --- a/webkit/plugins/ppapi/callbacks_unittest.cc +++ b/webkit/plugins/ppapi/callbacks_unittest.cc @@ -9,6 +9,7 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "webkit/plugins/ppapi/callbacks.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/mock_resource.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" @@ -184,7 +185,8 @@ class CallbackResourceTest : public PpapiUnittest { // Test that callbacks get aborted on the last resource unref. TEST_F(CallbackResourceTest, AbortOnNoRef) { - ResourceTracker* resource_tracker = ResourceTracker::Get(); + ResourceTracker* resource_tracker = + HostGlobals::Get()->host_resource_tracker(); // Test several things: Unref-ing a resource (to zero refs) with callbacks // which (1) have been run, (2) have been aborted, (3) haven't been completed. @@ -223,7 +225,8 @@ TEST_F(CallbackResourceTest, AbortOnNoRef) { // Test that "resurrecting" a resource (getting a new ID for a |Resource|) // doesn't resurrect callbacks. TEST_F(CallbackResourceTest, Resurrection) { - ResourceTracker* resource_tracker = ResourceTracker::Get(); + ResourceTracker* resource_tracker = + HostGlobals::Get()->host_resource_tracker(); scoped_refptr<CallbackMockResource> resource( new CallbackMockResource(instance()->pp_instance())); diff --git a/webkit/plugins/ppapi/host_globals.cc b/webkit/plugins/ppapi/host_globals.cc new file mode 100644 index 0000000..3a3626f --- /dev/null +++ b/webkit/plugins/ppapi/host_globals.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/plugins/ppapi/host_globals.h" + +namespace webkit { +namespace ppapi { + +HostGlobals* HostGlobals::host_globals_ = NULL; + +HostGlobals::HostGlobals() : ::ppapi::PpapiGlobals() { + DCHECK(!host_globals_); + host_globals_ = this; +} + +HostGlobals::~HostGlobals() { + DCHECK(host_globals_ == this); + host_globals_ = NULL; +} + +::ppapi::ResourceTracker* HostGlobals::GetResourceTracker() { + return &host_resource_tracker_; +} + +::ppapi::VarTracker* HostGlobals::GetVarTracker() { + return &host_var_tracker_; +} + +} // namespace ppapi +} // namespace webkit diff --git a/webkit/plugins/ppapi/host_globals.h b/webkit/plugins/ppapi/host_globals.h new file mode 100644 index 0000000..69b18d0 --- /dev/null +++ b/webkit/plugins/ppapi/host_globals.h @@ -0,0 +1,44 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_ +#define WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_ + +#include "base/compiler_specific.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/var_tracker.h" +#include "webkit/plugins/ppapi/resource_tracker.h" + +namespace webkit { +namespace ppapi { + +class HostGlobals : public ::ppapi::PpapiGlobals { + public: + HostGlobals(); + virtual ~HostGlobals(); + + // Getter for the global singleton. Generally, you should use + // PpapiGlobals::Get() when possible. Use this only when you need some + // host-specific functionality. + inline static HostGlobals* Get() { return host_globals_; } + + // PpapiGlobals implementation. + virtual ::ppapi::ResourceTracker* GetResourceTracker() OVERRIDE; + virtual ::ppapi::VarTracker* GetVarTracker() OVERRIDE; + + ResourceTracker* host_resource_tracker() { return &host_resource_tracker_; } + + private: + static HostGlobals* host_globals_; + + ResourceTracker host_resource_tracker_; + ::ppapi::VarTracker host_var_tracker_; + + DISALLOW_COPY_AND_ASSIGN(HostGlobals); +}; + +} // namespace ppapi +} // namespace webkit + +#endif // WEBKIT_PLUGINS_PPAPI_HOST_GLOBALS_H_ diff --git a/webkit/plugins/ppapi/npapi_glue.cc b/webkit/plugins/ppapi/npapi_glue.cc index cdb49d5..dceb25b 100644 --- a/webkit/plugins/ppapi/npapi_glue.cc +++ b/webkit/plugins/ppapi/npapi_glue.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/string_util.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/npobject_var.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/plugin_object.h" @@ -17,6 +18,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" using ppapi::NPObjectVar; +using ppapi::PpapiGlobals; using ppapi::StringVar; using ppapi::Var; using WebKit::WebBindings; @@ -132,8 +134,8 @@ PP_Var NPIdentifierToPPVar(PP_Module module, NPIdentifier id) { PP_Var NPObjectToPPVar(PluginInstance* instance, NPObject* object) { DCHECK(object); scoped_refptr<NPObjectVar> object_var( - ResourceTracker::Get()->NPObjectVarForNPObject(instance->pp_instance(), - object)); + HostGlobals::Get()->host_resource_tracker()->NPObjectVarForNPObject( + instance->pp_instance(), object)); if (!object_var) { // No object for this module yet, make a new one. object_var = new NPObjectVar(instance->module()->pp_module(), instance->pp_instance(), object); @@ -159,7 +161,7 @@ PPResultAndExceptionToNPResult::~PPResultAndExceptionToNPResult() { // been lost. DCHECK(checked_exception_); - ResourceTracker::Get()->GetVarTracker()->ReleaseVar(exception_); + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(exception_); } // Call this with the return value of the PPAPI function. It will convert @@ -184,7 +186,7 @@ bool PPResultAndExceptionToNPResult::SetResult(PP_Var result) { // No matter what happened, we need to release the reference to the // value passed in. On success, a reference to this value will be in // the np_result_. - ResourceTracker::Get()->GetVarTracker()->ReleaseVar(result); + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(result); return success_; } @@ -236,7 +238,7 @@ PPVarArrayFromNPVariantArray::PPVarArrayFromNPVariantArray( } PPVarArrayFromNPVariantArray::~PPVarArrayFromNPVariantArray() { - ::ppapi::VarTracker* var_tracker = ResourceTracker::Get()->GetVarTracker(); + ::ppapi::VarTracker* var_tracker = PpapiGlobals::Get()->GetVarTracker(); for (size_t i = 0; i < size_; i++) var_tracker->ReleaseVar(array_[i]); } @@ -248,7 +250,7 @@ PPVarFromNPObject::PPVarFromNPObject(PluginInstance* instance, NPObject* object) } PPVarFromNPObject::~PPVarFromNPObject() { - ResourceTracker::Get()->GetVarTracker()->ReleaseVar(var_); + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var_); } // NPObjectAccessorWithIdentifier ---------------------------------------------- @@ -268,7 +270,7 @@ NPObjectAccessorWithIdentifier::NPObjectAccessorWithIdentifier( } NPObjectAccessorWithIdentifier::~NPObjectAccessorWithIdentifier() { - ResourceTracker::Get()->GetVarTracker()->ReleaseVar(identifier_); + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(identifier_); } // TryCatch -------------------------------------------------------------------- diff --git a/webkit/plugins/ppapi/npobject_var.cc b/webkit/plugins/ppapi/npobject_var.cc index e430dd2..f87bea4 100644 --- a/webkit/plugins/ppapi/npobject_var.cc +++ b/webkit/plugins/ppapi/npobject_var.cc @@ -7,8 +7,10 @@ #include "base/logging.h" #include "ppapi/c/pp_var.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/resource_tracker.h" +using webkit::ppapi::HostGlobals; using WebKit::WebBindings; namespace ppapi { @@ -22,12 +24,12 @@ NPObjectVar::NPObjectVar(PP_Module module, pp_instance_(instance), np_object_(np_object) { WebBindings::retainObject(np_object_); - webkit::ppapi::ResourceTracker::Get()->AddNPObjectVar(this); + HostGlobals::Get()->host_resource_tracker()->AddNPObjectVar(this); } NPObjectVar::~NPObjectVar() { if (pp_instance()) - webkit::ppapi::ResourceTracker::Get()->RemoveNPObjectVar(this); + HostGlobals::Get()->host_resource_tracker()->RemoveNPObjectVar(this); WebBindings::releaseObject(np_object_); } @@ -60,7 +62,7 @@ scoped_refptr<NPObjectVar> NPObjectVar::FromPPVar(PP_Var var) { if (var.type != PP_VARTYPE_OBJECT) return scoped_refptr<NPObjectVar>(NULL); scoped_refptr<Var> var_object( - webkit::ppapi::ResourceTracker::Get()->GetVarTracker()->GetVar(var)); + PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); if (!var_object) return scoped_refptr<NPObjectVar>(); return scoped_refptr<NPObjectVar>(var_object->AsNPObjectVar()); diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index f4db023..ce0cee2 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. diff --git a/webkit/plugins/ppapi/plugin_object.cc b/webkit/plugins/ppapi/plugin_object.cc index 7b58456..fbbd349 100644 --- a/webkit/plugins/ppapi/plugin_object.cc +++ b/webkit/plugins/ppapi/plugin_object.cc @@ -15,6 +15,7 @@ #include "ppapi/c/dev/ppp_class_deprecated.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" +#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/var.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" #include "webkit/plugins/ppapi/npapi_glue.h" @@ -23,6 +24,7 @@ #include "webkit/plugins/ppapi/resource_tracker.h" #include "webkit/plugins/ppapi/string.h" +using ppapi::PpapiGlobals; using ppapi::StringVar; using ppapi::Var; using WebKit::WebBindings; @@ -150,7 +152,7 @@ bool WrapperClass_SetProperty(NPObject* object, NPIdentifier property_name, accessor.object()->ppp_class()->SetProperty( accessor.object()->ppp_class_data(), accessor.identifier(), value_var, result_converter.exception()); - ResourceTracker::Get()->GetVarTracker()->ReleaseVar(value_var); + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(value_var); return result_converter.CheckExceptionForNoResult(); } @@ -215,7 +217,7 @@ bool WrapperClass_Enumerate(NPObject* object, NPIdentifier** values, // Release the PP_Var that the plugin allocated. On success, they will all // be converted to NPVariants, and on failure, we want them to just go away. - ::ppapi::VarTracker* var_tracker = ResourceTracker::Get()->GetVarTracker(); + ::ppapi::VarTracker* var_tracker = PpapiGlobals::Get()->GetVarTracker(); for (uint32_t i = 0; i < property_count; ++i) var_tracker->ReleaseVar(properties[i]); free(properties); diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 5ec687d..6e3be13 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -62,6 +62,7 @@ #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/event_conversion.h" #include "webkit/plugins/ppapi/fullscreen_container.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/message_channel.h" #include "webkit/plugins/ppapi/npapi_glue.h" #include "webkit/plugins/ppapi/plugin_delegate.h" @@ -102,6 +103,7 @@ using base::StringPrintf; using ppapi::InputEventImpl; +using ppapi::PpapiGlobals; using ppapi::StringVar; using ppapi::thunk::EnterResourceNoLock; using ppapi::thunk::PPB_Buffer_API; @@ -242,7 +244,8 @@ void RectToPPRect(const gfx::Rect& input, PP_Rect* output) { // unchanged. bool SecurityOriginForInstance(PP_Instance instance_id, WebKit::WebSecurityOrigin* security_origin) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id); if (!instance) return false; @@ -306,7 +309,7 @@ PluginInstance::PluginInstance( text_input_caret_bounds_(0, 0, 0, 0), text_input_caret_set_(false), lock_mouse_callback_(PP_BlockUntilComplete()) { - pp_instance_ = ResourceTracker::Get()->AddInstance(this); + pp_instance_ = HostGlobals::Get()->host_resource_tracker()->AddInstance(this); memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); DCHECK(delegate); @@ -335,7 +338,7 @@ PluginInstance::~PluginInstance() { delegate_->InstanceDeleted(this); module_->InstanceDeleted(this); - ResourceTracker::Get()->InstanceDeleted(pp_instance_); + HostGlobals::Get()->host_resource_tracker()->InstanceDeleted(pp_instance_); } // NOTE: Any of these methods that calls into the plugin needs to take into @@ -423,7 +426,7 @@ void PluginInstance::CommitBackingTexture() { void PluginInstance::InstanceCrashed() { // Force free all resources and vars. - ResourceTracker::Get()->InstanceCrashed(pp_instance()); + HostGlobals::Get()->host_resource_tracker()->InstanceCrashed(pp_instance()); // Free any associated graphics. SetFullscreen(false, false); @@ -870,7 +873,7 @@ string16 PluginInstance::GetSelectedText(bool html) { if (string) selection = UTF8ToUTF16(string->value()); // Release the ref the plugin transfered to us. - ResourceTracker::Get()->GetVarTracker()->ReleaseVar(rv); + HostGlobals::Get()->GetVarTracker()->ReleaseVar(rv); return selection; } @@ -889,7 +892,7 @@ string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) { if (string) link = UTF8ToUTF16(string->value()); // Release the ref the plugin transfered to us. - ResourceTracker::Get()->GetVarTracker()->ReleaseVar(rv); + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(rv); return link; } diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc index e0f26e5..ea73f38 100644 --- a/webkit/plugins/ppapi/ppb_audio_impl.cc +++ b/webkit/plugins/ppapi/ppb_audio_impl.cc @@ -17,6 +17,7 @@ #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/resource_helper.h" +using ppapi::PpapiGlobals; using ppapi::thunk::EnterResourceNoLock; using ppapi::thunk::PPB_Audio_API; using ppapi::thunk::PPB_AudioConfig_API; @@ -94,7 +95,7 @@ bool PPB_Audio_Impl::Init(PP_Resource config, PP_Resource PPB_Audio_Impl::GetCurrentConfig() { // AddRef on behalf of caller, while keeping a ref for ourselves. - ::ppapi::TrackerBase::Get()->GetResourceTracker()->AddRefResource(config_); + PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(config_); return config_; } diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc index da7112b..63279cd 100644 --- a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc +++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc @@ -9,6 +9,7 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/dev/ppb_directory_reader_dev.h" +#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_file_ref_api.h" #include "webkit/plugins/ppapi/common.h" @@ -21,6 +22,7 @@ #include "webkit/plugins/ppapi/resource_helper.h" #include "webkit/plugins/ppapi/resource_tracker.h" +using ::ppapi::PpapiGlobals; using ::ppapi::thunk::EnterResourceNoLock; using ::ppapi::thunk::PPB_DirectoryReader_API; using ::ppapi::thunk::PPB_FileRef_API; @@ -128,8 +130,10 @@ bool PPB_DirectoryReader_Impl::FillUpEntry() { if (!entries_.empty()) { base::FileUtilProxy::Entry dir_entry = entries_.front(); entries_.pop(); - if (entry_->file_ref) - ResourceTracker::Get()->ReleaseResource(entry_->file_ref); + if (entry_->file_ref) { + PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource( + entry_->file_ref); + } PPB_FileRef_Impl* file_ref = PPB_FileRef_Impl::CreateInternal( directory_ref_->file_system()->pp_resource(), diff --git a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc index 73ad13e..fdffadf 100644 --- a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc @@ -18,6 +18,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "webkit/plugins/ppapi/common.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/resource_tracker.h" @@ -64,7 +65,8 @@ PP_Bool IsFormatAvailable(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type, PP_Flash_Clipboard_Format format) { // If you don't give us an instance, we don't give you anything. - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id); if (!instance) return PP_FALSE; @@ -82,7 +84,8 @@ PP_Bool IsFormatAvailable(PP_Instance instance_id, PP_Var ReadPlainText(PP_Instance instance_id, PP_Flash_Clipboard_Type clipboard_type) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id); if (!instance) return PP_MakeNull(); diff --git a/webkit/plugins/ppapi/ppb_flash_file_impl.cc b/webkit/plugins/ppapi/ppb_flash_file_impl.cc index de8b939..47b18f8 100644 --- a/webkit/plugins/ppapi/ppb_flash_file_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_file_impl.cc @@ -16,6 +16,7 @@ #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/file_path.h" #include "webkit/plugins/ppapi/file_type_conversions.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" @@ -66,7 +67,8 @@ int32_t OpenModuleLocalFile(PP_Instance pp_instance, if (!path || !PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file) return PP_ERROR_BADARGUMENT; - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) return PP_ERROR_FAILED; @@ -85,7 +87,8 @@ int32_t RenameModuleLocalFile(PP_Instance pp_instance, if (!from_path || !to_path) return PP_ERROR_BADARGUMENT; - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) return PP_ERROR_FAILED; @@ -101,7 +104,8 @@ int32_t DeleteModuleLocalFileOrDir(PP_Instance pp_instance, if (!path) return PP_ERROR_BADARGUMENT; - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) return PP_ERROR_FAILED; @@ -115,7 +119,8 @@ int32_t CreateModuleLocalDir(PP_Instance pp_instance, const char* path) { if (!path) return PP_ERROR_BADARGUMENT; - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) return PP_ERROR_FAILED; @@ -130,7 +135,8 @@ int32_t QueryModuleLocalFile(PP_Instance pp_instance, if (!path || !info) return PP_ERROR_BADARGUMENT; - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) return PP_ERROR_FAILED; @@ -157,7 +163,8 @@ int32_t GetModuleLocalDirContents(PP_Instance pp_instance, PP_DirContents_Dev** contents) { if (!path || !contents) return PP_ERROR_BADARGUMENT; - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) return PP_ERROR_FAILED; diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc index 58354db..78d5677 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_impl.cc @@ -14,6 +14,7 @@ #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "webkit/plugins/ppapi/common.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" @@ -32,14 +33,16 @@ namespace ppapi { namespace { void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) return; instance->set_always_on_top(PPBoolToBool(on_top)); } PP_Var GetProxyForURL(PP_Instance pp_instance, const char* url) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) return PP_MakeUndefined(); @@ -83,7 +86,8 @@ void QuitMessageLoop(PP_Instance instance) { } double GetLocalTimeZoneOffset(PP_Instance pp_instance, PP_Time t) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) return 0.0; @@ -101,7 +105,8 @@ double GetLocalTimeZoneOffset(PP_Instance pp_instance, PP_Time t) { } PP_Var GetCommandLineArgs(PP_Module pp_module) { - PluginModule* module = ResourceTracker::Get()->GetModule(pp_module); + PluginModule* module = + HostGlobals::Get()->host_resource_tracker()->GetModule(pp_module); if (!module) return PP_MakeUndefined(); diff --git a/webkit/plugins/ppapi/ppb_proxy_impl.cc b/webkit/plugins/ppapi/ppb_proxy_impl.cc index ece3410..884ad7d 100644 --- a/webkit/plugins/ppapi/ppb_proxy_impl.cc +++ b/webkit/plugins/ppapi/ppb_proxy_impl.cc @@ -7,11 +7,13 @@ #include "ppapi/c/private/ppb_proxy_private.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_image_data_api.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" #include "webkit/plugins/ppapi/resource_tracker.h" +using ppapi::PpapiGlobals; using ppapi::thunk::EnterResource; using ppapi::thunk::PPB_URLLoader_API; @@ -21,13 +23,15 @@ namespace ppapi { namespace { void PluginCrashed(PP_Module module) { - PluginModule* plugin_module = ResourceTracker::Get()->GetModule(module); + PluginModule* plugin_module = + HostGlobals::Get()->host_resource_tracker()->GetModule(module); if (plugin_module) plugin_module->PluginCrashed(); } PP_Instance GetInstanceForResource(PP_Resource resource) { - ::ppapi::Resource* obj = ResourceTracker::Get()->GetResource(resource); + ::ppapi::Resource* obj = + PpapiGlobals::Get()->GetResourceTracker()->GetResource(resource); if (!obj) return 0; return obj->pp_instance(); @@ -35,7 +39,8 @@ PP_Instance GetInstanceForResource(PP_Resource resource) { void SetReserveInstanceIDCallback(PP_Module module, PP_Bool (*reserve)(PP_Module, PP_Instance)) { - PluginModule* plugin_module = ResourceTracker::Get()->GetModule(module); + PluginModule* plugin_module = + HostGlobals::Get()->host_resource_tracker()->GetModule(module); if (plugin_module) plugin_module->SetReserveInstanceIDCallback(reserve); } @@ -48,19 +53,22 @@ int32_t GetURLLoaderBufferedBytes(PP_Resource url_loader) { } void AddRefModule(PP_Module module) { - PluginModule* plugin_module = ResourceTracker::Get()->GetModule(module); + PluginModule* plugin_module = + HostGlobals::Get()->host_resource_tracker()->GetModule(module); if (plugin_module) plugin_module->AddRef(); } void ReleaseModule(PP_Module module) { - PluginModule* plugin_module = ResourceTracker::Get()->GetModule(module); + PluginModule* plugin_module = + HostGlobals::Get()->host_resource_tracker()->GetModule(module); if (plugin_module) plugin_module->Release(); } PP_Bool IsInModuleDestructor(PP_Module module) { - PluginModule* plugin_module = ResourceTracker::Get()->GetModule(module); + PluginModule* plugin_module = + HostGlobals::Get()->host_resource_tracker()->GetModule(module); if (plugin_module) return PP_FromBool(plugin_module->is_in_destructor()); return PP_FALSE; diff --git a/webkit/plugins/ppapi/ppb_var_impl.cc b/webkit/plugins/ppapi/ppb_var_impl.cc index 384d449..59df63d 100644 --- a/webkit/plugins/ppapi/ppb_var_impl.cc +++ b/webkit/plugins/ppapi/ppb_var_impl.cc @@ -11,6 +11,7 @@ #include "ppapi/c/pp_var.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" #include "webkit/plugins/ppapi/common.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/npapi_glue.h" #include "webkit/plugins/ppapi/npobject_var.h" #include "webkit/plugins/ppapi/plugin_module.h" @@ -20,6 +21,7 @@ #include "v8/include/v8.h" using ppapi::NPObjectVar; +using ppapi::PpapiGlobals; using ppapi::StringVar; using ppapi::Var; using WebKit::WebBindings; @@ -124,7 +126,8 @@ class ObjectAccessorTryCatch : public TryCatch { NPObjectVar* object() { return object_.get(); } PluginInstance* GetPluginInstance() { - return ResourceTracker::Get()->GetInstance(object()->pp_instance()); + return HostGlobals::Get()->host_resource_tracker()->GetInstance( + object()->pp_instance()); } protected: @@ -170,11 +173,11 @@ class ObjectAccessorWithIdentifierTryCatch : public ObjectAccessorTryCatch { // PPB_Var methods ------------------------------------------------------------- void AddRefVar(PP_Var var) { - ResourceTracker::Get()->GetVarTracker()->AddRefVar(var); + PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); } void ReleaseVar(PP_Var var) { - ResourceTracker::Get()->GetVarTracker()->ReleaseVar(var); + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); } PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) { @@ -404,10 +407,11 @@ bool IsInstanceOfDeprecated(PP_Var var, ppp_class, ppp_class_data); } -PP_Var CreateObjectDeprecated(PP_Instance instance_id, +PP_Var CreateObjectDeprecated(PP_Instance pp_instance, const PPP_Class_Deprecated* ppp_class, void* ppp_class_data) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); if (!instance) { DLOG(ERROR) << "Create object passed an invalid instance."; return PP_MakeNull(); @@ -415,10 +419,11 @@ PP_Var CreateObjectDeprecated(PP_Instance instance_id, return PluginObject::Create(instance, ppp_class, ppp_class_data); } -PP_Var CreateObjectWithModuleDeprecated(PP_Module module_id, +PP_Var CreateObjectWithModuleDeprecated(PP_Module pp_module, const PPP_Class_Deprecated* ppp_class, void* ppp_class_data) { - PluginModule* module = ResourceTracker::Get()->GetModule(module_id); + PluginModule* module = + HostGlobals::Get()->host_resource_tracker()->GetModule(pp_module); if (!module) return PP_MakeNull(); return PluginObject::Create(module->GetSomeInstance(), diff --git a/webkit/plugins/ppapi/ppb_video_capture_impl.cc b/webkit/plugins/ppapi/ppb_video_capture_impl.cc index de97914..466125c 100644 --- a/webkit/plugins/ppapi/ppb_video_capture_impl.cc +++ b/webkit/plugins/ppapi/ppb_video_capture_impl.cc @@ -12,6 +12,7 @@ #include "ppapi/c/dev/ppb_video_capture_dev.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/thunk/enter.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/plugin_module.h" @@ -20,6 +21,7 @@ #include "webkit/plugins/ppapi/resource_helper.h" #include "webkit/plugins/ppapi/resource_tracker.h" +using ppapi::PpapiGlobals; using ppapi::thunk::EnterResourceNoLock; using ppapi::thunk::PPB_Buffer_API; using ppapi::thunk::PPB_VideoCapture_API; @@ -265,7 +267,7 @@ void PPB_VideoCapture_Impl::OnDeviceInfoReceived( info.buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); info.data = info.buffer->Map(); if (!info.data) { - ResourceTracker::Get()->ReleaseResource(resources[i]); + PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(resources[i]); break; } buffers_.push_back(info); @@ -286,7 +288,7 @@ void PPB_VideoCapture_Impl::OnDeviceInfoReceived( void PPB_VideoCapture_Impl::ReleaseBuffers() { DCHECK(!is_dead_); - ResourceTracker *tracker = ResourceTracker::Get(); + ::ppapi::ResourceTracker* tracker = PpapiGlobals::Get()->GetResourceTracker(); for (size_t i = 0; i < buffers_.size(); ++i) { buffers_[i].buffer->Unmap(); tracker->ReleaseResource(buffers_[i].buffer->pp_resource()); diff --git a/webkit/plugins/ppapi/quota_file_io.cc b/webkit/plugins/ppapi/quota_file_io.cc index 73b20ca..37e58c0 100644 --- a/webkit/plugins/ppapi/quota_file_io.cc +++ b/webkit/plugins/ppapi/quota_file_io.cc @@ -12,6 +12,7 @@ #include "base/message_loop_proxy.h" #include "base/stl_util.h" #include "base/task.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/resource_helper.h" #include "webkit/plugins/ppapi/resource_tracker.h" @@ -270,7 +271,8 @@ bool QuotaFileIO::WillSetLength(int64_t length, } PluginDelegate* QuotaFileIO::GetPluginDelegate() const { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance_); + PluginInstance* instance = + HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance_); if (instance) return instance->delegate(); return NULL; diff --git a/webkit/plugins/ppapi/resource_helper.cc b/webkit/plugins/ppapi/resource_helper.cc index 27f303d..cdea783 100644 --- a/webkit/plugins/ppapi/resource_helper.cc +++ b/webkit/plugins/ppapi/resource_helper.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "ppapi/shared_impl/resource.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" @@ -17,7 +18,7 @@ namespace ppapi { // static PluginInstance* ResourceHelper::GetPluginInstance( const ::ppapi::Resource* resource) { - ResourceTracker* tracker = ResourceTracker::Get(); + ResourceTracker* tracker = HostGlobals::Get()->host_resource_tracker(); return tracker->GetInstance(resource->pp_instance()); } diff --git a/webkit/plugins/ppapi/resource_tracker.cc b/webkit/plugins/ppapi/resource_tracker.cc index 6b0de7d..0743723 100644 --- a/webkit/plugins/ppapi/resource_tracker.cc +++ b/webkit/plugins/ppapi/resource_tracker.cc @@ -15,6 +15,7 @@ #include "ppapi/shared_impl/id_assignment.h" #include "ppapi/shared_impl/tracker_base.h" #include "webkit/plugins/ppapi/callbacks.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/npobject_var.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" @@ -36,7 +37,7 @@ namespace ppapi { namespace { ::ppapi::TrackerBase* GetTrackerBase() { - return ResourceTracker::Get(); + return HostGlobals::Get()->host_resource_tracker(); } } // namespace @@ -61,10 +62,6 @@ struct ResourceTracker::InstanceData { function_proxies[::ppapi::proxy::INTERFACE_ID_COUNT]; }; -// static -ResourceTracker* ResourceTracker::global_tracker_ = NULL; -ResourceTracker* ResourceTracker::singleton_override_ = NULL; - ResourceTracker::ResourceTracker() { // Wire up the new shared resource tracker base to use our implementation. ::ppapi::TrackerBase::Init(&GetTrackerBase); @@ -73,15 +70,6 @@ ResourceTracker::ResourceTracker() { ResourceTracker::~ResourceTracker() { } -// static -ResourceTracker* ResourceTracker::Get() { - if (singleton_override_) - return singleton_override_; - if (!global_tracker_) - global_tracker_ = new ResourceTracker; - return global_tracker_; -} - void ResourceTracker::CleanupInstanceData(PP_Instance instance, bool delete_instance) { DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE)) @@ -154,14 +142,6 @@ void ResourceTracker::CleanupInstanceData(PP_Instance instance, return proxy.get(); } -::ppapi::VarTracker* ResourceTracker::GetVarTracker() { - return &var_tracker_; -} - -::ppapi::ResourceTracker* ResourceTracker::GetResourceTracker() { - return this; -} - PP_Module ResourceTracker::GetModuleForInstance(PP_Instance instance) { PluginInstance* inst = GetInstance(instance); if (!inst) @@ -309,17 +289,5 @@ PluginModule* ResourceTracker::GetModule(PP_Module module) { return found->second; } -// static -void ResourceTracker::SetSingletonOverride(ResourceTracker* tracker) { - DCHECK(!singleton_override_); - singleton_override_ = tracker; -} - -// static -void ResourceTracker::ClearSingletonOverride() { - DCHECK(singleton_override_); - singleton_override_ = NULL; -} - } // namespace ppapi } // namespace webkit diff --git a/webkit/plugins/ppapi/resource_tracker.h b/webkit/plugins/ppapi/resource_tracker.h index 79de8be..221a8f9 100644 --- a/webkit/plugins/ppapi/resource_tracker.h +++ b/webkit/plugins/ppapi/resource_tracker.h @@ -45,8 +45,8 @@ class ResourceTrackerTest; class ResourceTracker : public ::ppapi::TrackerBase, public ::ppapi::ResourceTracker { public: - // Returns the pointer to the singleton object. - static ResourceTracker* Get(); + ResourceTracker(); + virtual ~ResourceTracker(); // PP_Resources -------------------------------------------------------------- @@ -54,8 +54,6 @@ class ResourceTracker : public ::ppapi::TrackerBase, virtual ::ppapi::FunctionGroupBase* GetFunctionAPI( PP_Instance pp_instance, ::ppapi::proxy::InterfaceID id) OVERRIDE; - virtual ::ppapi::VarTracker* GetVarTracker() OVERRIDE; - virtual ::ppapi::ResourceTracker* GetResourceTracker() OVERRIDE; virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE; // ppapi::ResourceTracker overrides. @@ -119,46 +117,11 @@ class ResourceTracker : public ::ppapi::TrackerBase, // Per-instance data we track. struct InstanceData; - // Prohibit creation other then by the Singleton class. - ResourceTracker(); - virtual ~ResourceTracker(); - // Force frees all vars and resources associated with the given instance. // If delete_instance is true, the instance tracking information will also // be deleted. void CleanupInstanceData(PP_Instance instance, bool delete_instance); - // Overrides the singleton object. This is used for tests which want to - // specify their own tracker (otherwise, you can get cross-talk between - // tests since the data will live into the subsequent tests). - static void SetSingletonOverride(ResourceTracker* tracker); - static void ClearSingletonOverride(); - - // The lazy-initialized global instance of this object. This is created in - // ::Get() if there is no singleton_override_ specified. - // - // It would be nice to use LazyInstance for this since it manages the - // creation properly, and also cleans up on shutdown. However, the shutdown - // cleanup causes problems in some cases. - // - // For example, say the browser crashes or is killed. The renderer then - // decides to exit. Normally resources are bound to an instance and are - // cleaned up when WebKit deletes the instance (when you go to a different - // page or close that view). In this case, WebKit doesn't clean up. If the - // ResourceTracker was cleaned up by the AtExitManager (which would be the - // case with LazyInstance/Singleton) then we'd try to call up to the renderer - // layer via the delegate, which may be in a random state of shutdown. - // - // So effectively our rule is: any resources still around at shutdown are - // associated with leaked plugins in WebKit, so it's also OK to leak those - // resources from here (avoiding the shutdown race). - static ResourceTracker* global_tracker_; - - // See SetSingletonOverride above. - static ResourceTracker* singleton_override_; - - ::ppapi::VarTracker var_tracker_; - // Like ResourceAndRefCount but for vars, which are associated with modules. typedef std::pair<scoped_refptr< ::ppapi::Var>, size_t> VarAndRefCount; typedef base::hash_map<int32, VarAndRefCount> VarMap; diff --git a/webkit/plugins/ppapi/resource_tracker_unittest.cc b/webkit/plugins/ppapi/resource_tracker_unittest.cc index 0b418bb..68a4b2f 100644 --- a/webkit/plugins/ppapi/resource_tracker_unittest.cc +++ b/webkit/plugins/ppapi/resource_tracker_unittest.cc @@ -9,6 +9,7 @@ #include "ppapi/c/ppp_instance.h" #include "third_party/npapi/bindings/npruntime.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" +#include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/mock_plugin_delegate.h" #include "webkit/plugins/ppapi/mock_resource.h" #include "webkit/plugins/ppapi/npapi_glue.h" @@ -78,23 +79,9 @@ class ResourceTrackerTest : public PpapiUnittest { ResourceTrackerTest() { } - virtual void SetUp() { - // The singleton override must be installed before the generic setup because - // that creates an instance, etc. which uses the tracker. - ResourceTracker::SetSingletonOverride(&tracker_); - PpapiUnittest::SetUp(); + ResourceTracker& tracker() { + return *HostGlobals::Get()->host_resource_tracker(); } - virtual void TearDown() { - // Must do normal tear down before clearing the override for the same rason - // as the SetUp. - PpapiUnittest::TearDown(); - ResourceTracker::ClearSingletonOverride(); - } - - ResourceTracker& tracker() { return tracker_; } - - private: - ResourceTracker tracker_; }; TEST_F(ResourceTrackerTest, DeleteObjectVarWithInstance) { @@ -138,7 +125,8 @@ TEST_F(ResourceTrackerTest, ReuseVar) { } // Remove both of the refs we made above. - ::ppapi::VarTracker* var_tracker = tracker().GetVarTracker(); + ::ppapi::VarTracker* var_tracker = + ::ppapi::PpapiGlobals::Get()->GetVarTracker(); var_tracker->ReleaseVar(static_cast<int32_t>(pp_object2.value.as_id)); var_tracker->ReleaseVar(static_cast<int32_t>(pp_object1.value.as_id)); |