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/message_loop/message_loop.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "content/browser/utility_process_host_impl.h" | 11 #include "content/browser/utility_process_host_impl.h" |
12 #include "content/common/child_process_host_impl.h" | 12 #include "content/common/child_process_host_impl.h" |
| 13 #include "content/common/plugin_list.h" |
13 #include "content/common/utility_messages.h" | 14 #include "content/common/utility_messages.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 #include "webkit/plugins/npapi/plugin_list.h" | |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 PluginLoaderPosix::PluginLoaderPosix() | 19 PluginLoaderPosix::PluginLoaderPosix() |
20 : next_load_index_(0) { | 20 : next_load_index_(0) { |
21 } | 21 } |
22 | 22 |
23 void PluginLoaderPosix::LoadPlugins( | 23 void PluginLoaderPosix::LoadPlugins( |
24 scoped_refptr<base::MessageLoopProxy> target_loop, | 24 scoped_refptr<base::MessageLoopProxy> target_loop, |
25 const PluginService::GetPluginsCallback& callback) { | 25 const PluginService::GetPluginsCallback& callback) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 void PluginLoaderPosix::GetPluginsToLoad() { | 69 void PluginLoaderPosix::GetPluginsToLoad() { |
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
71 | 71 |
72 base::TimeTicks start_time(base::TimeTicks::Now()); | 72 base::TimeTicks start_time(base::TimeTicks::Now()); |
73 | 73 |
74 loaded_plugins_.clear(); | 74 loaded_plugins_.clear(); |
75 next_load_index_ = 0; | 75 next_load_index_ = 0; |
76 | 76 |
77 canonical_list_.clear(); | 77 canonical_list_.clear(); |
78 webkit::npapi::PluginList::Singleton()->GetPluginPathsToLoad( | 78 PluginList::Singleton()->GetPluginPathsToLoad(&canonical_list_); |
79 &canonical_list_); | |
80 | 79 |
81 internal_plugins_.clear(); | 80 internal_plugins_.clear(); |
82 webkit::npapi::PluginList::Singleton()->GetInternalPlugins( | 81 PluginList::Singleton()->GetInternalPlugins(&internal_plugins_); |
83 &internal_plugins_); | |
84 | 82 |
85 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 83 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
86 base::Bind(&PluginLoaderPosix::LoadPluginsInternal, | 84 base::Bind(&PluginLoaderPosix::LoadPluginsInternal, |
87 make_scoped_refptr(this))); | 85 make_scoped_refptr(this))); |
88 | 86 |
89 HISTOGRAM_TIMES("PluginLoaderPosix.GetPluginList", | 87 HISTOGRAM_TIMES("PluginLoaderPosix.GetPluginList", |
90 (base::TimeTicks::Now() - start_time) * | 88 (base::TimeTicks::Now() - start_time) * |
91 base::Time::kMicrosecondsPerMillisecond); | 89 base::Time::kMicrosecondsPerMillisecond); |
92 } | 90 } |
93 | 91 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return true; | 154 return true; |
157 } | 155 } |
158 } | 156 } |
159 return false; | 157 return false; |
160 } | 158 } |
161 | 159 |
162 bool PluginLoaderPosix::MaybeRunPendingCallbacks() { | 160 bool PluginLoaderPosix::MaybeRunPendingCallbacks() { |
163 if (next_load_index_ < canonical_list_.size()) | 161 if (next_load_index_ < canonical_list_.size()) |
164 return false; | 162 return false; |
165 | 163 |
166 webkit::npapi::PluginList::Singleton()->SetPlugins(loaded_plugins_); | 164 PluginList::Singleton()->SetPlugins(loaded_plugins_); |
167 | 165 |
168 // Only call the first callback with loaded plugins because there may be | 166 // Only call the first callback with loaded plugins because there may be |
169 // some extra plugin paths added since the first callback is added. | 167 // some extra plugin paths added since the first callback is added. |
170 if (!callbacks_.empty()) { | 168 if (!callbacks_.empty()) { |
171 PendingCallback callback = callbacks_.front(); | 169 PendingCallback callback = callbacks_.front(); |
172 callbacks_.pop_front(); | 170 callbacks_.pop_front(); |
173 callback.target_loop->PostTask( | 171 callback.target_loop->PostTask( |
174 FROM_HERE, | 172 FROM_HERE, |
175 base::Bind(callback.callback, loaded_plugins_)); | 173 base::Bind(callback.callback, loaded_plugins_)); |
176 } | 174 } |
(...skipping 15 matching lines...) Expand all Loading... |
192 scoped_refptr<base::MessageLoopProxy> loop, | 190 scoped_refptr<base::MessageLoopProxy> loop, |
193 const PluginService::GetPluginsCallback& cb) | 191 const PluginService::GetPluginsCallback& cb) |
194 : target_loop(loop), | 192 : target_loop(loop), |
195 callback(cb) { | 193 callback(cb) { |
196 } | 194 } |
197 | 195 |
198 PluginLoaderPosix::PendingCallback::~PendingCallback() { | 196 PluginLoaderPosix::PendingCallback::~PendingCallback() { |
199 } | 197 } |
200 | 198 |
201 } // namespace content | 199 } // namespace content |
OLD | NEW |