Chromium Code Reviews| Index: components/network_time/network_time_tracker.h |
| diff --git a/components/network_time/network_time_tracker.h b/components/network_time/network_time_tracker.h |
| index 07869e3f271b13e240bba1295fbb421b08dc8e62..730ece825844a2314d7a840ce19002a226aaf803 100644 |
| --- a/components/network_time/network_time_tracker.h |
| +++ b/components/network_time/network_time_tracker.h |
| @@ -48,6 +48,20 @@ const int64_t kTicksResolutionMs = 1; // Assume 1ms for non-windows platforms. |
| // for a corresponding local time. This class is not thread safe. |
| class NetworkTimeTracker : public net::URLFetcherDelegate { |
| public: |
| + // Describes the result of a GetNetworkTime() call, describing whether |
| + // network time was available and if not, why not. |
| + enum NetworkTimeResult { |
| + // Network time is available. |
| + NETWORK_TIME_AVAILABLE, |
| + // A time has been retrieved from the network in the past, but |
| + // network time is no longer available because the tracker fell out |
| + // of sync due to, for example, a suspend/resume. |
| + NETWORK_TIME_SYNC_LOST, |
|
mab
2016/08/16 19:04:52
I was thinking this morning that if we've once obt
estark
2016/08/18 12:15:11
Acknowledged. Might be useful; I was also thinking
|
| + // Network time is unavailable because the tracker has not yet |
| + // retrieved a time from the network. |
| + NETWORK_TIME_NO_SYNC, |
|
mab
2016/08/16 19:04:52
There's an implementation detail here that you may
estark
2016/08/18 12:15:11
It occurred to me that knowing the amount of diver
|
| + }; |
| + |
| static void RegisterPrefs(PrefRegistrySimple* registry); |
| // Constructor. Arguments may be stubbed out for tests. |getter|, if not |
| @@ -59,9 +73,13 @@ class NetworkTimeTracker : public net::URLFetcherDelegate { |
| scoped_refptr<net::URLRequestContextGetter> getter); |
| ~NetworkTimeTracker() override; |
| - // Sets |network_time| to an estimate of the true time. Returns true if time |
| - // is available, and false otherwise. If |uncertainty| is non-NULL, it will |
| - // be set to an estimate of the error range. |
| + // Sets |network_time| to an estimate of the true time. Returns |
| + // NETWORK_TIME_AVAILABLE if time is available. If |uncertainty| is |
| + // non-NULL, it will be set to an estimate of the error range. |
| + // |
| + // If network is unavailable, this method returns |
| + // NETWORK_TIME_SYNC_LOST or NETWORK_TIME_NO_SYNC to indicate the |
| + // reason. |
| // |
| // Network time may be available on startup if deserialized from a pref. |
| // Failing that, a call to |UpdateNetworkTime| is required to make time |
| @@ -69,8 +87,8 @@ class NetworkTimeTracker : public net::URLFetcherDelegate { |
| // become unavailable if |NetworkTimeTracker| has reason to believe it is no |
| // longer accurate. Consumers should even be prepared to handle the case |
| // where calls to |GetNetworkTime| never once succeeds. |
| - bool GetNetworkTime(base::Time* network_time, |
| - base::TimeDelta* uncertainty) const; |
| + NetworkTimeResult GetNetworkTime(base::Time* network_time, |
| + base::TimeDelta* uncertainty) const; |
|
mab
2016/08/16 19:04:52
Most callers don't care about the reason for failu
estark
2016/08/18 12:15:11
Acknowledged. Decided to leave as-is because I alr
|
| // Calculates corresponding time ticks according to the given parameters. |
| // The provided |network_time| is precise at the given |resolution| and |