Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: components/network_time/network_time_tracker.h

Issue 2254433003: When network time is unavailable, record the reason in UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix maximums to not overflow, and fix unit tests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/upgrade_detector_impl.cc ('k') | components/network_time/network_time_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/upgrade_detector_impl.cc ('k') | components/network_time/network_time_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698