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/browser/plugin_loader_posix.h" | 5 #include "content/browser/plugin_loader_posix.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/location.h" |
9 #include "base/message_loop/message_loop_proxy.h" | |
10 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" |
11 #include "content/browser/utility_process_host_impl.h" | 12 #include "content/browser/utility_process_host_impl.h" |
12 #include "content/common/child_process_host_impl.h" | 13 #include "content/common/child_process_host_impl.h" |
13 #include "content/common/plugin_list.h" | 14 #include "content/common/plugin_list.h" |
14 #include "content/common/utility_messages.h" | 15 #include "content/common/utility_messages.h" |
15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/plugin_service.h" | 17 #include "content/public/browser/plugin_service.h" |
17 #include "content/public/browser/user_metrics.h" | 18 #include "content/public/browser/user_metrics.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 PluginLoaderPosix::PluginLoaderPosix() | 22 PluginLoaderPosix::PluginLoaderPosix() |
22 : next_load_index_(0), loading_plugins_(false) { | 23 : next_load_index_(0), loading_plugins_(false) { |
23 } | 24 } |
24 | 25 |
25 void PluginLoaderPosix::GetPlugins( | 26 void PluginLoaderPosix::GetPlugins( |
26 const PluginService::GetPluginsCallback& callback) { | 27 const PluginService::GetPluginsCallback& callback) { |
27 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 28 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
28 | 29 |
29 std::vector<WebPluginInfo> cached_plugins; | 30 std::vector<WebPluginInfo> cached_plugins; |
30 if (PluginList::Singleton()->GetPluginsNoRefresh(&cached_plugins)) { | 31 if (PluginList::Singleton()->GetPluginsNoRefresh(&cached_plugins)) { |
31 // Can't assume the caller is reentrant. | 32 // Can't assume the caller is reentrant. |
32 base::MessageLoop::current()->PostTask(FROM_HERE, | 33 base::ThreadTaskRunnerHandle::Get()->PostTask( |
33 base::Bind(callback, cached_plugins)); | 34 FROM_HERE, base::Bind(callback, cached_plugins)); |
34 return; | 35 return; |
35 } | 36 } |
36 | 37 |
37 if (!loading_plugins_) { | 38 if (!loading_plugins_) { |
38 loading_plugins_ = true; | 39 loading_plugins_ = true; |
39 callbacks_.push_back(callback); | 40 callbacks_.push_back(callback); |
40 | 41 |
41 // When |loading_plugins_| is set to false, this instance must call | 42 // When |loading_plugins_| is set to false, this instance must call |
42 // SetPlugins(). | 43 // SetPlugins(). |
43 PluginList::Singleton()->PrepareForPluginLoading(); | 44 PluginList::Singleton()->PrepareForPluginLoading(); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 220 |
220 DCHECK(next_load_index_ <= canonical_list_.size()); | 221 DCHECK(next_load_index_ <= canonical_list_.size()); |
221 return next_load_index_ == canonical_list_.size(); | 222 return next_load_index_ == canonical_list_.size(); |
222 } | 223 } |
223 | 224 |
224 void PluginLoaderPosix::FinishedLoadingPlugins() { | 225 void PluginLoaderPosix::FinishedLoadingPlugins() { |
225 loading_plugins_ = false; | 226 loading_plugins_ = false; |
226 PluginList::Singleton()->SetPlugins(loaded_plugins_); | 227 PluginList::Singleton()->SetPlugins(loaded_plugins_); |
227 | 228 |
228 for (auto& callback : callbacks_) { | 229 for (auto& callback : callbacks_) { |
229 base::MessageLoop::current()->PostTask( | 230 base::ThreadTaskRunnerHandle::Get()->PostTask( |
230 FROM_HERE, base::Bind(callback, loaded_plugins_)); | 231 FROM_HERE, base::Bind(callback, loaded_plugins_)); |
231 } | 232 } |
232 callbacks_.clear(); | 233 callbacks_.clear(); |
233 } | 234 } |
234 | 235 |
235 bool PluginLoaderPosix::LaunchUtilityProcess() { | 236 bool PluginLoaderPosix::LaunchUtilityProcess() { |
236 return process_host_->Send(new UtilityMsg_LoadPlugins(canonical_list_)); | 237 return process_host_->Send(new UtilityMsg_LoadPlugins(canonical_list_)); |
237 } | 238 } |
238 | 239 |
239 } // namespace content | 240 } // namespace content |
OLD | NEW |