Chromium Code Reviews| 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..cf572f3640eeea9ee6ce2306efb85c62d0f28f7d 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(const DataFetcherFactory* factory); |
| private: |
| // Method for polling a DataFetcher. |
| @@ -87,13 +87,13 @@ ProviderImpl::PollingThread::~PollingThread() { |
| } |
| void ProviderImpl::PollingThread::Initialize( |
| - const std::vector<DataFetcherFactory>& factories) { |
| + const 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; |
| - scoped_ptr<DataFetcher> fetcher(factory()); |
| + if (factory != NULL) { |
|
hans
2012/08/01 19:08:47
i wonder if it would make the code simpler to chec
aousterh
2012/08/02 10:10:38
I don't think it would really be simpler, because
|
| + // Try to use factory to create a fetcher that can provide orientation data. |
| + DataFetcherFactory data_fetcher_factory = *factory; |
| + scoped_ptr<DataFetcher> fetcher(data_fetcher_factory()); |
| Orientation orientation; |
| if (fetcher.get() && fetcher->GetOrientation(&orientation)) { |
| @@ -183,12 +183,14 @@ base::TimeDelta ProviderImpl::PollingThread::SamplingInterval() const { |
| return base::TimeDelta::FromMilliseconds(kDesiredSamplingIntervalMs); |
| } |
| -ProviderImpl::ProviderImpl(const DataFetcherFactory factories[]) |
| +ProviderImpl::ProviderImpl(const DataFetcherFactory* factory) |
| : creator_loop_(MessageLoop::current()), |
| ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| polling_thread_(NULL) { |
| - for (const DataFetcherFactory* fp = factories; *fp; ++fp) |
| - factories_.push_back(*fp); |
| + if (factory == NULL) |
| + factory_ = NULL; |
| + else |
| + factory_ = new DataFetcherFactory(*factory); |
|
hans
2012/08/01 19:08:47
this looks overly complex; i think it should just
aousterh
2012/08/02 10:10:38
Done.
|
| } |
| ProviderImpl::~ProviderImpl() { |
| @@ -251,7 +253,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) { |