OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "webkit/plugins/ppapi/resource_tracker.h" | 5 #include "webkit/plugins/ppapi/resource_tracker.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 const T mask = (static_cast<T>(1) << kPPIdTypeBits) - 1; | 39 const T mask = (static_cast<T>(1) << kPPIdTypeBits) - 1; |
40 return (id & mask) == type; | 40 return (id & mask) == type; |
41 } | 41 } |
42 | 42 |
43 namespace webkit { | 43 namespace webkit { |
44 namespace ppapi { | 44 namespace ppapi { |
45 | 45 |
46 static base::LazyInstance<ResourceTracker> g_resource_tracker( | 46 static base::LazyInstance<ResourceTracker> g_resource_tracker( |
47 base::LINKER_INITIALIZED); | 47 base::LINKER_INITIALIZED); |
48 | 48 |
| 49 struct ResourceTracker::InstanceData { |
| 50 InstanceData() : instance(0) {} |
| 51 |
| 52 // Non-owning pointer to the instance object. When a PluginInstance is |
| 53 // destroyed, it will notify us and we'll delete all associated data. |
| 54 PluginInstance* instance; |
| 55 |
| 56 // Resources and object vars associated with the instance. |
| 57 ResourceSet resources; |
| 58 VarSet object_vars; |
| 59 }; |
| 60 |
49 scoped_refptr<Resource> ResourceTracker::GetResource(PP_Resource res) const { | 61 scoped_refptr<Resource> ResourceTracker::GetResource(PP_Resource res) const { |
50 DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) | 62 DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) |
51 << res << " is not a PP_Resource."; | 63 << res << " is not a PP_Resource."; |
52 ResourceMap::const_iterator result = live_resources_.find(res); | 64 ResourceMap::const_iterator result = live_resources_.find(res); |
53 if (result == live_resources_.end()) { | 65 if (result == live_resources_.end()) { |
54 return scoped_refptr<Resource>(); | 66 return scoped_refptr<Resource>(); |
55 } | 67 } |
56 return result->second.first; | 68 return result->second.first; |
57 } | 69 } |
58 | 70 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 339 |
328 // static | 340 // static |
329 void ResourceTracker::ClearSingletonOverride() { | 341 void ResourceTracker::ClearSingletonOverride() { |
330 DCHECK(singleton_override_); | 342 DCHECK(singleton_override_); |
331 singleton_override_ = NULL; | 343 singleton_override_ = NULL; |
332 } | 344 } |
333 | 345 |
334 } // namespace ppapi | 346 } // namespace ppapi |
335 } // namespace webkit | 347 } // namespace webkit |
336 | 348 |
OLD | NEW |