| 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" |
| 11 #include "base/compiler_specific.h" |
| 11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 12 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
| 13 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 #include "ppapi/c/pp_instance.h" | 17 #include "ppapi/c/pp_instance.h" |
| 17 #include "ppapi/c/pp_resource.h" | 18 #include "ppapi/c/pp_resource.h" |
| 18 #include "ppapi/shared_impl/function_group_base.h" | 19 #include "ppapi/shared_impl/function_group_base.h" |
| 19 #include "ppapi/shared_impl/resource_tracker.h" | 20 #include "ppapi/shared_impl/resource_tracker.h" |
| 20 #include "ppapi/shared_impl/var_tracker.h" | 21 #include "ppapi/shared_impl/var_tracker.h" |
| 21 #include "webkit/plugins/webkit_plugins_export.h" | 22 #include "webkit/plugins/webkit_plugins_export.h" |
| 22 | 23 |
| 23 typedef struct NPObject NPObject; | 24 typedef struct NPObject NPObject; |
| 24 | 25 |
| 25 namespace ppapi { | 26 namespace ppapi { |
| 27 class ArrayBufferVar; |
| 26 class NPObjectVar; | 28 class NPObjectVar; |
| 27 class Var; | 29 class Var; |
| 28 } | 30 } |
| 29 | 31 |
| 30 namespace webkit { | 32 namespace webkit { |
| 31 namespace ppapi { | 33 namespace ppapi { |
| 32 | 34 |
| 33 // Adds NPObject var tracking to the standard PPAPI VarTracker for use in the | 35 // Adds NPObject var tracking to the standard PPAPI VarTracker for use in the |
| 34 // renderer. | 36 // renderer. |
| 35 class HostVarTracker : public ::ppapi::VarTracker { | 37 class HostVarTracker : public ::ppapi::VarTracker { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 53 // Returns the number of NPObjectVar's associated with the given instance. | 55 // Returns the number of NPObjectVar's associated with the given instance. |
| 54 // Returns 0 if the instance isn't known. | 56 // Returns 0 if the instance isn't known. |
| 55 WEBKIT_PLUGINS_EXPORT int GetLiveNPObjectVarsForInstance( | 57 WEBKIT_PLUGINS_EXPORT int GetLiveNPObjectVarsForInstance( |
| 56 PP_Instance instance) const; | 58 PP_Instance instance) const; |
| 57 | 59 |
| 58 // 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 |
| 59 // instance cleanup. | 61 // instance cleanup. |
| 60 void ForceFreeNPObjectsForInstance(PP_Instance instance); | 62 void ForceFreeNPObjectsForInstance(PP_Instance instance); |
| 61 | 63 |
| 62 private: | 64 private: |
| 65 // VarTracker implementation. |
| 66 virtual ::ppapi::ArrayBufferVar* CreateArrayBuffer( |
| 67 uint32 size_in_bytes) OVERRIDE; |
| 68 |
| 63 typedef std::map<NPObject*, ::ppapi::NPObjectVar*> NPObjectToNPObjectVarMap; | 69 typedef std::map<NPObject*, ::ppapi::NPObjectVar*> NPObjectToNPObjectVarMap; |
| 64 | 70 |
| 65 // Lists all known NPObjects, first indexed by the corresponding instance, | 71 // Lists all known NPObjects, first indexed by the corresponding instance, |
| 66 // then by the NPObject*. This allows us to look up an NPObjectVar given | 72 // then by the NPObject*. This allows us to look up an NPObjectVar given |
| 67 // these two pieces of information. | 73 // these two pieces of information. |
| 68 // | 74 // |
| 69 // The instance map is lazily managed, so we'll add the | 75 // The instance map is lazily managed, so we'll add the |
| 70 // NPObjectToNPObjectVarMap lazily when the first NPObject var is created, | 76 // NPObjectToNPObjectVarMap lazily when the first NPObject var is created, |
| 71 // and delete it when it's empty. | 77 // and delete it when it's empty. |
| 72 typedef std::map<PP_Instance, linked_ptr<NPObjectToNPObjectVarMap> > | 78 typedef std::map<PP_Instance, linked_ptr<NPObjectToNPObjectVarMap> > |
| 73 InstanceMap; | 79 InstanceMap; |
| 74 InstanceMap instance_map_; | 80 InstanceMap instance_map_; |
| 75 | 81 |
| 76 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); | 82 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); |
| 77 }; | 83 }; |
| 78 | 84 |
| 79 } // namespace ppapi | 85 } // namespace ppapi |
| 80 } // namespace webkit | 86 } // namespace webkit |
| 81 | 87 |
| 82 #endif // WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ | 88 #endif // WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ |
| OLD | NEW |