OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ | 5 #ifndef PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ |
6 #define PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ | 6 #define PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/linked_ptr.h" | |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
17 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
18 #include "base/threading/thread_checker_impl.h" | 17 #include "base/threading/thread_checker_impl.h" |
19 #include "ppapi/c/pp_instance.h" | 18 #include "ppapi/c/pp_instance.h" |
20 #include "ppapi/c/pp_resource.h" | 19 #include "ppapi/c/pp_resource.h" |
21 #include "ppapi/shared_impl/ppapi_shared_export.h" | 20 #include "ppapi/shared_impl/ppapi_shared_export.h" |
22 | 21 |
23 namespace ppapi { | 22 namespace ppapi { |
24 | 23 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 bool CanOperateOnResource(PP_Resource res); | 99 bool CanOperateOnResource(PP_Resource res); |
101 | 100 |
102 typedef std::set<PP_Resource> ResourceSet; | 101 typedef std::set<PP_Resource> ResourceSet; |
103 | 102 |
104 struct InstanceData { | 103 struct InstanceData { |
105 // Lists all resources associated with the given instance as non-owning | 104 // Lists all resources associated with the given instance as non-owning |
106 // pointers. This allows us to notify those resources that the instance is | 105 // pointers. This allows us to notify those resources that the instance is |
107 // going away (otherwise, they may crash if they outlive the instance). | 106 // going away (otherwise, they may crash if they outlive the instance). |
108 ResourceSet resources; | 107 ResourceSet resources; |
109 }; | 108 }; |
110 typedef base::hash_map<PP_Instance, linked_ptr<InstanceData> > InstanceMap; | 109 typedef base::hash_map<PP_Instance, scoped_ptr<InstanceData>> InstanceMap; |
111 | 110 |
112 InstanceMap instance_map_; | 111 InstanceMap instance_map_; |
113 | 112 |
114 // For each PP_Resource, keep the object pointer and a plugin use count. | 113 // For each PP_Resource, keep the object pointer and a plugin use count. |
115 // This use count is different then Resource object's RefCount, and is | 114 // This use count is different then Resource object's RefCount, and is |
116 // manipulated using this AddRefResource/UnrefResource. When the plugin use | 115 // manipulated using this AddRefResource/UnrefResource. When the plugin use |
117 // count is positive, we keep an extra ref on the Resource on | 116 // count is positive, we keep an extra ref on the Resource on |
118 // behalf of the plugin. When it drops to 0, we free that ref, keeping | 117 // behalf of the plugin. When it drops to 0, we free that ref, keeping |
119 // the resource in the list. | 118 // the resource in the list. |
120 // | 119 // |
(...skipping 11 matching lines...) Expand all Loading... |
132 scoped_ptr<base::ThreadChecker> thread_checker_; | 131 scoped_ptr<base::ThreadChecker> thread_checker_; |
133 | 132 |
134 base::WeakPtrFactory<ResourceTracker> weak_ptr_factory_; | 133 base::WeakPtrFactory<ResourceTracker> weak_ptr_factory_; |
135 | 134 |
136 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); | 135 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); |
137 }; | 136 }; |
138 | 137 |
139 } // namespace ppapi | 138 } // namespace ppapi |
140 | 139 |
141 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ | 140 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ |
OLD | NEW |