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

Unified Diff: content/browser/device_orientation/provider_impl.cc

Issue 10837055: Changes ProviderImpl to use a single DataFetcherFactory (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Passes factory by value Created 8 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/device_orientation/provider_impl.cc
diff --git a/content/browser/device_orientation/provider_impl.cc b/content/browser/device_orientation/provider_impl.cc
index 6d3e0e620b1eca053296b1dc0bc5cb993060a7a0..3118093585a95d95477bf0cf4a14c52865b0de1d 100644
--- a/content/browser/device_orientation/provider_impl.cc
+++ b/content/browser/device_orientation/provider_impl.cc
@@ -47,7 +47,7 @@ class ProviderImpl::PollingThread : public base::Thread {
virtual ~PollingThread();
// Method for finding a suitable DataFetcher and starting the polling.
- void Initialize(const std::vector<DataFetcherFactory>& factories);
+ void Initialize(DataFetcherFactory factory);
private:
// Method for polling a DataFetcher.
@@ -86,13 +86,11 @@ ProviderImpl::PollingThread::PollingThread(
ProviderImpl::PollingThread::~PollingThread() {
}
-void ProviderImpl::PollingThread::Initialize(
- const std::vector<DataFetcherFactory>& factories) {
+void ProviderImpl::PollingThread::Initialize(DataFetcherFactory factory) {
DCHECK(MessageLoop::current() == message_loop());
- typedef std::vector<DataFetcherFactory>::const_iterator Iterator;
- for (Iterator i = factories.begin(); i != factories.end(); ++i) {
- DataFetcherFactory factory = *i;
+ if (factory != NULL) {
+ // Try to use factory to create a fetcher that can provide orientation data.
scoped_ptr<DataFetcher> fetcher(factory());
Orientation orientation;
@@ -183,12 +181,11 @@ base::TimeDelta ProviderImpl::PollingThread::SamplingInterval() const {
return base::TimeDelta::FromMilliseconds(kDesiredSamplingIntervalMs);
}
-ProviderImpl::ProviderImpl(const DataFetcherFactory factories[])
+ProviderImpl::ProviderImpl(DataFetcherFactory factory)
: creator_loop_(MessageLoop::current()),
+ factory_(factory),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
polling_thread_(NULL) {
- for (const DataFetcherFactory* fp = factories; *fp; ++fp)
- factories_.push_back(*fp);
}
ProviderImpl::~ProviderImpl() {
@@ -251,7 +248,7 @@ void ProviderImpl::ScheduleInitializePollingThread() {
polling_loop->PostTask(FROM_HERE,
base::Bind(&PollingThread::Initialize,
base::Unretained(polling_thread_),
- factories_));
+ factory_));
}
void ProviderImpl::DoNotify(const Orientation& orientation) {

Powered by Google App Engine
This is Rietveld 408576698