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/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "ppapi/c/pp_instance.h" | 16 #include "ppapi/c/pp_instance.h" |
17 #include "ppapi/c/pp_module.h" | 17 #include "ppapi/c/pp_module.h" |
18 #include "ppapi/c/pp_resource.h" | 18 #include "ppapi/c/pp_resource.h" |
19 #include "ppapi/shared_impl/function_group_base.h" | 19 #include "ppapi/shared_impl/function_group_base.h" |
20 #include "ppapi/shared_impl/resource_tracker.h" | 20 #include "ppapi/shared_impl/resource_tracker.h" |
21 #include "ppapi/shared_impl/var_tracker.h" | 21 #include "ppapi/shared_impl/var_tracker.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 { |
26 class NPObjectVar; | 27 class NPObjectVar; |
27 class Var; | 28 class Var; |
28 } | 29 } |
29 | 30 |
30 namespace webkit { | 31 namespace webkit { |
31 namespace ppapi { | 32 namespace ppapi { |
(...skipping 13 matching lines...) Expand all Loading... |
45 void RemoveNPObjectVar(::ppapi::NPObjectVar* object_var); | 46 void RemoveNPObjectVar(::ppapi::NPObjectVar* object_var); |
46 | 47 |
47 // Looks up a previously registered NPObjectVar for the given NPObject and | 48 // Looks up a previously registered NPObjectVar for the given NPObject and |
48 // instance. Returns NULL if there is no NPObjectVar corresponding to the | 49 // instance. Returns NULL if there is no NPObjectVar corresponding to the |
49 // given NPObject for the given instance. See AddNPObjectVar above. | 50 // given NPObject for the given instance. See AddNPObjectVar above. |
50 ::ppapi::NPObjectVar* NPObjectVarForNPObject(PP_Instance instance, | 51 ::ppapi::NPObjectVar* NPObjectVarForNPObject(PP_Instance instance, |
51 NPObject* np_object); | 52 NPObject* np_object); |
52 | 53 |
53 // Returns the number of NPObjectVar's associated with the given instance. | 54 // Returns the number of NPObjectVar's associated with the given instance. |
54 // Returns 0 if the instance isn't known. | 55 // Returns 0 if the instance isn't known. |
55 int GetLiveNPObjectVarsForInstance(PP_Instance instance) const; | 56 WEBKIT_PLUGINS_EXPORT int GetLiveNPObjectVarsForInstance( |
| 57 PP_Instance instance) const; |
56 | 58 |
57 // Forcibly deletes all np object vars for the given instance. Used for | 59 // Forcibly deletes all np object vars for the given instance. Used for |
58 // instance cleanup. | 60 // instance cleanup. |
59 void ForceFreeNPObjectsForInstance(PP_Instance instance); | 61 void ForceFreeNPObjectsForInstance(PP_Instance instance); |
60 | 62 |
61 private: | 63 private: |
62 typedef std::map<NPObject*, ::ppapi::NPObjectVar*> NPObjectToNPObjectVarMap; | 64 typedef std::map<NPObject*, ::ppapi::NPObjectVar*> NPObjectToNPObjectVarMap; |
63 | 65 |
64 // Lists all known NPObjects, first indexed by the corresponding instance, | 66 // Lists all known NPObjects, first indexed by the corresponding instance, |
65 // then by the NPObject*. This allows us to look up an NPObjectVar given | 67 // then by the NPObject*. This allows us to look up an NPObjectVar given |
66 // these two pieces of information. | 68 // these two pieces of information. |
67 // | 69 // |
68 // The instance map is lazily managed, so we'll add the | 70 // The instance map is lazily managed, so we'll add the |
69 // NPObjectToNPObjectVarMap lazily when the first NPObject var is created, | 71 // NPObjectToNPObjectVarMap lazily when the first NPObject var is created, |
70 // and delete it when it's empty. | 72 // and delete it when it's empty. |
71 typedef std::map<PP_Instance, linked_ptr<NPObjectToNPObjectVarMap> > | 73 typedef std::map<PP_Instance, linked_ptr<NPObjectToNPObjectVarMap> > |
72 InstanceMap; | 74 InstanceMap; |
73 InstanceMap instance_map_; | 75 InstanceMap instance_map_; |
74 | 76 |
75 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); | 77 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); |
76 }; | 78 }; |
77 | 79 |
78 } // namespace ppapi | 80 } // namespace ppapi |
79 } // namespace webkit | 81 } // namespace webkit |
80 | 82 |
81 #endif // WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ | 83 #endif // WEBKIT_PLUGINS_PPAPI_HOST_VAR_TRACKER_H_ |
OLD | NEW |