| 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 <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // behalf of the plugin. When it drops to 0, we free that ref, keeping | 119 // behalf of the plugin. When it drops to 0, we free that ref, keeping |
| 120 // the resource in the list. | 120 // the resource in the list. |
| 121 // | 121 // |
| 122 // A resource will be in this list as long as the object is alive. | 122 // A resource will be in this list as long as the object is alive. |
| 123 typedef std::pair<Resource*, int> ResourceAndRefCount; | 123 typedef std::pair<Resource*, int> ResourceAndRefCount; |
| 124 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; | 124 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; |
| 125 ResourceMap live_resources_; | 125 ResourceMap live_resources_; |
| 126 | 126 |
| 127 int32 last_resource_value_; | 127 int32 last_resource_value_; |
| 128 | 128 |
| 129 base::WeakPtrFactory<ResourceTracker> weak_ptr_factory_; |
| 130 |
| 129 // On the host side, we want to check that we are only called on the main | 131 // On the host side, we want to check that we are only called on the main |
| 130 // thread. This is to protect us from accidentally using the tracker from | 132 // thread. This is to protect us from accidentally using the tracker from |
| 131 // other threads (especially the IO thread). On the plugin side, the tracker | 133 // other threads (especially the IO thread). On the plugin side, the tracker |
| 132 // is protected by the proxy lock and is thread-safe, so this will be NULL. | 134 // is protected by the proxy lock and is thread-safe, so this will be NULL. |
| 133 scoped_ptr<base::ThreadChecker> thread_checker_; | 135 scoped_ptr<base::ThreadChecker> thread_checker_; |
| 134 | 136 |
| 135 base::WeakPtrFactory<ResourceTracker> weak_ptr_factory_; | |
| 136 | |
| 137 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); | 137 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 } // namespace ppapi | 140 } // namespace ppapi |
| 141 | 141 |
| 142 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ | 142 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ |
| OLD | NEW |