Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: webkit/plugins/ppapi/resource_tracker.cc

Issue 7578001: Unify var tracking between webkit and the proxy. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/tracker_base.h" 16 #include "ppapi/shared_impl/tracker_base.h"
16 #include "webkit/plugins/ppapi/npobject_var.h" 17 #include "webkit/plugins/ppapi/npobject_var.h"
17 #include "webkit/plugins/ppapi/plugin_module.h" 18 #include "webkit/plugins/ppapi/plugin_module.h"
18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
19 #include "webkit/plugins/ppapi/ppb_char_set_impl.h" 20 #include "webkit/plugins/ppapi/ppb_char_set_impl.h"
20 #include "webkit/plugins/ppapi/ppb_cursor_control_impl.h" 21 #include "webkit/plugins/ppapi/ppb_cursor_control_impl.h"
21 #include "webkit/plugins/ppapi/ppb_find_impl.h" 22 #include "webkit/plugins/ppapi/ppb_find_impl.h"
22 #include "webkit/plugins/ppapi/ppb_font_impl.h" 23 #include "webkit/plugins/ppapi/ppb_font_impl.h"
23 #include "webkit/plugins/ppapi/resource.h" 24 #include "webkit/plugins/ppapi/resource.h"
24 #include "webkit/plugins/ppapi/resource_creation_impl.h" 25 #include "webkit/plugins/ppapi/resource_creation_impl.h"
25 26
27 using ppapi::CheckIdType;
28 using ppapi::MakeTypedId;
26 using ppapi::NPObjectVar; 29 using ppapi::NPObjectVar;
30 using ppapi::PPIdType;
27 using ppapi::Var; 31 using ppapi::Var;
28 32
29 enum PPIdType {
30 PP_ID_TYPE_MODULE,
31 PP_ID_TYPE_INSTANCE,
32 PP_ID_TYPE_RESOURCE,
33 PP_ID_TYPE_VAR,
34 PP_ID_TYPE_COUNT
35 };
36
37 static const unsigned int kPPIdTypeBits = 2;
38 COMPILE_ASSERT(PP_ID_TYPE_COUNT <= (1<<kPPIdTypeBits),
39 kPPIdTypeBits_is_too_small_for_all_id_types);
40
41 static const int32 kMaxPPIdType =
42 std::numeric_limits<int32>::max() >> kPPIdTypeBits;
43
44 template <typename T> static inline T MakeTypedId(T value, PPIdType type) {
45 return (value << kPPIdTypeBits) | static_cast<T>(type);
46 }
47
48 template <typename T> static inline bool CheckIdType(T id, PPIdType type) {
49 // 0 is a valid resource.
50 if (!id)
51 return true;
52 const T mask = (static_cast<T>(1) << kPPIdTypeBits) - 1;
53 return (id & mask) == type;
54 }
55
56 namespace webkit { 33 namespace webkit {
57 namespace ppapi { 34 namespace ppapi {
58 35
59 namespace { 36 namespace {
60 37
61 ::ppapi::TrackerBase* GetTrackerBase() { 38 ::ppapi::TrackerBase* GetTrackerBase() {
62 return ResourceTracker::Get(); 39 return ResourceTracker::Get();
63 } 40 }
64 41
65 } // namespace 42 } // namespace
(...skipping 16 matching lines...) Expand all
82 // instance goes away when there are still refs. These are non-owning 59 // instance goes away when there are still refs. These are non-owning
83 // references. 60 // references.
84 NPObjectToNPObjectVarMap np_object_to_object_var; 61 NPObjectToNPObjectVarMap np_object_to_object_var;
85 62
86 // Lazily allocated function proxies for the different interfaces. 63 // Lazily allocated function proxies for the different interfaces.
87 scoped_ptr< ::ppapi::FunctionGroupBase > 64 scoped_ptr< ::ppapi::FunctionGroupBase >
88 function_proxies[::pp::proxy::INTERFACE_ID_COUNT]; 65 function_proxies[::pp::proxy::INTERFACE_ID_COUNT];
89 }; 66 };
90 67
91 scoped_refptr<Resource> ResourceTracker::GetResource(PP_Resource res) const { 68 scoped_refptr<Resource> ResourceTracker::GetResource(PP_Resource res) const {
92 DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) 69 DLOG_IF(ERROR, !CheckIdType(res, ::ppapi::PP_ID_TYPE_RESOURCE))
93 << res << " is not a PP_Resource."; 70 << res << " is not a PP_Resource.";
94 ResourceMap::const_iterator result = live_resources_.find(res); 71 ResourceMap::const_iterator result = live_resources_.find(res);
95 if (result == live_resources_.end()) { 72 if (result == live_resources_.end()) {
96 return scoped_refptr<Resource>(); 73 return scoped_refptr<Resource>();
97 } 74 }
98 return result->second.first; 75 return result->second.first;
99 } 76 }
100 77
101 // static 78 // static
102 ResourceTracker* ResourceTracker::global_tracker_ = NULL; 79 ResourceTracker* ResourceTracker::global_tracker_ = NULL;
103 ResourceTracker* ResourceTracker::singleton_override_ = NULL; 80 ResourceTracker* ResourceTracker::singleton_override_ = NULL;
104 81
105 ResourceTracker::ResourceTracker() 82 ResourceTracker::ResourceTracker()
106 : last_resource_id_(0), 83 : last_resource_id_(0) {
107 last_var_id_(0) {
108 // Wire up the new shared resource tracker base to use our implementation. 84 // Wire up the new shared resource tracker base to use our implementation.
109 ::ppapi::TrackerBase::Init(&GetTrackerBase); 85 ::ppapi::TrackerBase::Init(&GetTrackerBase);
110 } 86 }
111 87
112 ResourceTracker::~ResourceTracker() { 88 ResourceTracker::~ResourceTracker() {
113 } 89 }
114 90
115 // static 91 // static
116 ResourceTracker* ResourceTracker::Get() { 92 ResourceTracker* ResourceTracker::Get() {
117 if (singleton_override_) 93 if (singleton_override_)
(...skipping 20 matching lines...) Expand all
138 PP_Instance pp_instance = resource->instance()->pp_instance(); 114 PP_Instance pp_instance = resource->instance()->pp_instance();
139 DCHECK(pp_instance); 115 DCHECK(pp_instance);
140 DCHECK(instance_map_.find(pp_instance) != instance_map_.end()); 116 DCHECK(instance_map_.find(pp_instance) != instance_map_.end());
141 117
142 instance_map_[pp_instance]->assoc_resources.erase(resource); 118 instance_map_[pp_instance]->assoc_resources.erase(resource);
143 } 119 }
144 120
145 PP_Resource ResourceTracker::AddResource(Resource* resource) { 121 PP_Resource ResourceTracker::AddResource(Resource* resource) {
146 // If the plugin manages to create 1 billion resources, don't do crazy stuff. 122 // If the plugin manages to create 1 billion resources, don't do crazy stuff.
147 if (last_resource_id_ == 123 if (last_resource_id_ ==
148 (std::numeric_limits<PP_Resource>::max() >> kPPIdTypeBits)) 124 (std::numeric_limits<PP_Resource>::max() >> ::ppapi::kPPIdTypeBits))
149 return 0; 125 return 0;
150 126
151 // Add the resource with plugin use-count 1. 127 // Add the resource with plugin use-count 1.
152 PP_Resource new_id = MakeTypedId(++last_resource_id_, PP_ID_TYPE_RESOURCE); 128 PP_Resource new_id = MakeTypedId(++last_resource_id_,
129 ::ppapi::PP_ID_TYPE_RESOURCE);
153 live_resources_.insert(std::make_pair(new_id, std::make_pair(resource, 1))); 130 live_resources_.insert(std::make_pair(new_id, std::make_pair(resource, 1)));
154 131
155 // Track associated with the instance. 132 // Track associated with the instance.
156 PP_Instance pp_instance = resource->instance()->pp_instance(); 133 PP_Instance pp_instance = resource->instance()->pp_instance();
157 DCHECK(instance_map_.find(pp_instance) != instance_map_.end()); 134 DCHECK(instance_map_.find(pp_instance) != instance_map_.end());
158 instance_map_[pp_instance]->ref_resources.insert(new_id); 135 instance_map_[pp_instance]->ref_resources.insert(new_id);
159 return new_id; 136 return new_id;
160 } 137 }
161 138
162 bool ResourceTracker::AddRefResource(PP_Resource res) { 139 bool ResourceTracker::AddRefResource(PP_Resource res) {
163 DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) 140 DLOG_IF(ERROR, !CheckIdType(res, ::ppapi::PP_ID_TYPE_RESOURCE))
164 << res << " is not a PP_Resource."; 141 << res << " is not a PP_Resource.";
165 ResourceMap::iterator i = live_resources_.find(res); 142 ResourceMap::iterator i = live_resources_.find(res);
166 if (i != live_resources_.end()) { 143 if (i != live_resources_.end()) {
167 // We don't protect against overflow, since a plugin as malicious as to ref 144 // We don't protect against overflow, since a plugin as malicious as to ref
168 // once per every byte in the address space could have just as well unrefed 145 // once per every byte in the address space could have just as well unrefed
169 // one time too many. 146 // one time too many.
170 ++i->second.second; 147 ++i->second.second;
171 return true; 148 return true;
172 } else { 149 } else {
173 return false; 150 return false;
174 } 151 }
175 } 152 }
176 153
177 bool ResourceTracker::UnrefResource(PP_Resource res) { 154 bool ResourceTracker::UnrefResource(PP_Resource res) {
178 DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) 155 DLOG_IF(ERROR, !CheckIdType(res, ::ppapi::PP_ID_TYPE_RESOURCE))
179 << res << " is not a PP_Resource."; 156 << res << " is not a PP_Resource.";
180 ResourceMap::iterator i = live_resources_.find(res); 157 ResourceMap::iterator i = live_resources_.find(res);
181 if (i != live_resources_.end()) { 158 if (i != live_resources_.end()) {
182 if (!--i->second.second) { 159 if (!--i->second.second) {
183 Resource* to_release = i->second.first; 160 Resource* to_release = i->second.first;
184 // LastPluginRefWasDeleted will clear the instance pointer, so save it 161 // LastPluginRefWasDeleted will clear the instance pointer, so save it
185 // first. 162 // first.
186 PP_Instance instance = to_release->instance()->pp_instance(); 163 PP_Instance instance = to_release->instance()->pp_instance();
187 to_release->LastPluginRefWasDeleted(); 164 to_release->LastPluginRefWasDeleted();
188 165
189 instance_map_[instance]->ref_resources.erase(res); 166 instance_map_[instance]->ref_resources.erase(res);
190 live_resources_.erase(i); 167 live_resources_.erase(i);
191 } 168 }
192 return true; 169 return true;
193 } else { 170 } else {
194 return false; 171 return false;
195 } 172 }
196 } 173 }
197 174
198 void ResourceTracker::CleanupInstanceData(PP_Instance instance, 175 void ResourceTracker::CleanupInstanceData(PP_Instance instance,
199 bool delete_instance) { 176 bool delete_instance) {
200 DLOG_IF(ERROR, !CheckIdType(instance, PP_ID_TYPE_INSTANCE)) 177 DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE))
201 << instance << " is not a PP_Instance."; 178 << instance << " is not a PP_Instance.";
202 InstanceMap::iterator found = instance_map_.find(instance); 179 InstanceMap::iterator found = instance_map_.find(instance);
203 if (found == instance_map_.end()) { 180 if (found == instance_map_.end()) {
204 NOTREACHED(); 181 NOTREACHED();
205 return; 182 return;
206 } 183 }
207 InstanceData& data = *found->second; 184 InstanceData& data = *found->second;
208 185
209 // Force release all plugin references to resources associated with the 186 // Force release all plugin references to resources associated with the
210 // deleted instance. 187 // deleted instance.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 PP_Instance instance) const { 240 PP_Instance instance) const {
264 InstanceMap::const_iterator found = instance_map_.find(instance); 241 InstanceMap::const_iterator found = instance_map_.find(instance);
265 if (found == instance_map_.end()) 242 if (found == instance_map_.end())
266 return 0; 243 return 0;
267 return static_cast<uint32>(found->second->ref_resources.size() + 244 return static_cast<uint32>(found->second->ref_resources.size() +
268 found->second->np_object_to_object_var.size()); 245 found->second->np_object_to_object_var.size());
269 } 246 }
270 247
271 ::ppapi::ResourceObjectBase* ResourceTracker::GetResourceAPI( 248 ::ppapi::ResourceObjectBase* ResourceTracker::GetResourceAPI(
272 PP_Resource res) { 249 PP_Resource res) {
273 DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) 250 DLOG_IF(ERROR, !CheckIdType(res, ::ppapi::PP_ID_TYPE_RESOURCE))
274 << res << " is not a PP_Resource."; 251 << res << " is not a PP_Resource.";
275 ResourceMap::const_iterator result = live_resources_.find(res); 252 ResourceMap::const_iterator result = live_resources_.find(res);
276 if (result == live_resources_.end()) 253 if (result == live_resources_.end())
277 return NULL; 254 return NULL;
278 return result->second.first.get(); 255 return result->second.first.get();
279 } 256 }
280 257
281 ::ppapi::FunctionGroupBase* ResourceTracker::GetFunctionAPI( 258 ::ppapi::FunctionGroupBase* ResourceTracker::GetFunctionAPI(
282 PP_Instance pp_instance, 259 PP_Instance pp_instance,
283 pp::proxy::InterfaceID id) { 260 pp::proxy::InterfaceID id) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 return proxy.get(); 297 return proxy.get();
321 } 298 }
322 299
323 PP_Instance ResourceTracker::GetInstanceForResource(PP_Resource pp_resource) { 300 PP_Instance ResourceTracker::GetInstanceForResource(PP_Resource pp_resource) {
324 scoped_refptr<Resource> resource(GetResource(pp_resource)); 301 scoped_refptr<Resource> resource(GetResource(pp_resource));
325 if (!resource.get()) 302 if (!resource.get())
326 return 0; 303 return 0;
327 return resource->instance()->pp_instance(); 304 return resource->instance()->pp_instance();
328 } 305 }
329 306
330 int32 ResourceTracker::AddVar(Var* var) { 307 ::ppapi::VarTracker* ResourceTracker::GetVarTracker() {
331 // If the plugin manages to create 1B strings... 308 return &var_tracker_;
332 if (last_var_id_ == kMaxPPIdType)
333 return 0;
334
335 // Validate the module.
336 if (!GetModule(var->pp_module()))
337 return 0;
338
339 // Add the resource with plugin use-count 1.
340 int32 new_id = MakeTypedId(++last_var_id_, PP_ID_TYPE_VAR);
341 live_vars_.insert(std::make_pair(new_id, std::make_pair(var, 1)));
342
343 return new_id;
344 }
345
346 scoped_refptr<Var> ResourceTracker::GetVar(int32 var_id) const {
347 DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR))
348 << var_id << " is not a PP_Var ID.";
349 VarMap::const_iterator result = live_vars_.find(var_id);
350 if (result == live_vars_.end())
351 return scoped_refptr<Var>();
352 return result->second.first;
353 }
354
355 bool ResourceTracker::AddRefVar(int32 var_id) {
356 DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR))
357 << var_id << " is not a PP_Var ID.";
358 VarMap::iterator i = live_vars_.find(var_id);
359 if (i != live_vars_.end()) {
360 // We don't protect against overflow, since a plugin as malicious as to ref
361 // once per every byte in the address space could have just as well unrefed
362 // one time too many.
363 ++i->second.second;
364 return true;
365 }
366 return false;
367 }
368
369 bool ResourceTracker::UnrefVar(int32 var_id) {
370 DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR))
371 << var_id << " is not a PP_Var ID.";
372 VarMap::iterator i = live_vars_.find(var_id);
373 if (i != live_vars_.end()) {
374 if (!--i->second.second)
375 live_vars_.erase(i);
376 return true;
377 }
378 return false;
379 } 309 }
380 310
381 void ResourceTracker::AddNPObjectVar(NPObjectVar* object_var) { 311 void ResourceTracker::AddNPObjectVar(NPObjectVar* object_var) {
382 DCHECK(instance_map_.find(object_var->pp_instance()) != instance_map_.end()); 312 DCHECK(instance_map_.find(object_var->pp_instance()) != instance_map_.end());
383 InstanceData& data = *instance_map_[object_var->pp_instance()].get(); 313 InstanceData& data = *instance_map_[object_var->pp_instance()].get();
384 314
385 DCHECK(data.np_object_to_object_var.find(object_var->np_object()) == 315 DCHECK(data.np_object_to_object_var.find(object_var->np_object()) ==
386 data.np_object_to_object_var.end()) << "NPObjectVar already in map"; 316 data.np_object_to_object_var.end()) << "NPObjectVar already in map";
387 data.np_object_to_object_var[object_var->np_object()] = object_var; 317 data.np_object_to_object_var[object_var->np_object()] = object_var;
388 } 318 }
(...skipping 30 matching lines...) Expand all
419 PP_Instance ResourceTracker::AddInstance(PluginInstance* instance) { 349 PP_Instance ResourceTracker::AddInstance(PluginInstance* instance) {
420 DCHECK(instance_map_.find(instance->pp_instance()) == instance_map_.end()); 350 DCHECK(instance_map_.find(instance->pp_instance()) == instance_map_.end());
421 351
422 // Use a random number for the instance ID. This helps prevent some 352 // Use a random number for the instance ID. This helps prevent some
423 // accidents. See also AddModule below. 353 // accidents. See also AddModule below.
424 // 354 //
425 // Need to make sure the random number isn't a duplicate or 0. 355 // Need to make sure the random number isn't a duplicate or 0.
426 PP_Instance new_instance; 356 PP_Instance new_instance;
427 do { 357 do {
428 new_instance = MakeTypedId(static_cast<PP_Instance>(base::RandUint64()), 358 new_instance = MakeTypedId(static_cast<PP_Instance>(base::RandUint64()),
429 PP_ID_TYPE_INSTANCE); 359 ::ppapi::PP_ID_TYPE_INSTANCE);
430 } while (!new_instance || 360 } while (!new_instance ||
431 instance_map_.find(new_instance) != instance_map_.end() || 361 instance_map_.find(new_instance) != instance_map_.end() ||
432 !instance->module()->ReserveInstanceID(new_instance)); 362 !instance->module()->ReserveInstanceID(new_instance));
433 363
434 instance_map_[new_instance] = linked_ptr<InstanceData>(new InstanceData); 364 instance_map_[new_instance] = linked_ptr<InstanceData>(new InstanceData);
435 instance_map_[new_instance]->instance = instance; 365 instance_map_[new_instance]->instance = instance;
436 return new_instance; 366 return new_instance;
437 } 367 }
438 368
439 void ResourceTracker::InstanceDeleted(PP_Instance instance) { 369 void ResourceTracker::InstanceDeleted(PP_Instance instance) {
440 CleanupInstanceData(instance, true); 370 CleanupInstanceData(instance, true);
441 } 371 }
442 372
443 void ResourceTracker::InstanceCrashed(PP_Instance instance) { 373 void ResourceTracker::InstanceCrashed(PP_Instance instance) {
444 CleanupInstanceData(instance, false); 374 CleanupInstanceData(instance, false);
445 } 375 }
446 376
447 PluginInstance* ResourceTracker::GetInstance(PP_Instance instance) { 377 PluginInstance* ResourceTracker::GetInstance(PP_Instance instance) {
448 DLOG_IF(ERROR, !CheckIdType(instance, PP_ID_TYPE_INSTANCE)) 378 DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE))
449 << instance << " is not a PP_Instance."; 379 << instance << " is not a PP_Instance.";
450 InstanceMap::iterator found = instance_map_.find(instance); 380 InstanceMap::iterator found = instance_map_.find(instance);
451 if (found == instance_map_.end()) 381 if (found == instance_map_.end())
452 return NULL; 382 return NULL;
453 return found->second->instance; 383 return found->second->instance;
454 } 384 }
455 385
456 PP_Module ResourceTracker::AddModule(PluginModule* module) { 386 PP_Module ResourceTracker::AddModule(PluginModule* module) {
457 #ifndef NDEBUG 387 #ifndef NDEBUG
458 // Make sure we're not adding one more than once. 388 // Make sure we're not adding one more than once.
459 for (ModuleMap::const_iterator i = module_map_.begin(); 389 for (ModuleMap::const_iterator i = module_map_.begin();
460 i != module_map_.end(); ++i) 390 i != module_map_.end(); ++i)
461 DCHECK(i->second != module); 391 DCHECK(i->second != module);
462 #endif 392 #endif
463 393
464 // See AddInstance above. 394 // See AddInstance above.
465 PP_Module new_module; 395 PP_Module new_module;
466 do { 396 do {
467 new_module = MakeTypedId(static_cast<PP_Module>(base::RandUint64()), 397 new_module = MakeTypedId(static_cast<PP_Module>(base::RandUint64()),
468 PP_ID_TYPE_MODULE); 398 ::ppapi::PP_ID_TYPE_MODULE);
469 } while (!new_module || 399 } while (!new_module ||
470 module_map_.find(new_module) != module_map_.end()); 400 module_map_.find(new_module) != module_map_.end());
471 module_map_[new_module] = module; 401 module_map_[new_module] = module;
472 return new_module; 402 return new_module;
473 } 403 }
474 404
475 void ResourceTracker::ModuleDeleted(PP_Module module) { 405 void ResourceTracker::ModuleDeleted(PP_Module module) {
476 DLOG_IF(ERROR, !CheckIdType(module, PP_ID_TYPE_MODULE)) 406 DLOG_IF(ERROR, !CheckIdType(module, ::ppapi::PP_ID_TYPE_MODULE))
477 << module << " is not a PP_Module."; 407 << module << " is not a PP_Module.";
478 ModuleMap::iterator found = module_map_.find(module); 408 ModuleMap::iterator found = module_map_.find(module);
479 if (found == module_map_.end()) { 409 if (found == module_map_.end()) {
480 NOTREACHED(); 410 NOTREACHED();
481 return; 411 return;
482 } 412 }
483 module_map_.erase(found); 413 module_map_.erase(found);
484 } 414 }
485 415
486 PluginModule* ResourceTracker::GetModule(PP_Module module) { 416 PluginModule* ResourceTracker::GetModule(PP_Module module) {
487 DLOG_IF(ERROR, !CheckIdType(module, PP_ID_TYPE_MODULE)) 417 DLOG_IF(ERROR, !CheckIdType(module, ::ppapi::PP_ID_TYPE_MODULE))
488 << module << " is not a PP_Module."; 418 << module << " is not a PP_Module.";
489 ModuleMap::iterator found = module_map_.find(module); 419 ModuleMap::iterator found = module_map_.find(module);
490 if (found == module_map_.end()) 420 if (found == module_map_.end())
491 return NULL; 421 return NULL;
492 return found->second; 422 return found->second;
493 } 423 }
494 424
495 // static 425 // static
496 void ResourceTracker::SetSingletonOverride(ResourceTracker* tracker) { 426 void ResourceTracker::SetSingletonOverride(ResourceTracker* tracker) {
497 DCHECK(!singleton_override_); 427 DCHECK(!singleton_override_);
498 singleton_override_ = tracker; 428 singleton_override_ = tracker;
499 } 429 }
500 430
501 // static 431 // static
502 void ResourceTracker::ClearSingletonOverride() { 432 void ResourceTracker::ClearSingletonOverride() {
503 DCHECK(singleton_override_); 433 DCHECK(singleton_override_);
504 singleton_override_ = NULL; 434 singleton_override_ = NULL;
505 } 435 }
506 436
507 } // namespace ppapi 437 } // namespace ppapi
508 } // namespace webkit 438 } // namespace webkit
509 439
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/resource_tracker.h ('k') | webkit/plugins/ppapi/resource_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698