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

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

Issue 10755002: Refactors DeviceOrientation to make it more extensible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moves construction of DeviceData objects out of ProviderImpl 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.h
diff --git a/content/browser/device_orientation/provider_impl.h b/content/browser/device_orientation/provider_impl.h
index c7c12eb4dce6651e6dc315caa3a91e08a239ffd5..2d276187bf8ea2bb9fbe5fd3850dfbde344ba644 100644
--- a/content/browser/device_orientation/provider_impl.h
+++ b/content/browser/device_orientation/provider_impl.h
@@ -8,11 +8,12 @@
#include <set>
#include <vector>
+#include "base/id_map.h"
#include "base/memory/scoped_ptr.h"
#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.
@@ -43,23 +44,28 @@ class ProviderImpl : public Provider {
void Start();
void Stop();
+ // Method for adding a type of observer to poll. Runs on the polling_thread_.
+ void DoAddObserverType(DeviceData::DeviceDataType device_data_type);
+ void ScheduleDoAddObserverType(DeviceData::DeviceDataType device_data_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::DeviceDataType device_data_type);
+ void ScheduleInitializePollingThread(
+ DeviceData::DeviceDataType 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::DeviceDataType device_data_type);
+ void ScheduleDoNotify(const DeviceData* device_data,
+ DeviceData::DeviceDataType device_data_type);
enum { kDesiredSamplingIntervalMs = 100 };
base::TimeDelta SamplingInterval() const;
@@ -71,13 +77,14 @@ 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_;
+ IDMap<DeviceData, IDMapOwnPointer> 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<IDMap<DeviceData, IDMapOwnPointer> > last_device_data_map_;
base::WeakPtrFactory<ProviderImpl> weak_factory_;
+ std::set<DeviceData::DeviceDataType> observer_types_;
// Polling is done on this background thread.
scoped_ptr<base::Thread> polling_thread_;

Powered by Google App Engine
This is Rietveld 408576698