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 #include "webkit/plugins/ppapi/resource_tracker.h" | 5 #include "webkit/plugins/ppapi/resource_tracker.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "ppapi/c/pp_resource.h" | 12 #include "ppapi/c/pp_resource.h" |
13 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
14 #include "ppapi/shared_impl/function_group_base.h" | 14 #include "ppapi/shared_impl/function_group_base.h" |
15 #include "ppapi/shared_impl/id_assignment.h" | 15 #include "ppapi/shared_impl/id_assignment.h" |
16 #include "ppapi/shared_impl/tracker_base.h" | 16 #include "ppapi/shared_impl/tracker_base.h" |
| 17 #include "webkit/plugins/ppapi/callbacks.h" |
17 #include "webkit/plugins/ppapi/npobject_var.h" | 18 #include "webkit/plugins/ppapi/npobject_var.h" |
18 #include "webkit/plugins/ppapi/plugin_module.h" | 19 #include "webkit/plugins/ppapi/plugin_module.h" |
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
20 #include "webkit/plugins/ppapi/ppb_char_set_impl.h" | 21 #include "webkit/plugins/ppapi/ppb_char_set_impl.h" |
21 #include "webkit/plugins/ppapi/ppb_cursor_control_impl.h" | 22 #include "webkit/plugins/ppapi/ppb_cursor_control_impl.h" |
22 #include "webkit/plugins/ppapi/ppb_find_impl.h" | 23 #include "webkit/plugins/ppapi/ppb_find_impl.h" |
23 #include "webkit/plugins/ppapi/ppb_font_impl.h" | 24 #include "webkit/plugins/ppapi/ppb_font_impl.h" |
24 #include "webkit/plugins/ppapi/resource.h" | |
25 #include "webkit/plugins/ppapi/resource_creation_impl.h" | 25 #include "webkit/plugins/ppapi/resource_creation_impl.h" |
| 26 #include "webkit/plugins/ppapi/resource_helper.h" |
26 | 27 |
27 using ppapi::CheckIdType; | 28 using ppapi::CheckIdType; |
28 using ppapi::MakeTypedId; | 29 using ppapi::MakeTypedId; |
29 using ppapi::NPObjectVar; | 30 using ppapi::NPObjectVar; |
30 using ppapi::PPIdType; | 31 using ppapi::PPIdType; |
31 using ppapi::Var; | 32 using ppapi::Var; |
32 | 33 |
33 namespace webkit { | 34 namespace webkit { |
34 namespace ppapi { | 35 namespace ppapi { |
35 | 36 |
(...skipping 22 matching lines...) Expand all Loading... |
58 | 59 |
59 // Lazily allocated function proxies for the different interfaces. | 60 // Lazily allocated function proxies for the different interfaces. |
60 scoped_ptr< ::ppapi::FunctionGroupBase > | 61 scoped_ptr< ::ppapi::FunctionGroupBase > |
61 function_proxies[::ppapi::proxy::INTERFACE_ID_COUNT]; | 62 function_proxies[::ppapi::proxy::INTERFACE_ID_COUNT]; |
62 }; | 63 }; |
63 | 64 |
64 // static | 65 // static |
65 ResourceTracker* ResourceTracker::global_tracker_ = NULL; | 66 ResourceTracker* ResourceTracker::global_tracker_ = NULL; |
66 ResourceTracker* ResourceTracker::singleton_override_ = NULL; | 67 ResourceTracker* ResourceTracker::singleton_override_ = NULL; |
67 | 68 |
68 ResourceTracker::ResourceTracker() | 69 ResourceTracker::ResourceTracker() { |
69 : last_resource_id_(0) { | |
70 // Wire up the new shared resource tracker base to use our implementation. | 70 // Wire up the new shared resource tracker base to use our implementation. |
71 ::ppapi::TrackerBase::Init(&GetTrackerBase); | 71 ::ppapi::TrackerBase::Init(&GetTrackerBase); |
72 } | 72 } |
73 | 73 |
74 ResourceTracker::~ResourceTracker() { | 74 ResourceTracker::~ResourceTracker() { |
75 } | 75 } |
76 | 76 |
77 // static | 77 // static |
78 ResourceTracker* ResourceTracker::Get() { | 78 ResourceTracker* ResourceTracker::Get() { |
79 if (singleton_override_) | 79 if (singleton_override_) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 ::ppapi::VarTracker* ResourceTracker::GetVarTracker() { | 161 ::ppapi::VarTracker* ResourceTracker::GetVarTracker() { |
162 return &var_tracker_; | 162 return &var_tracker_; |
163 } | 163 } |
164 | 164 |
165 ::ppapi::ResourceTracker* ResourceTracker::GetResourceTracker() { | 165 ::ppapi::ResourceTracker* ResourceTracker::GetResourceTracker() { |
166 return this; | 166 return this; |
167 } | 167 } |
168 | 168 |
| 169 void ResourceTracker::LastPluginRefWasDeleted(::ppapi::Resource* object) { |
| 170 ::ppapi::ResourceTracker::LastPluginRefWasDeleted(object); |
| 171 |
| 172 // TODO(brettw) this should be removed when we have the callback tracker |
| 173 // moved to the shared_impl. This will allow the logic to post aborts for |
| 174 // any callbacks directly in the Resource::LastPluginRefWasDeleted function |
| 175 // and we can remove this function altogether. |
| 176 PluginModule* plugin_module = ResourceHelper::GetPluginModule(object); |
| 177 if (plugin_module) { |
| 178 plugin_module->GetCallbackTracker()->PostAbortForResource( |
| 179 object->pp_resource()); |
| 180 } |
| 181 } |
| 182 |
169 void ResourceTracker::AddNPObjectVar(NPObjectVar* object_var) { | 183 void ResourceTracker::AddNPObjectVar(NPObjectVar* object_var) { |
170 DCHECK(instance_map_.find(object_var->pp_instance()) != instance_map_.end()); | 184 DCHECK(instance_map_.find(object_var->pp_instance()) != instance_map_.end()); |
171 InstanceData& data = *instance_map_[object_var->pp_instance()].get(); | 185 InstanceData& data = *instance_map_[object_var->pp_instance()].get(); |
172 | 186 |
173 DCHECK(data.np_object_to_object_var.find(object_var->np_object()) == | 187 DCHECK(data.np_object_to_object_var.find(object_var->np_object()) == |
174 data.np_object_to_object_var.end()) << "NPObjectVar already in map"; | 188 data.np_object_to_object_var.end()) << "NPObjectVar already in map"; |
175 data.np_object_to_object_var[object_var->np_object()] = object_var; | 189 data.np_object_to_object_var[object_var->np_object()] = object_var; |
176 } | 190 } |
177 | 191 |
178 void ResourceTracker::RemoveNPObjectVar(NPObjectVar* object_var) { | 192 void ResourceTracker::RemoveNPObjectVar(NPObjectVar* object_var) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 314 |
301 // static | 315 // static |
302 void ResourceTracker::ClearSingletonOverride() { | 316 void ResourceTracker::ClearSingletonOverride() { |
303 DCHECK(singleton_override_); | 317 DCHECK(singleton_override_); |
304 singleton_override_ = NULL; | 318 singleton_override_ = NULL; |
305 } | 319 } |
306 | 320 |
307 } // namespace ppapi | 321 } // namespace ppapi |
308 } // namespace webkit | 322 } // namespace webkit |
309 | 323 |
OLD | NEW |