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

Unified Diff: components/network_time/network_time_tracker.cc

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: 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
Index: components/network_time/network_time_tracker.cc
diff --git a/components/network_time/network_time_tracker.cc b/components/network_time/network_time_tracker.cc
index 8c0540777e0e847154afa9faa2d341d5e7f18389..430140c5a45919e3d396b8643d68615a60245083 100644
--- a/components/network_time/network_time_tracker.cc
+++ b/components/network_time/network_time_tracker.cc
@@ -306,12 +306,13 @@ base::TimeDelta NetworkTimeTracker::GetTimerDelayForTesting() const {
return timer_.GetCurrentDelay();
}
-bool NetworkTimeTracker::GetNetworkTime(base::Time* network_time,
- base::TimeDelta* uncertainty) const {
+NetworkTimeTracker::NetworkTimeResult NetworkTimeTracker::GetNetworkTime(
+ base::Time* network_time,
+ base::TimeDelta* uncertainty) const {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(network_time);
if (network_time_at_last_measurement_.is_null()) {
- return false;
+ return NETWORK_TIME_NO_SYNC;
}
DCHECK(!ticks_at_last_measurement_.is_null());
DCHECK(!time_at_last_measurement_.is_null());
@@ -321,7 +322,7 @@ bool NetworkTimeTracker::GetNetworkTime(base::Time* network_time,
if (time_delta.InMilliseconds() < 0) { // Has wall clock run backward?
DVLOG(1) << "Discarding network time due to wall clock running backward";
network_time_at_last_measurement_ = base::Time();
- return false;
+ return NETWORK_TIME_SYNC_LOST;
}
// Now we know that both |tick_delta| and |time_delta| are positive.
base::TimeDelta divergence = (tick_delta - time_delta).magnitude();
@@ -330,13 +331,13 @@ bool NetworkTimeTracker::GetNetworkTime(base::Time* network_time,
// reset.
DVLOG(1) << "Discarding network time due to clocks diverging";
network_time_at_last_measurement_ = base::Time();
- return false;
+ return NETWORK_TIME_SYNC_LOST;
}
*network_time = network_time_at_last_measurement_ + tick_delta;
if (uncertainty) {
*uncertainty = network_time_uncertainty_ + divergence;
}
- return true;
+ return NETWORK_TIME_AVAILABLE;
}
void NetworkTimeTracker::CheckTime() {
@@ -471,10 +472,10 @@ bool NetworkTimeTracker::ShouldIssueTimeQuery() {
return false;
}
- // If GetNetworkTime() returns false, synchronization has been lost
- // and a query is needed.
+ // If GetNetworkTime() does not return NETWORK_TIME_AVAILABLE,
+ // synchronization has been lost and a query is needed.
base::Time network_time;
- if (!GetNetworkTime(&network_time, nullptr)) {
+ if (GetNetworkTime(&network_time, nullptr) != NETWORK_TIME_AVAILABLE) {
return true;
}

Powered by Google App Engine
This is Rietveld 408576698