| 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/npapi/plugin_lib.h" | 5 #include "webkit/plugins/npapi/plugin_lib.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/metrics/stats_counters.h" | 9 #include "base/metrics/stats_counters.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // instance function calls (i.e. NP_Initialize and NP_Shutdown). So we keep | 27 // instance function calls (i.e. NP_Initialize and NP_Shutdown). So we keep |
| 28 // a map of PluginLib objects. | 28 // a map of PluginLib objects. |
| 29 if (!g_loaded_libs) | 29 if (!g_loaded_libs) |
| 30 g_loaded_libs = new std::vector<scoped_refptr<PluginLib> >; | 30 g_loaded_libs = new std::vector<scoped_refptr<PluginLib> >; |
| 31 | 31 |
| 32 for (size_t i = 0; i < g_loaded_libs->size(); ++i) { | 32 for (size_t i = 0; i < g_loaded_libs->size(); ++i) { |
| 33 if ((*g_loaded_libs)[i]->plugin_info().path == filename) | 33 if ((*g_loaded_libs)[i]->plugin_info().path == filename) |
| 34 return (*g_loaded_libs)[i]; | 34 return (*g_loaded_libs)[i]; |
| 35 } | 35 } |
| 36 | 36 |
| 37 WebPluginInfo info; | 37 webkit::WebPluginInfo info; |
| 38 const PluginEntryPoints* entry_points = NULL; | 38 const PluginEntryPoints* entry_points = NULL; |
| 39 if (!PluginList::Singleton()->ReadPluginInfo(filename, &info, &entry_points)) | 39 if (!PluginList::Singleton()->ReadPluginInfo(filename, &info, &entry_points)) |
| 40 return NULL; | 40 return NULL; |
| 41 | 41 |
| 42 return new PluginLib(info, entry_points); | 42 return new PluginLib(info, entry_points); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void PluginLib::UnloadAllPlugins() { | 45 void PluginLib::UnloadAllPlugins() { |
| 46 if (g_loaded_libs) { | 46 if (g_loaded_libs) { |
| 47 // PluginLib::Unload() can remove items from the list and even delete | 47 // PluginLib::Unload() can remove items from the list and even delete |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 void PluginLib::ShutdownAllPlugins() { | 61 void PluginLib::ShutdownAllPlugins() { |
| 62 if (g_loaded_libs) { | 62 if (g_loaded_libs) { |
| 63 for (size_t i = 0; i < g_loaded_libs->size(); ++i) | 63 for (size_t i = 0; i < g_loaded_libs->size(); ++i) |
| 64 (*g_loaded_libs)[i]->Shutdown(); | 64 (*g_loaded_libs)[i]->Shutdown(); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 PluginLib::PluginLib(const WebPluginInfo& info, | 68 PluginLib::PluginLib(const webkit::WebPluginInfo& info, |
| 69 const PluginEntryPoints* entry_points) | 69 const PluginEntryPoints* entry_points) |
| 70 : web_plugin_info_(info), | 70 : web_plugin_info_(info), |
| 71 library_(NULL), | 71 library_(NULL), |
| 72 initialized_(false), | 72 initialized_(false), |
| 73 saved_data_(0), | 73 saved_data_(0), |
| 74 instance_count_(0), | 74 instance_count_(0), |
| 75 skip_unload_(false), | 75 skip_unload_(false), |
| 76 defer_unload_(false) { | 76 defer_unload_(false) { |
| 77 base::StatsCounter(kPluginLibrariesLoadedCounter).Increment(); | 77 base::StatsCounter(kPluginLibrariesLoadedCounter).Increment(); |
| 78 memset(static_cast<void*>(&plugin_funcs_), 0, sizeof(plugin_funcs_)); | 78 memset(static_cast<void*>(&plugin_funcs_), 0, sizeof(plugin_funcs_)); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 359 |
| 360 void PluginLib::Shutdown() { | 360 void PluginLib::Shutdown() { |
| 361 if (initialized_ && !internal_) { | 361 if (initialized_ && !internal_) { |
| 362 NP_Shutdown(); | 362 NP_Shutdown(); |
| 363 initialized_ = false; | 363 initialized_ = false; |
| 364 } | 364 } |
| 365 } | 365 } |
| 366 | 366 |
| 367 } // namespace npapi | 367 } // namespace npapi |
| 368 } // namespace webkit | 368 } // namespace webkit |
| OLD | NEW |