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 CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ |
6 #define CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ | 6 #define CONTENT_RENDERER_PEPPER_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 22 matching lines...) Expand all Loading... |
33 HostVarTracker(); | 33 HostVarTracker(); |
34 ~HostVarTracker() override; | 34 ~HostVarTracker() override; |
35 | 35 |
36 // Tracks all live V8ObjectVar. This is so we can map between instance + | 36 // Tracks all live V8ObjectVar. This is so we can map between instance + |
37 // V8Object and get the V8ObjectVar corresponding to it. This Add/Remove | 37 // V8Object and get the V8ObjectVar corresponding to it. This Add/Remove |
38 // function is called by the V8ObjectVar when it is created and destroyed. | 38 // function is called by the V8ObjectVar when it is created and destroyed. |
39 void AddV8ObjectVar(ppapi::V8ObjectVar* object_var); | 39 void AddV8ObjectVar(ppapi::V8ObjectVar* object_var); |
40 void RemoveV8ObjectVar(ppapi::V8ObjectVar* object_var); | 40 void RemoveV8ObjectVar(ppapi::V8ObjectVar* object_var); |
41 // Creates or retrieves a V8ObjectVar. | 41 // Creates or retrieves a V8ObjectVar. |
42 PP_Var V8ObjectVarForV8Object(PP_Instance instance, | 42 PP_Var V8ObjectVarForV8Object(PP_Instance instance, |
43 v8::Handle<v8::Object> object); | 43 v8::Local<v8::Object> object); |
44 // Returns the number of V8ObjectVars associated with the given instance. | 44 // Returns the number of V8ObjectVars associated with the given instance. |
45 // Returns 0 if the instance isn't known. | 45 // Returns 0 if the instance isn't known. |
46 CONTENT_EXPORT int GetLiveV8ObjectVarsForTest(PP_Instance instance); | 46 CONTENT_EXPORT int GetLiveV8ObjectVarsForTest(PP_Instance instance); |
47 | 47 |
48 // VarTracker public implementation. | 48 // VarTracker public implementation. |
49 PP_Var MakeResourcePPVarFromMessage(PP_Instance instance, | 49 PP_Var MakeResourcePPVarFromMessage(PP_Instance instance, |
50 const IPC::Message& creation_message, | 50 const IPC::Message& creation_message, |
51 int pending_renderer_id, | 51 int pending_renderer_id, |
52 int pending_browser_id) override; | 52 int pending_browser_id) override; |
53 ppapi::ResourceVar* MakeResourceVar(PP_Resource pp_resource) override; | 53 ppapi::ResourceVar* MakeResourceVar(PP_Resource pp_resource) override; |
(...skipping 15 matching lines...) Expand all Loading... |
69 base::SharedMemoryHandle handle) override; | 69 base::SharedMemoryHandle handle) override; |
70 | 70 |
71 // Clear the reference count of the given object and remove it from | 71 // Clear the reference count of the given object and remove it from |
72 // live_vars_. | 72 // live_vars_. |
73 void ForceReleaseV8Object(ppapi::V8ObjectVar* object_var); | 73 void ForceReleaseV8Object(ppapi::V8ObjectVar* object_var); |
74 | 74 |
75 // A non-unique, ordered key for a V8ObjectVar. Contains the hash of the v8 | 75 // A non-unique, ordered key for a V8ObjectVar. Contains the hash of the v8 |
76 // and the instance it is associated with. | 76 // and the instance it is associated with. |
77 struct V8ObjectVarKey { | 77 struct V8ObjectVarKey { |
78 explicit V8ObjectVarKey(ppapi::V8ObjectVar* object_var); | 78 explicit V8ObjectVarKey(ppapi::V8ObjectVar* object_var); |
79 V8ObjectVarKey(PP_Instance i, v8::Handle<v8::Object> object); | 79 V8ObjectVarKey(PP_Instance i, v8::Local<v8::Object> object); |
80 ~V8ObjectVarKey(); | 80 ~V8ObjectVarKey(); |
81 | 81 |
82 bool operator<(const V8ObjectVarKey& other) const; | 82 bool operator<(const V8ObjectVarKey& other) const; |
83 | 83 |
84 PP_Instance instance; | 84 PP_Instance instance; |
85 int hash; | 85 int hash; |
86 }; | 86 }; |
87 typedef std::multimap<V8ObjectVarKey, ppapi::V8ObjectVar*> ObjectMap; | 87 typedef std::multimap<V8ObjectVarKey, ppapi::V8ObjectVar*> ObjectMap; |
88 | 88 |
89 // Returns an iterator into |object_map| which points to V8Object which | 89 // Returns an iterator into |object_map| which points to V8Object which |
90 // is associated with the given instance and object. | 90 // is associated with the given instance and object. |
91 ObjectMap::iterator GetForV8Object(PP_Instance instance, | 91 ObjectMap::iterator GetForV8Object(PP_Instance instance, |
92 v8::Handle<v8::Object> object); | 92 v8::Local<v8::Object> object); |
93 | 93 |
94 | 94 |
95 // A multimap of V8ObjectVarKey -> ObjectMap. | 95 // A multimap of V8ObjectVarKey -> ObjectMap. |
96 ObjectMap object_map_; | 96 ObjectMap object_map_; |
97 | 97 |
98 // Tracks all shared memory handles used for transmitting array buffers. | 98 // Tracks all shared memory handles used for transmitting array buffers. |
99 struct SharedMemoryMapEntry { | 99 struct SharedMemoryMapEntry { |
100 PP_Instance instance; | 100 PP_Instance instance; |
101 base::SharedMemoryHandle handle; | 101 base::SharedMemoryHandle handle; |
102 uint32 size_in_bytes; | 102 uint32 size_in_bytes; |
103 }; | 103 }; |
104 typedef std::map<int, SharedMemoryMapEntry> SharedMemoryMap; | 104 typedef std::map<int, SharedMemoryMapEntry> SharedMemoryMap; |
105 SharedMemoryMap shared_memory_map_; | 105 SharedMemoryMap shared_memory_map_; |
106 uint32_t last_shared_memory_map_id_; | 106 uint32_t last_shared_memory_map_id_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); | 108 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); |
109 }; | 109 }; |
110 | 110 |
111 } // namespace content | 111 } // namespace content |
112 | 112 |
113 #endif // CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ | 113 #endif // CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ |
OLD | NEW |