| 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 WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // instance. Returns NULL if there is no NPObjectVar corresponding to the | 49 // instance. Returns NULL if there is no NPObjectVar corresponding to the |
| 50 // given NPObject for the given instance. See AddNPObjectVar above. | 50 // given NPObject for the given instance. See AddNPObjectVar above. |
| 51 ::ppapi::NPObjectVar* NPObjectVarForNPObject(PP_Instance instance, | 51 ::ppapi::NPObjectVar* NPObjectVarForNPObject(PP_Instance instance, |
| 52 NPObject* np_object); | 52 NPObject* np_object); |
| 53 | 53 |
| 54 // Returns the number of NPObjectVar's associated with the given instance. | 54 // Returns the number of NPObjectVar's associated with the given instance. |
| 55 // Returns 0 if the instance isn't known. | 55 // Returns 0 if the instance isn't known. |
| 56 WEBKIT_PLUGINS_EXPORT int GetLiveNPObjectVarsForInstance( | 56 WEBKIT_PLUGINS_EXPORT int GetLiveNPObjectVarsForInstance( |
| 57 PP_Instance instance) const; | 57 PP_Instance instance) const; |
| 58 | 58 |
| 59 // Forcibly deletes all np object vars for the given instance. Used for | 59 // VarTracker public implementation. |
| 60 // instance cleanup. | 60 virtual void DidDeleteInstance(PP_Instance instance) OVERRIDE; |
| 61 void ForceFreeNPObjectsForInstance(PP_Instance instance); | |
| 62 | 61 |
| 63 private: | 62 private: |
| 64 // VarTracker implementation. | 63 // VarTracker private implementation. |
| 65 virtual ::ppapi::ArrayBufferVar* CreateArrayBuffer( | 64 virtual ::ppapi::ArrayBufferVar* CreateArrayBuffer( |
| 66 uint32 size_in_bytes) OVERRIDE; | 65 uint32 size_in_bytes) OVERRIDE; |
| 67 | 66 |
| 68 // Clear the reference count of the given object and remove it from | 67 // Clear the reference count of the given object and remove it from |
| 69 // live_vars_. | 68 // live_vars_. |
| 70 void ForceReleaseNPObject(const base::WeakPtr< ::ppapi::NPObjectVar>& object); | 69 void ForceReleaseNPObject(const base::WeakPtr< ::ppapi::NPObjectVar>& object); |
| 71 | 70 |
| 72 typedef std::map<NPObject*, base::WeakPtr< ::ppapi::NPObjectVar> > | 71 typedef std::map<NPObject*, base::WeakPtr< ::ppapi::NPObjectVar> > |
| 73 NPObjectToNPObjectVarMap; | 72 NPObjectToNPObjectVarMap; |
| 74 | 73 |
| 75 // Lists all known NPObjects, first indexed by the corresponding instance, | 74 // Lists all known NPObjects, first indexed by the corresponding instance, |
| 76 // then by the NPObject*. This allows us to look up an NPObjectVar given | 75 // then by the NPObject*. This allows us to look up an NPObjectVar given |
| 77 // these two pieces of information. | 76 // these two pieces of information. |
| 78 // | 77 // |
| 79 // The instance map is lazily managed, so we'll add the | 78 // The instance map is lazily managed, so we'll add the |
| 80 // NPObjectToNPObjectVarMap lazily when the first NPObject var is created, | 79 // NPObjectToNPObjectVarMap lazily when the first NPObject var is created, |
| 81 // and delete it when it's empty. | 80 // and delete it when it's empty. |
| 82 typedef std::map<PP_Instance, linked_ptr<NPObjectToNPObjectVarMap> > | 81 typedef std::map<PP_Instance, linked_ptr<NPObjectToNPObjectVarMap> > |
| 83 InstanceMap; | 82 InstanceMap; |
| 84 InstanceMap instance_map_; | 83 InstanceMap instance_map_; |
| 85 | 84 |
| 86 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); | 85 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace ppapi | 88 } // namespace ppapi |
| 90 } // namespace webkit | 89 } // namespace webkit |
| 91 | 90 |
| 92 #endif // WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ | 91 #endif // WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ |
| OLD | NEW |