OLD | NEW |
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 <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Returns the number of resources associated with this module. | 46 // Returns the number of resources associated with this module. |
47 // | 47 // |
48 // This is slow, use only for testing. | 48 // This is slow, use only for testing. |
49 uint32 GetLiveObjectsForModule(PluginModule* module) const; | 49 uint32 GetLiveObjectsForModule(PluginModule* module) const; |
50 | 50 |
51 private: | 51 private: |
52 friend struct DefaultSingletonTraits<ResourceTracker>; | 52 friend struct DefaultSingletonTraits<ResourceTracker>; |
53 friend class Resource; | 53 friend class Resource; |
54 | 54 |
55 // Prohibit creation other then by the Singleton class. | 55 // Prohibit creation other then by the Singleton class. |
56 ResourceTracker() : last_id_(0) {} | 56 ResourceTracker(); |
57 ~ResourceTracker() {} | 57 ~ResourceTracker(); |
58 | 58 |
59 // Adds the given resource to the tracker and assigns it a resource ID and | 59 // Adds the given resource to the tracker and assigns it a resource ID and |
60 // refcount of 1. The assigned resource ID will be returned. Used only by the | 60 // refcount of 1. The assigned resource ID will be returned. Used only by the |
61 // Resource class. | 61 // Resource class. |
62 PP_Resource AddResource(Resource* resource); | 62 PP_Resource AddResource(Resource* resource); |
63 | 63 |
64 // Last assigned resource ID. | 64 // Last assigned resource ID. |
65 PP_Resource last_id_; | 65 PP_Resource last_id_; |
66 | 66 |
67 // For each PP_Resource, keep the Resource* (as refptr) and plugin use count. | 67 // For each PP_Resource, keep the Resource* (as refptr) and plugin use count. |
68 // This use count is different then Resource's RefCount, and is manipulated | 68 // This use count is different then Resource's RefCount, and is manipulated |
69 // using this RefResource/UnrefResource. When it drops to zero, we just remove | 69 // using this RefResource/UnrefResource. When it drops to zero, we just remove |
70 // the resource from this resource tracker, but the resource object will be | 70 // the resource from this resource tracker, but the resource object will be |
71 // alive so long as some scoped_refptr still holds it's reference. This | 71 // alive so long as some scoped_refptr still holds it's reference. This |
72 // prevents plugins from forcing destruction of Resource objects. | 72 // prevents plugins from forcing destruction of Resource objects. |
73 typedef std::pair<scoped_refptr<Resource>, size_t> ResourceAndRefCount; | 73 typedef std::pair<scoped_refptr<Resource>, size_t> ResourceAndRefCount; |
74 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; | 74 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; |
75 ResourceMap live_resources_; | 75 ResourceMap live_resources_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); | 77 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); |
78 }; | 78 }; |
79 | 79 |
80 } // namespace pepper | 80 } // namespace pepper |
81 | 81 |
82 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ | 82 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ |
OLD | NEW |