Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: content/browser/plugin_loader_posix.cc

Issue 8493019: Refactor PluginService to take PluginList as a dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/utility_messages.h" 11 #include "content/common/utility_messages.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "webkit/plugins/npapi/plugin_list.h" 13 #include "webkit/plugins/npapi/plugin_list.h"
14 14
15 using content::BrowserThread; 15 using content::BrowserThread;
16 using webkit::npapi::PluginList;
17 16
18 PluginLoaderPosix::PluginLoaderPosix() 17 PluginLoaderPosix::PluginLoaderPosix()
19 : next_load_index_(0) { 18 : next_load_index_(0) {
20 } 19 }
21 20
22 void PluginLoaderPosix::LoadPlugins( 21 void PluginLoaderPosix::LoadPlugins(
23 scoped_refptr<base::MessageLoopProxy> target_loop, 22 scoped_refptr<base::MessageLoopProxy> target_loop,
24 const PluginService::GetPluginsCallback& callback) { 23 const PluginService::GetPluginsCallback& callback) {
25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
26 25
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 58
60 void PluginLoaderPosix::GetPluginsToLoad() { 59 void PluginLoaderPosix::GetPluginsToLoad() {
61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
62 61
63 base::TimeTicks start_time(base::TimeTicks::Now()); 62 base::TimeTicks start_time(base::TimeTicks::Now());
64 63
65 loaded_plugins_.clear(); 64 loaded_plugins_.clear();
66 next_load_index_ = 0; 65 next_load_index_ = 0;
67 66
68 canonical_list_.clear(); 67 canonical_list_.clear();
69 webkit::npapi::PluginList::Singleton()->GetPluginPathsToLoad( 68 PluginService::GetInstance()->plugin_list()->GetPluginPathsToLoad(
70 &canonical_list_); 69 &canonical_list_);
71 70
72 internal_plugins_.clear(); 71 internal_plugins_.clear();
73 PluginList::Singleton()->GetInternalPlugins(&internal_plugins_); 72 PluginService::GetInstance()->plugin_list()->GetInternalPlugins(
73 &internal_plugins_);
74 74
75 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 75 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
76 base::Bind(&PluginLoaderPosix::LoadPluginsInternal, 76 base::Bind(&PluginLoaderPosix::LoadPluginsInternal,
77 make_scoped_refptr(this))); 77 make_scoped_refptr(this)));
78 78
79 HISTOGRAM_TIMES("PluginLoaderPosix.GetPluginList", 79 HISTOGRAM_TIMES("PluginLoaderPosix.GetPluginList",
80 (base::TimeTicks::Now() - start_time) * 80 (base::TimeTicks::Now() - start_time) *
81 base::Time::kMicrosecondsPerMillisecond); 81 base::Time::kMicrosecondsPerMillisecond);
82 } 82 }
83 83
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return true; 142 return true;
143 } 143 }
144 } 144 }
145 return false; 145 return false;
146 } 146 }
147 147
148 bool PluginLoaderPosix::MaybeRunPendingCallbacks() { 148 bool PluginLoaderPosix::MaybeRunPendingCallbacks() {
149 if (next_load_index_ < canonical_list_.size()) 149 if (next_load_index_ < canonical_list_.size())
150 return false; 150 return false;
151 151
152 PluginList::Singleton()->SetPlugins(loaded_plugins_); 152 PluginService::GetInstance()->plugin_list()->SetPlugins(loaded_plugins_);
153 for (std::vector<PendingCallback>::iterator it = callbacks_.begin(); 153 for (std::vector<PendingCallback>::iterator it = callbacks_.begin();
154 it != callbacks_.end(); 154 it != callbacks_.end();
155 ++it) { 155 ++it) {
156 it->target_loop->PostTask(FROM_HERE, 156 it->target_loop->PostTask(FROM_HERE,
157 base::Bind(it->callback, loaded_plugins_)); 157 base::Bind(it->callback, loaded_plugins_));
158 } 158 }
159 callbacks_.clear(); 159 callbacks_.clear();
160 160
161 HISTOGRAM_TIMES("PluginLoaderPosix.LoadDone", 161 HISTOGRAM_TIMES("PluginLoaderPosix.LoadDone",
162 (base::TimeTicks::Now() - load_start_time_) 162 (base::TimeTicks::Now() - load_start_time_)
163 * base::Time::kMicrosecondsPerMillisecond); 163 * base::Time::kMicrosecondsPerMillisecond);
164 load_start_time_ = base::TimeTicks(); 164 load_start_time_ = base::TimeTicks();
165 165
166 return true; 166 return true;
167 } 167 }
168 168
169 PluginLoaderPosix::PendingCallback::PendingCallback( 169 PluginLoaderPosix::PendingCallback::PendingCallback(
170 scoped_refptr<base::MessageLoopProxy> loop, 170 scoped_refptr<base::MessageLoopProxy> loop,
171 const PluginService::GetPluginsCallback& cb) 171 const PluginService::GetPluginsCallback& cb)
172 : target_loop(loop), 172 : target_loop(loop),
173 callback(cb) { 173 callback(cb) {
174 } 174 }
175 175
176 PluginLoaderPosix::PendingCallback::~PendingCallback() { 176 PluginLoaderPosix::PendingCallback::~PendingCallback() {
177 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698