Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: webkit/plugins/ppapi/resource_tracker.h

Issue 8342016: Revert 106142 - Add a new globals object for PPAPI tracking information. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/resource_helper.cc ('k') | webkit/plugins/ppapi/resource_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/resource_tracker.h
===================================================================
--- webkit/plugins/ppapi/resource_tracker.h (revision 106147)
+++ webkit/plugins/ppapi/resource_tracker.h (working copy)
@@ -45,8 +45,8 @@
class ResourceTracker : public ::ppapi::TrackerBase,
public ::ppapi::ResourceTracker {
public:
- ResourceTracker();
- virtual ~ResourceTracker();
+ // Returns the pointer to the singleton object.
+ static ResourceTracker* Get();
// PP_Resources --------------------------------------------------------------
@@ -54,6 +54,8 @@
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.
@@ -117,11 +119,46 @@
// 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;
Property changes on: webkit/plugins/ppapi/resource_tracker.h
___________________________________________________________________
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/src/webkit/plugins/ppapi/resource_tracker.h:r3734-4217,4606-5108,5177-5263
« no previous file with comments | « webkit/plugins/ppapi/resource_helper.cc ('k') | webkit/plugins/ppapi/resource_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698