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 #include "content/renderer/pepper/pepper_plugin_registry.h" | 5 #include "content/renderer/pepper/pepper_plugin_registry.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/common/pepper_plugin_list.h" | 8 #include "content/common/pepper_plugin_list.h" |
9 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | |
9 #include "content/renderer/pepper/plugin_module.h" | 10 #include "content/renderer/pepper/plugin_module.h" |
10 #include "ppapi/shared_impl/ppapi_permissions.h" | 11 #include "ppapi/shared_impl/ppapi_permissions.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 // static | 15 // static |
15 PepperPluginRegistry* PepperPluginRegistry::GetInstance() { | 16 PepperPluginRegistry* PepperPluginRegistry::GetInstance() { |
16 static PepperPluginRegistry* registry = NULL; | 17 static PepperPluginRegistry* registry = NULL; |
17 // This object leaks. It is a temporary hack to work around a crash. | 18 // This object leaks. It is a temporary hack to work around a crash. |
18 // http://code.google.com/p/chromium/issues/detail?id=63234 | 19 // http://code.google.com/p/chromium/issues/detail?id=63234 |
(...skipping 18 matching lines...) Expand all Loading... | |
37 PepperPluginInfo plugin; | 38 PepperPluginInfo plugin; |
38 if (!MakePepperPluginInfo(info, &plugin)) | 39 if (!MakePepperPluginInfo(info, &plugin)) |
39 return NULL; | 40 return NULL; |
40 | 41 |
41 plugin_list_.push_back(plugin); | 42 plugin_list_.push_back(plugin); |
42 return &plugin_list_[plugin_list_.size() - 1]; | 43 return &plugin_list_[plugin_list_.size() - 1]; |
43 } | 44 } |
44 | 45 |
45 PluginModule* PepperPluginRegistry::GetLiveModule(const base::FilePath& path) { | 46 PluginModule* PepperPluginRegistry::GetLiveModule(const base::FilePath& path) { |
46 NonOwningModuleMap::iterator it = live_modules_.find(path); | 47 NonOwningModuleMap::iterator it = live_modules_.find(path); |
47 if (it == live_modules_.end()) | 48 if (it == live_modules_.end()) |
dmichael (off chromium)
2013/11/11 23:41:36
I think "it" and "jt" are too similar.
Maybe:
it->
| |
48 return NULL; | 49 return NULL; |
49 return it->second; | 50 |
51 // Check the instances for the module to see if they've all been Delete()d. | |
52 // We don't want to return a PluginModule in that case, since the plugin may | |
53 // have exited already. | |
54 const PluginModule::PluginInstanceSet& instance_set = | |
55 it->second->GetAllInstances(); | |
56 // If instance_set is empty, InstanceCreated() hasn't been called yet, so | |
57 // it's safe to return the PluginModule. | |
58 if (instance_set.size() == 0) | |
59 return it->second; | |
60 | |
61 PluginModule::PluginInstanceSet::const_iterator jt = instance_set.begin(); | |
62 while (jt != instance_set.end()) { | |
63 if (!(*jt)->is_deleted()) | |
64 return it->second; | |
65 ++jt; | |
66 } | |
67 return NULL; | |
50 } | 68 } |
51 | 69 |
52 void PepperPluginRegistry::AddLiveModule(const base::FilePath& path, | 70 void PepperPluginRegistry::AddLiveModule(const base::FilePath& path, |
53 PluginModule* module) { | 71 PluginModule* module) { |
54 DCHECK(live_modules_.find(path) == live_modules_.end()); | 72 DCHECK(live_modules_.find(path) == live_modules_.end()); |
55 live_modules_[path] = module; | 73 live_modules_[path] = module; |
56 } | 74 } |
57 | 75 |
58 void PepperPluginRegistry::PluginModuleDead(PluginModule* dead_module) { | 76 void PepperPluginRegistry::PluginModuleDead(PluginModule* dead_module) { |
59 // DANGER: Don't dereference the dead_module pointer! It may be in the | 77 // DANGER: Don't dereference the dead_module pointer! It may be in the |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 if (!module->InitAsLibrary(current.path)) { | 127 if (!module->InitAsLibrary(current.path)) { |
110 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value(); | 128 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value(); |
111 continue; | 129 continue; |
112 } | 130 } |
113 } | 131 } |
114 preloaded_modules_[current.path] = module; | 132 preloaded_modules_[current.path] = module; |
115 } | 133 } |
116 } | 134 } |
117 | 135 |
118 } // namespace content | 136 } // namespace content |
OLD | NEW |