| Index: content/browser/device_orientation/provider_impl.h
|
| diff --git a/content/browser/device_orientation/provider_impl.h b/content/browser/device_orientation/provider_impl.h
|
| index c7c12eb4dce6651e6dc315caa3a91e08a239ffd5..f6a1c95c9ed803eaf07c55c88bdd222b379bd3ee 100644
|
| --- a/content/browser/device_orientation/provider_impl.h
|
| +++ b/content/browser/device_orientation/provider_impl.h
|
| @@ -5,6 +5,7 @@
|
| #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_
|
| #define CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_
|
|
|
| +#include <map>
|
| #include <set>
|
| #include <vector>
|
|
|
| @@ -12,7 +13,7 @@
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/time.h"
|
| #include "content/browser/device_orientation/data_fetcher.h"
|
| -#include "content/browser/device_orientation/orientation.h"
|
| +#include "content/browser/device_orientation/device_data.h"
|
| #include "content/browser/device_orientation/provider.h"
|
| #include "content/common/content_export.h"
|
|
|
| @@ -29,7 +30,7 @@ class ProviderImpl : public Provider {
|
| typedef DataFetcher* (*DataFetcherFactory)();
|
|
|
| // Create a ProviderImpl that uses the NULL-terminated factories array to find
|
| - // a DataFetcher that can provide orientation data.
|
| + // a DataFetcher that can provide data.
|
| CONTENT_EXPORT ProviderImpl(const DataFetcherFactory factories[]);
|
|
|
| // From Provider.
|
| @@ -40,27 +41,33 @@ class ProviderImpl : public Provider {
|
| virtual ~ProviderImpl();
|
|
|
| // Starts or Stops the provider. Called from creator_loop_.
|
| - void Start();
|
| + void Start(DeviceData::Type type);
|
| void Stop();
|
|
|
| + // Method for adding a type of data to poll for. Runs on the polling_thread_.
|
| + void DoAddPollingDataType(DeviceData::Type type);
|
| + void ScheduleDoAddPollingDataType(DeviceData::Type type);
|
| +
|
| // Method for finding a suitable DataFetcher and starting the polling.
|
| // Runs on the polling_thread_.
|
| void DoInitializePollingThread(
|
| - const std::vector<DataFetcherFactory>& factories);
|
| - void ScheduleInitializePollingThread();
|
| + const std::vector<DataFetcherFactory>& factories,
|
| + DeviceData::Type device_data_type);
|
| + void ScheduleInitializePollingThread(DeviceData::Type device_data_type);
|
|
|
| // Method for polling a DataFetcher. Runs on the polling_thread_.
|
| void DoPoll();
|
| void ScheduleDoPoll();
|
|
|
| - // Method for notifying observers of an orientation update.
|
| + // Method for notifying observers of a data update.
|
| // Runs on the creator_thread_.
|
| - void DoNotify(const Orientation& orientation);
|
| - void ScheduleDoNotify(const Orientation& orientation);
|
| -
|
| - static bool SignificantlyDifferent(const Orientation& orientation1,
|
| - const Orientation& orientation2);
|
| + void DoNotify(const DeviceData* device_data,
|
| + DeviceData::Type device_data_type);
|
| + void ScheduleDoNotify(const DeviceData* device_data,
|
| + DeviceData::Type device_data_type);
|
|
|
| + static bool ShouldFireEvent(const DeviceData* old_data,
|
| + const DeviceData* new_data, DeviceData::Type device_data_type);
|
| enum { kDesiredSamplingIntervalMs = 100 };
|
| base::TimeDelta SamplingInterval() const;
|
|
|
| @@ -71,13 +78,16 @@ class ProviderImpl : public Provider {
|
| // Members below are only to be used from the creator_loop_.
|
| std::vector<DataFetcherFactory> factories_;
|
| std::set<Observer*> observers_;
|
| - Orientation last_notification_;
|
| + std::map<DeviceData::Type, scoped_refptr<const DeviceData> >
|
| + last_notifications_map_;
|
|
|
| // When polling_thread_ is running, members below are only to be used
|
| // from that thread.
|
| scoped_ptr<DataFetcher> data_fetcher_;
|
| - Orientation last_orientation_;
|
| + scoped_ptr<std::map<DeviceData::Type, scoped_refptr<const DeviceData> > >
|
| + last_device_data_map_;
|
| base::WeakPtrFactory<ProviderImpl> weak_factory_;
|
| + std::set<DeviceData::Type> polling_data_types_;
|
|
|
| // Polling is done on this background thread.
|
| scoped_ptr<base::Thread> polling_thread_;
|
|
|