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 "content/child/npapi/plugin_lib.h" | 5 #include "content/child/npapi/plugin_lib.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/thread_task_runner_handle.h" |
11 #include "content/child/npapi/plugin_host.h" | 13 #include "content/child/npapi/plugin_host.h" |
12 #include "content/child/npapi/plugin_instance.h" | 14 #include "content/child/npapi/plugin_instance.h" |
13 #include "content/common/plugin_list.h" | 15 #include "content/common/plugin_list.h" |
14 | 16 |
15 namespace content { | 17 namespace content { |
16 | 18 |
17 // A list of all the instantiated plugins. | 19 // A list of all the instantiated plugins. |
18 static std::vector<scoped_refptr<PluginLib> >* g_loaded_libs; | 20 static std::vector<scoped_refptr<PluginLib> >* g_loaded_libs; |
19 | 21 |
20 PluginLib* PluginLib::CreatePluginLib(const base::FilePath& filename) { | 22 PluginLib* PluginLib::CreatePluginLib(const base::FilePath& filename) { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // The plugin NPAPI instances may still be around. Delay the | 284 // The plugin NPAPI instances may still be around. Delay the |
283 // NP_Shutdown and FreeLibrary calls at least till the next | 285 // NP_Shutdown and FreeLibrary calls at least till the next |
284 // peek message. | 286 // peek message. |
285 defer_unload = true; | 287 defer_unload = true; |
286 #endif | 288 #endif |
287 */ | 289 */ |
288 if (!defer_unload_) { | 290 if (!defer_unload_) { |
289 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 291 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
290 << "Scheduling delayed unload for plugin " | 292 << "Scheduling delayed unload for plugin " |
291 << web_plugin_info_.path.value(); | 293 << web_plugin_info_.path.value(); |
292 base::MessageLoop::current()->PostTask( | 294 base::ThreadTaskRunnerHandle::Get()->PostTask( |
293 FROM_HERE, | 295 FROM_HERE, base::Bind(&FreePluginLibraryHelper, web_plugin_info_.path, |
294 base::Bind(&FreePluginLibraryHelper, | 296 skip_unload_ ? NULL : library_, |
295 web_plugin_info_.path, | 297 entry_points_.np_shutdown)); |
296 skip_unload_ ? NULL : library_, | |
297 entry_points_.np_shutdown)); | |
298 } else { | 298 } else { |
299 Shutdown(); | 299 Shutdown(); |
300 if (!skip_unload_) { | 300 if (!skip_unload_) { |
301 LOG_IF(ERROR, PluginList::DebugPluginLoading()) | 301 LOG_IF(ERROR, PluginList::DebugPluginLoading()) |
302 << "Unloading plugin " << web_plugin_info_.path.value(); | 302 << "Unloading plugin " << web_plugin_info_.path.value(); |
303 base::UnloadNativeLibrary(library_); | 303 base::UnloadNativeLibrary(library_); |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 library_ = NULL; | 307 library_ = NULL; |
(...skipping 12 matching lines...) Expand all Loading... |
320 } | 320 } |
321 | 321 |
322 void PluginLib::Shutdown() { | 322 void PluginLib::Shutdown() { |
323 if (initialized_) { | 323 if (initialized_) { |
324 NP_Shutdown(); | 324 NP_Shutdown(); |
325 initialized_ = false; | 325 initialized_ = false; |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 } // namespace content | 329 } // namespace content |
OLD | NEW |