| 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/feature_list.h" |
| 11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 15 #include "base/time/clock.h" | 16 #include "base/time/clock.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 18 #include "net/url_request/url_fetcher_delegate.h" | 19 #include "net/url_request/url_fetcher_delegate.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 namespace network_time { | 39 namespace network_time { |
| 39 | 40 |
| 40 // Clock resolution is platform dependent. | 41 // Clock resolution is platform dependent. |
| 41 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 42 const int64_t kTicksResolutionMs = base::Time::kMinLowResolutionThresholdMs; | 43 const int64_t kTicksResolutionMs = base::Time::kMinLowResolutionThresholdMs; |
| 43 #else | 44 #else |
| 44 const int64_t kTicksResolutionMs = 1; // Assume 1ms for non-windows platforms. | 45 const int64_t kTicksResolutionMs = 1; // Assume 1ms for non-windows platforms. |
| 45 #endif | 46 #endif |
| 46 | 47 |
| 48 // Variations Service feature that enables network time service querying. |
| 49 extern const base::Feature kNetworkTimeServiceQuerying; |
| 50 |
| 47 // A class that receives network time updates and can provide the network time | 51 // A class that receives network time updates and can provide the network time |
| 48 // for a corresponding local time. This class is not thread safe. | 52 // for a corresponding local time. This class is not thread safe. |
| 49 class NetworkTimeTracker : public net::URLFetcherDelegate { | 53 class NetworkTimeTracker : public net::URLFetcherDelegate { |
| 50 public: | 54 public: |
| 51 // Describes the result of a GetNetworkTime() call, describing whether | 55 // Describes the result of a GetNetworkTime() call, describing whether |
| 52 // network time was available and if not, why not. | 56 // network time was available and if not, why not. |
| 53 enum NetworkTimeResult { | 57 enum NetworkTimeResult { |
| 54 // Network time is available. | 58 // Network time is available. |
| 55 NETWORK_TIME_AVAILABLE, | 59 NETWORK_TIME_AVAILABLE, |
| 56 // A time has been retrieved from the network in the past, but | 60 // A time has been retrieved from the network in the past, but |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 base::TimeDelta network_time_uncertainty_; | 174 base::TimeDelta network_time_uncertainty_; |
| 171 | 175 |
| 172 base::ThreadChecker thread_checker_; | 176 base::ThreadChecker thread_checker_; |
| 173 | 177 |
| 174 DISALLOW_COPY_AND_ASSIGN(NetworkTimeTracker); | 178 DISALLOW_COPY_AND_ASSIGN(NetworkTimeTracker); |
| 175 }; | 179 }; |
| 176 | 180 |
| 177 } // namespace network_time | 181 } // namespace network_time |
| 178 | 182 |
| 179 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ | 183 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ |
| OLD | NEW |