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

Side by Side Diff: webkit/glue/plugins/pepper_resource_tracker.h

Issue 5581008: Add a new GetInstance() method for singleton classes, take 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 11 matching lines...) Expand all
22 class PluginModule; 22 class PluginModule;
23 class Resource; 23 class Resource;
24 24
25 // This class maintains a global list of all live pepper resources. It allows 25 // This class maintains a global list of all live pepper resources. It allows
26 // us to check resource ID validity and to map them to a specific module. 26 // us to check resource ID validity and to map them to a specific module.
27 // 27 //
28 // This object is threadsafe. 28 // This object is threadsafe.
29 class ResourceTracker { 29 class ResourceTracker {
30 public: 30 public:
31 // Returns the pointer to the singleton object. 31 // Returns the pointer to the singleton object.
32 static ResourceTracker* Get() { 32 static ResourceTracker* Get();
33 return Singleton<ResourceTracker>::get();
34 }
35 33
36 // PP_Resources -------------------------------------------------------------- 34 // PP_Resources --------------------------------------------------------------
37 35
38 // The returned pointer will be NULL if there is no resource. Note that this 36 // The returned pointer will be NULL if there is no resource. Note that this
39 // return value is a scoped_refptr so that we ensure the resource is valid 37 // return value is a scoped_refptr so that we ensure the resource is valid
40 // from the point of the lookup to the point that the calling code needs it. 38 // from the point of the lookup to the point that the calling code needs it.
41 // Otherwise, the plugin could Release() the resource on another thread and 39 // Otherwise, the plugin could Release() the resource on another thread and
42 // the object will get deleted out from under us. 40 // the object will get deleted out from under us.
43 scoped_refptr<Resource> GetResource(PP_Resource res) const; 41 scoped_refptr<Resource> GetResource(PP_Resource res) const;
44 42
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // destructor will notify us when the module is deleted. 123 // destructor will notify us when the module is deleted.
126 typedef std::map<PP_Module, PluginModule*> ModuleMap; 124 typedef std::map<PP_Module, PluginModule*> ModuleMap;
127 ModuleMap module_map_; 125 ModuleMap module_map_;
128 126
129 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); 127 DISALLOW_COPY_AND_ASSIGN(ResourceTracker);
130 }; 128 };
131 129
132 } // namespace pepper 130 } // namespace pepper
133 131
134 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ 132 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698