| 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 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 // Forcibly deletes all np object vars for the given instance. Used for | 60 // Forcibly deletes all np object vars for the given instance. Used for |
| 61 // instance cleanup. | 61 // instance cleanup. |
| 62 void ForceFreeNPObjectsForInstance(PP_Instance instance); | 62 void ForceFreeNPObjectsForInstance(PP_Instance instance); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 // VarTracker implementation. | 65 // VarTracker implementation. |
| 66 virtual ::ppapi::ArrayBufferVar* CreateArrayBuffer( | 66 virtual ::ppapi::ArrayBufferVar* CreateArrayBuffer( |
| 67 uint32 size_in_bytes) OVERRIDE; | 67 uint32 size_in_bytes) OVERRIDE; |
| 68 | 68 |
| 69 // Clear the reference count of the given object and remove it from |
| 70 // live_vars_. |
| 71 void ForceReleaseNPObject(::ppapi::NPObjectVar* object); |
| 72 |
| 69 typedef std::map<NPObject*, ::ppapi::NPObjectVar*> NPObjectToNPObjectVarMap; | 73 typedef std::map<NPObject*, ::ppapi::NPObjectVar*> NPObjectToNPObjectVarMap; |
| 70 | 74 |
| 71 // Lists all known NPObjects, first indexed by the corresponding instance, | 75 // Lists all known NPObjects, first indexed by the corresponding instance, |
| 72 // then by the NPObject*. This allows us to look up an NPObjectVar given | 76 // then by the NPObject*. This allows us to look up an NPObjectVar given |
| 73 // these two pieces of information. | 77 // these two pieces of information. |
| 74 // | 78 // |
| 75 // The instance map is lazily managed, so we'll add the | 79 // The instance map is lazily managed, so we'll add the |
| 76 // NPObjectToNPObjectVarMap lazily when the first NPObject var is created, | 80 // NPObjectToNPObjectVarMap lazily when the first NPObject var is created, |
| 77 // and delete it when it's empty. | 81 // and delete it when it's empty. |
| 78 typedef std::map<PP_Instance, linked_ptr<NPObjectToNPObjectVarMap> > | 82 typedef std::map<PP_Instance, linked_ptr<NPObjectToNPObjectVarMap> > |
| 79 InstanceMap; | 83 InstanceMap; |
| 80 InstanceMap instance_map_; | 84 InstanceMap instance_map_; |
| 81 | 85 |
| 82 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); | 86 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); |
| 83 }; | 87 }; |
| 84 | 88 |
| 85 } // namespace ppapi | 89 } // namespace ppapi |
| 86 } // namespace webkit | 90 } // namespace webkit |
| 87 | 91 |
| 88 #endif // WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ | 92 #endif // WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ |
| OLD | NEW |