| 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/common/pepper_plugin_registry.h" | 5 #include "content/common/pepper_plugin_registry.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/native_library.h" | 8 #include "base/native_library.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 // Modules aren't destroyed very often and there are normally at most a | 178 // Modules aren't destroyed very often and there are normally at most a |
| 179 // couple of them. So for now we just do a brute-force search. | 179 // couple of them. So for now we just do a brute-force search. |
| 180 for (NonOwningModuleMap::iterator i = live_modules_.begin(); | 180 for (NonOwningModuleMap::iterator i = live_modules_.begin(); |
| 181 i != live_modules_.end(); ++i) { | 181 i != live_modules_.end(); ++i) { |
| 182 if (i->second == dead_module) { | 182 if (i->second == dead_module) { |
| 183 live_modules_.erase(i); | 183 live_modules_.erase(i); |
| 184 return; | 184 return; |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 NOTREACHED(); // Should have always found the module above. | 187 // Can occur in tests. |
| 188 } | 188 } |
| 189 | 189 |
| 190 PepperPluginRegistry::~PepperPluginRegistry() { | 190 PepperPluginRegistry::~PepperPluginRegistry() { |
| 191 // Explicitly clear all preloaded modules first. This will cause callbacks | 191 // Explicitly clear all preloaded modules first. This will cause callbacks |
| 192 // to erase these modules from the live_modules_ list, and we don't want | 192 // to erase these modules from the live_modules_ list, and we don't want |
| 193 // that to happen implicitly out-of-order. | 193 // that to happen implicitly out-of-order. |
| 194 preloaded_modules_.clear(); | 194 preloaded_modules_.clear(); |
| 195 | 195 |
| 196 DCHECK(live_modules_.empty()); | 196 DCHECK(live_modules_.empty()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 PepperPluginRegistry::PepperPluginRegistry() { | 199 PepperPluginRegistry::PepperPluginRegistry() { |
| 200 ComputeList(&plugin_list_); | 200 ComputeList(&plugin_list_); |
| 201 | 201 |
| 202 // Note that in each case, AddLiveModule must be called before completing | 202 // Note that in each case, AddLiveModule must be called before completing |
| 203 // initialization. If we bail out (in the continue clauses) before saving | 203 // initialization. If we bail out (in the continue clauses) before saving |
| 204 // the initialized module, it will still try to unregister itself in its | 204 // the initialized module, it will still try to unregister itself in its |
| 205 // destructor. | 205 // destructor. |
| 206 for (size_t i = 0; i < plugin_list_.size(); i++) { | 206 for (size_t i = 0; i < plugin_list_.size(); i++) { |
| 207 const PepperPluginInfo& current = plugin_list_[i]; | 207 const PepperPluginInfo& current = plugin_list_[i]; |
| 208 if (current.is_out_of_process) | 208 if (current.is_out_of_process) |
| 209 continue; // Out of process plugins need no special pre-initialization. | 209 continue; // Out of process plugins need no special pre-initialization. |
| 210 | 210 |
| 211 scoped_refptr<webkit::ppapi::PluginModule> module = | 211 scoped_refptr<webkit::ppapi::PluginModule> module = |
| 212 new webkit::ppapi::PluginModule(current.name, current.path, this, | 212 new webkit::ppapi::PluginModule(current.name, current.path, |
| 213 ppapi::PpapiPermissions(current.permissions)); | 213 ppapi::PpapiPermissions(current.permissions)); |
| 214 AddLiveModule(current.path, module.get()); | 214 AddLiveModule(current.path, module.get()); |
| 215 if (current.is_internal) { | 215 if (current.is_internal) { |
| 216 if (!module->InitAsInternalPlugin(current.internal_entry_points)) { | 216 if (!module->InitAsInternalPlugin(current.internal_entry_points)) { |
| 217 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value(); | 217 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value(); |
| 218 continue; | 218 continue; |
| 219 } | 219 } |
| 220 } else { | 220 } else { |
| 221 // Preload all external plugins we're not running out of process. | 221 // Preload all external plugins we're not running out of process. |
| 222 if (!module->InitAsLibrary(current.path)) { | 222 if (!module->InitAsLibrary(current.path)) { |
| 223 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value(); | 223 DLOG(ERROR) << "Failed to load pepper module: " << current.path.value(); |
| 224 continue; | 224 continue; |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 preloaded_modules_[current.path] = module; | 227 preloaded_modules_[current.path] = module; |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace content | 231 } // namespace content |
| OLD | NEW |