| 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/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.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "content/common/child_process_host_impl.h" | 11 #include "content/common/child_process_host_impl.h" |
| 12 #include "content/common/utility_messages.h" | 12 #include "content/common/utility_messages.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "webkit/plugins/npapi/plugin_list.h" | 14 #include "webkit/plugins/npapi/plugin_list.h" |
| 15 | 15 |
| 16 using content::BrowserThread; | 16 using content::BrowserThread; |
| 17 using content::ChildProcessHost; | 17 using content::ChildProcessHost; |
| 18 | 18 |
| 19 PluginLoaderPosix::PluginLoaderPosix() | 19 PluginLoaderPosix::PluginLoaderPosix() |
| 20 : process_host_(NULL), | 20 : process_host_(NULL), |
| 21 next_load_index_(0) { | 21 next_load_index_(0) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 void PluginLoaderPosix::LoadPlugins( | 24 void PluginLoaderPosix::LoadPlugins( |
| 25 scoped_refptr<base::MessageLoopProxy> target_loop, | 25 scoped_refptr<base::MessageLoopProxy> target_loop, |
| 26 const PluginService::GetPluginsCallback& callback) { | 26 const content::PluginService::GetPluginsCallback& callback) { |
| 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 28 | 28 |
| 29 callbacks_.push_back(PendingCallback(target_loop, callback)); | 29 callbacks_.push_back(PendingCallback(target_loop, callback)); |
| 30 | 30 |
| 31 if (callbacks_.size() == 1) { | 31 if (callbacks_.size() == 1) { |
| 32 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 32 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 33 base::Bind(&PluginLoaderPosix::GetPluginsToLoad, this)); | 33 base::Bind(&PluginLoaderPosix::GetPluginsToLoad, this)); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 61 | 61 |
| 62 void PluginLoaderPosix::GetPluginsToLoad() { | 62 void PluginLoaderPosix::GetPluginsToLoad() { |
| 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 64 | 64 |
| 65 base::TimeTicks start_time(base::TimeTicks::Now()); | 65 base::TimeTicks start_time(base::TimeTicks::Now()); |
| 66 | 66 |
| 67 loaded_plugins_.clear(); | 67 loaded_plugins_.clear(); |
| 68 next_load_index_ = 0; | 68 next_load_index_ = 0; |
| 69 | 69 |
| 70 canonical_list_.clear(); | 70 canonical_list_.clear(); |
| 71 PluginService::GetInstance()->GetPluginList()->GetPluginPathsToLoad( | 71 PluginServiceImpl::GetInstance()->GetPluginList()->GetPluginPathsToLoad( |
| 72 &canonical_list_); | 72 &canonical_list_); |
| 73 | 73 |
| 74 internal_plugins_.clear(); | 74 internal_plugins_.clear(); |
| 75 PluginService::GetInstance()->GetPluginList()->GetInternalPlugins( | 75 PluginServiceImpl::GetInstance()->GetPluginList()->GetInternalPlugins( |
| 76 &internal_plugins_); | 76 &internal_plugins_); |
| 77 | 77 |
| 78 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 78 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 79 base::Bind(&PluginLoaderPosix::LoadPluginsInternal, | 79 base::Bind(&PluginLoaderPosix::LoadPluginsInternal, |
| 80 make_scoped_refptr(this))); | 80 make_scoped_refptr(this))); |
| 81 | 81 |
| 82 HISTOGRAM_TIMES("PluginLoaderPosix.GetPluginList", | 82 HISTOGRAM_TIMES("PluginLoaderPosix.GetPluginList", |
| 83 (base::TimeTicks::Now() - start_time) * | 83 (base::TimeTicks::Now() - start_time) * |
| 84 base::Time::kMicrosecondsPerMillisecond); | 84 base::Time::kMicrosecondsPerMillisecond); |
| 85 } | 85 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool PluginLoaderPosix::MaybeRunPendingCallbacks() { | 151 bool PluginLoaderPosix::MaybeRunPendingCallbacks() { |
| 152 if (next_load_index_ < canonical_list_.size()) | 152 if (next_load_index_ < canonical_list_.size()) |
| 153 return false; | 153 return false; |
| 154 | 154 |
| 155 PluginService::GetInstance()->GetPluginList()->SetPlugins(loaded_plugins_); | 155 PluginServiceImpl::GetInstance()->GetPluginList()->SetPlugins( |
| 156 loaded_plugins_); |
| 156 for (std::vector<PendingCallback>::iterator it = callbacks_.begin(); | 157 for (std::vector<PendingCallback>::iterator it = callbacks_.begin(); |
| 157 it != callbacks_.end(); | 158 it != callbacks_.end(); |
| 158 ++it) { | 159 ++it) { |
| 159 it->target_loop->PostTask(FROM_HERE, | 160 it->target_loop->PostTask(FROM_HERE, |
| 160 base::Bind(it->callback, loaded_plugins_)); | 161 base::Bind(it->callback, loaded_plugins_)); |
| 161 } | 162 } |
| 162 callbacks_.clear(); | 163 callbacks_.clear(); |
| 163 | 164 |
| 164 HISTOGRAM_TIMES("PluginLoaderPosix.LoadDone", | 165 HISTOGRAM_TIMES("PluginLoaderPosix.LoadDone", |
| 165 (base::TimeTicks::Now() - load_start_time_) | 166 (base::TimeTicks::Now() - load_start_time_) |
| 166 * base::Time::kMicrosecondsPerMillisecond); | 167 * base::Time::kMicrosecondsPerMillisecond); |
| 167 load_start_time_ = base::TimeTicks(); | 168 load_start_time_ = base::TimeTicks(); |
| 168 | 169 |
| 169 return true; | 170 return true; |
| 170 } | 171 } |
| 171 | 172 |
| 172 PluginLoaderPosix::PendingCallback::PendingCallback( | 173 PluginLoaderPosix::PendingCallback::PendingCallback( |
| 173 scoped_refptr<base::MessageLoopProxy> loop, | 174 scoped_refptr<base::MessageLoopProxy> loop, |
| 174 const PluginService::GetPluginsCallback& cb) | 175 const content::PluginService::GetPluginsCallback& cb) |
| 175 : target_loop(loop), | 176 : target_loop(loop), |
| 176 callback(cb) { | 177 callback(cb) { |
| 177 } | 178 } |
| 178 | 179 |
| 179 PluginLoaderPosix::PendingCallback::~PendingCallback() { | 180 PluginLoaderPosix::PendingCallback::~PendingCallback() { |
| 180 } | 181 } |
| OLD | NEW |