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_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
15 #include "base/singleton.h" | |
16 #include "ppapi/c/pp_instance.h" | 15 #include "ppapi/c/pp_instance.h" |
17 #include "ppapi/c/pp_module.h" | 16 #include "ppapi/c/pp_module.h" |
18 #include "ppapi/c/pp_resource.h" | 17 #include "ppapi/c/pp_resource.h" |
19 | 18 |
20 namespace pepper { | 19 namespace base { |
| 20 template <typename T> struct DefaultLazyInstanceTraits; |
| 21 } |
| 22 |
| 23 namespace webkit { |
| 24 namespace plugins { |
| 25 namespace ppapi { |
21 | 26 |
22 class PluginInstance; | 27 class PluginInstance; |
23 class PluginModule; | 28 class PluginModule; |
24 class Resource; | 29 class Resource; |
25 class ResourceTrackerTest; | 30 class ResourceTrackerTest; |
26 | 31 |
27 // This class maintains a global list of all live pepper resources. It allows | 32 // This class maintains a global list of all live pepper resources. It allows |
28 // us to check resource ID validity and to map them to a specific module. | 33 // us to check resource ID validity and to map them to a specific module. |
29 // | 34 // |
30 // This object is threadsafe. | 35 // This object is threadsafe. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 89 |
85 // Called when a plugin instance was deleted and should no longer be tracked. | 90 // Called when a plugin instance was deleted and should no longer be tracked. |
86 // The given handle should be one generated by AddInstance. | 91 // The given handle should be one generated by AddInstance. |
87 void InstanceDeleted(PP_Instance instance); | 92 void InstanceDeleted(PP_Instance instance); |
88 | 93 |
89 // Returns a pointer to the plugin instance object associated with the given | 94 // Returns a pointer to the plugin instance object associated with the given |
90 // instance handle. The return value will be NULL if the handle is invalid. | 95 // instance handle. The return value will be NULL if the handle is invalid. |
91 PluginInstance* GetInstance(PP_Instance instance); | 96 PluginInstance* GetInstance(PP_Instance instance); |
92 | 97 |
93 private: | 98 private: |
94 friend struct DefaultSingletonTraits<ResourceTracker>; | 99 friend struct base::DefaultLazyInstanceTraits<ResourceTracker>; |
95 friend class Resource; | 100 friend class Resource; |
96 friend class ResourceTrackerTest; | 101 friend class ResourceTrackerTest; |
97 | 102 |
98 // Prohibit creation other then by the Singleton class. | 103 // Prohibit creation other then by the Singleton class. |
99 ResourceTracker(); | 104 ResourceTracker(); |
100 ~ResourceTracker(); | 105 ~ResourceTracker(); |
101 | 106 |
102 // Adds the given resource to the tracker and assigns it a resource ID and | 107 // Adds the given resource to the tracker and assigns it a resource ID and |
103 // refcount of 1. The assigned resource ID will be returned. Used only by the | 108 // refcount of 1. The assigned resource ID will be returned. Used only by the |
104 // Resource class. | 109 // Resource class. |
(...skipping 27 matching lines...) Expand all Loading... |
132 InstanceMap instance_map_; | 137 InstanceMap instance_map_; |
133 | 138 |
134 // Tracks all live modules. The pointers are non-owning, the PluginModule | 139 // Tracks all live modules. The pointers are non-owning, the PluginModule |
135 // destructor will notify us when the module is deleted. | 140 // destructor will notify us when the module is deleted. |
136 typedef std::map<PP_Module, PluginModule*> ModuleMap; | 141 typedef std::map<PP_Module, PluginModule*> ModuleMap; |
137 ModuleMap module_map_; | 142 ModuleMap module_map_; |
138 | 143 |
139 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); | 144 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); |
140 }; | 145 }; |
141 | 146 |
142 } // namespace pepper | 147 } // namespace ppapi |
| 148 } // namespace plugins |
| 149 } // namespace webkit |
143 | 150 |
144 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ | 151 #endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_ |
OLD | NEW |