| OLD | NEW |
| 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 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_ | 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/time.h" |
| 13 #include "content/browser/device_orientation/data_fetcher.h" | 14 #include "content/browser/device_orientation/data_fetcher.h" |
| 14 #include "content/browser/device_orientation/orientation.h" | 15 #include "content/browser/device_orientation/orientation.h" |
| 15 #include "content/browser/device_orientation/provider.h" | 16 #include "content/browser/device_orientation/provider.h" |
| 16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 17 | 18 |
| 18 class MessageLoop; | 19 class MessageLoop; |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class Thread; | 22 class Thread; |
| 22 } | 23 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 55 |
| 55 // Method for notifying observers of an orientation update. | 56 // Method for notifying observers of an orientation update. |
| 56 // Runs on the creator_thread_. | 57 // Runs on the creator_thread_. |
| 57 void DoNotify(const Orientation& orientation); | 58 void DoNotify(const Orientation& orientation); |
| 58 void ScheduleDoNotify(const Orientation& orientation); | 59 void ScheduleDoNotify(const Orientation& orientation); |
| 59 | 60 |
| 60 static bool SignificantlyDifferent(const Orientation& orientation1, | 61 static bool SignificantlyDifferent(const Orientation& orientation1, |
| 61 const Orientation& orientation2); | 62 const Orientation& orientation2); |
| 62 | 63 |
| 63 enum { kDesiredSamplingIntervalMs = 100 }; | 64 enum { kDesiredSamplingIntervalMs = 100 }; |
| 64 int SamplingIntervalMs() const; | 65 base::TimeDelta SamplingInterval() const; |
| 65 | 66 |
| 66 // The Message Loop on which this object was created. | 67 // The Message Loop on which this object was created. |
| 67 // Typically the I/O loop, but may be something else during testing. | 68 // Typically the I/O loop, but may be something else during testing. |
| 68 MessageLoop* creator_loop_; | 69 MessageLoop* creator_loop_; |
| 69 | 70 |
| 70 // Members below are only to be used from the creator_loop_. | 71 // Members below are only to be used from the creator_loop_. |
| 71 std::vector<DataFetcherFactory> factories_; | 72 std::vector<DataFetcherFactory> factories_; |
| 72 std::set<Observer*> observers_; | 73 std::set<Observer*> observers_; |
| 73 Orientation last_notification_; | 74 Orientation last_notification_; |
| 74 | 75 |
| 75 // When polling_thread_ is running, members below are only to be used | 76 // When polling_thread_ is running, members below are only to be used |
| 76 // from that thread. | 77 // from that thread. |
| 77 scoped_ptr<DataFetcher> data_fetcher_; | 78 scoped_ptr<DataFetcher> data_fetcher_; |
| 78 Orientation last_orientation_; | 79 Orientation last_orientation_; |
| 79 base::WeakPtrFactory<ProviderImpl> weak_factory_; | 80 base::WeakPtrFactory<ProviderImpl> weak_factory_; |
| 80 | 81 |
| 81 // Polling is done on this background thread. | 82 // Polling is done on this background thread. |
| 82 scoped_ptr<base::Thread> polling_thread_; | 83 scoped_ptr<base::Thread> polling_thread_; |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 } // namespace device_orientation | 86 } // namespace device_orientation |
| 86 | 87 |
| 87 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_ | 88 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_PROVIDER_IMPL_H_ |
| OLD | NEW |