| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ | 5 #ifndef COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ |
| 6 #define COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ | 6 #define COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "base/time/clock.h" | 15 #include "base/time/clock.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 18 #include "net/url_request/url_fetcher_delegate.h" | 18 #include "net/url_request/url_fetcher_delegate.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 class PrefRegistrySimple; | 21 class PrefRegistrySimple; |
| 22 class PrefService; | 22 class PrefService; |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class MessageLoop; | 25 class RunLoop; |
| 26 class TickClock; | 26 class TickClock; |
| 27 } // namespace base | 27 } // namespace base |
| 28 | 28 |
| 29 namespace client_update_protocol { | 29 namespace client_update_protocol { |
| 30 class Ecdsa; | 30 class Ecdsa; |
| 31 } // namespace client_update_protocol | 31 } // namespace client_update_protocol |
| 32 | 32 |
| 33 namespace net { | 33 namespace net { |
| 34 class URLFetcher; | 34 class URLFetcher; |
| 35 class URLRequestContextGetter; | 35 class URLRequestContextGetter; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 size_t max_response_size_; | 137 size_t max_response_size_; |
| 138 base::TimeDelta backoff_; | 138 base::TimeDelta backoff_; |
| 139 // Timer that runs CheckTime(). All backoff and delay is implemented by | 139 // Timer that runs CheckTime(). All backoff and delay is implemented by |
| 140 // changing the delay of this timer, with the result that CheckTime() may | 140 // changing the delay of this timer, with the result that CheckTime() may |
| 141 // assume that if it runs, it is eligible to issue a time query. | 141 // assume that if it runs, it is eligible to issue a time query. |
| 142 base::RepeatingTimer timer_; | 142 base::RepeatingTimer timer_; |
| 143 scoped_refptr<net::URLRequestContextGetter> getter_; | 143 scoped_refptr<net::URLRequestContextGetter> getter_; |
| 144 std::unique_ptr<net::URLFetcher> time_fetcher_; | 144 std::unique_ptr<net::URLFetcher> time_fetcher_; |
| 145 base::TimeTicks fetch_started_; | 145 base::TimeTicks fetch_started_; |
| 146 std::unique_ptr<client_update_protocol::Ecdsa> query_signer_; | 146 std::unique_ptr<client_update_protocol::Ecdsa> query_signer_; |
| 147 base::MessageLoop* loop_; // For testing; quit on fetch complete. | 147 |
| 148 // Run by WaitForFetchForTesting() and quit by OnURLFetchComplete(). |
| 149 base::RunLoop* run_loop_for_testing_ = nullptr; |
| 148 | 150 |
| 149 // The |Clock| and |TickClock| are used to sanity-check one another, allowing | 151 // The |Clock| and |TickClock| are used to sanity-check one another, allowing |
| 150 // the NetworkTimeTracker to notice e.g. suspend/resume events and clock | 152 // the NetworkTimeTracker to notice e.g. suspend/resume events and clock |
| 151 // resets. | 153 // resets. |
| 152 std::unique_ptr<base::Clock> clock_; | 154 std::unique_ptr<base::Clock> clock_; |
| 153 std::unique_ptr<base::TickClock> tick_clock_; | 155 std::unique_ptr<base::TickClock> tick_clock_; |
| 154 | 156 |
| 155 PrefService* pref_service_; | 157 PrefService* pref_service_; |
| 156 | 158 |
| 157 // Network time based on last call to UpdateNetworkTime(). | 159 // Network time based on last call to UpdateNetworkTime(). |
| (...skipping 12 matching lines...) Expand all Loading... |
| 170 base::TimeDelta network_time_uncertainty_; | 172 base::TimeDelta network_time_uncertainty_; |
| 171 | 173 |
| 172 base::ThreadChecker thread_checker_; | 174 base::ThreadChecker thread_checker_; |
| 173 | 175 |
| 174 DISALLOW_COPY_AND_ASSIGN(NetworkTimeTracker); | 176 DISALLOW_COPY_AND_ASSIGN(NetworkTimeTracker); |
| 175 }; | 177 }; |
| 176 | 178 |
| 177 } // namespace network_time | 179 } // namespace network_time |
| 178 | 180 |
| 179 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ | 181 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ |
| OLD | NEW |