| 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 #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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // resource will have 0 plugin refcount. This is called by the resource | 51 // resource will have 0 plugin refcount. This is called by the resource |
| 52 // constructor. | 52 // constructor. |
| 53 // | 53 // |
| 54 // Returns 0 if the resource could not be added. | 54 // Returns 0 if the resource could not be added. |
| 55 virtual PP_Resource AddResource(Resource* object); | 55 virtual PP_Resource AddResource(Resource* object); |
| 56 | 56 |
| 57 // The opposite of AddResource, this removes the tracking information for | 57 // The opposite of AddResource, this removes the tracking information for |
| 58 // the given resource. It's called from the resource destructor. | 58 // the given resource. It's called from the resource destructor. |
| 59 virtual void RemoveResource(Resource* object); | 59 virtual void RemoveResource(Resource* object); |
| 60 | 60 |
| 61 // Calls LastPluginRefWasDeleted on the given resource object. This is |
| 62 // provided because the derived class in webkit/plugins/ppapi needs to |
| 63 // perform additional operations at this time. |
| 64 virtual void LastPluginRefWasDeleted(Resource* object); |
| 65 |
| 61 private: | 66 private: |
| 62 typedef std::set<PP_Resource> ResourceSet; | 67 typedef std::set<PP_Resource> ResourceSet; |
| 63 | 68 |
| 64 struct InstanceData { | 69 struct InstanceData { |
| 65 // Lists all resources associated with the given instance as non-owning | 70 // Lists all resources associated with the given instance as non-owning |
| 66 // pointers. This allows us to notify those resources that the instance is | 71 // pointers. This allows us to notify those resources that the instance is |
| 67 // going away (otherwise, they may crash if they outlive the instance). | 72 // going away (otherwise, they may crash if they outlive the instance). |
| 68 ResourceSet resources; | 73 ResourceSet resources; |
| 69 }; | 74 }; |
| 70 typedef base::hash_map<PP_Instance, linked_ptr<InstanceData> > InstanceMap; | 75 typedef base::hash_map<PP_Instance, linked_ptr<InstanceData> > InstanceMap; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 84 ResourceMap live_resources_; | 89 ResourceMap live_resources_; |
| 85 | 90 |
| 86 int32 last_resource_value_; | 91 int32 last_resource_value_; |
| 87 | 92 |
| 88 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); | 93 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); |
| 89 }; | 94 }; |
| 90 | 95 |
| 91 } // namespace ppapi | 96 } // namespace ppapi |
| 92 | 97 |
| 93 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ | 98 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ |
| OLD | NEW |