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..5e06fa6e58b0743b8b9a3710b3a030658a098554 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, |
+ // Network time is unavailable because the tracker has not yet |
+ // retrieved a time from the network. |
+ NETWORK_TIME_NO_SYNC, |
+ }; |
+ |
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 time 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; |
// Calculates corresponding time ticks according to the given parameters. |
// The provided |network_time| is precise at the given |resolution| and |