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

Unified Diff: components/network_time/network_time_tracker.cc

Issue 2449193002: Attempt an on-demand time fetch when encountering a date invalid error (Closed)
Patch Set: remove unnecessary allocation causing memory leak Created 4 years, 1 month 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 2be937662e8e777b846d931adaaa3aa51413a20e..3734c32d2ef07b49ec89d44afa81256de29f93fb 100644
--- a/components/network_time/network_time_tracker.cc
+++ b/components/network_time/network_time_tracker.cc
@@ -100,9 +100,19 @@ const char kVariationsServiceCheckTimeIntervalSeconds[] =
"CheckTimeIntervalSeconds";
const char kVariationsServiceRandomQueryProbability[] =
"RandomQueryProbability";
-// This parameter must have the value "true" in order for
-// StartTimeFetch() to start time queries on demand.
-const char kVariationsServiceEnableFetchesOnDemand[] = "EnableFetchesOnDemand";
+
+// This parameter can have three values:
+//
+// - "background-only": Time queries will be issued in the background as
+// needed (when the clock loses sync), but on-demand time queries will
+// not be issued (i.e. StartTimeFetch() will not start time queries.)
+//
+// - "on-demand-only": Time queries will not be issued except when
+// StartTimeFetch() is called.
+//
+// - "background-and-on-demand": Time queries will be issued both in the
+// background as needed and also on-demand.
+const char kVariationsServiceFetchBehavior[] = "FetchBehavior";
// This is an ECDSA prime256v1 named-curve key.
const int kKeyVersion = 1;
@@ -282,6 +292,10 @@ void NetworkTimeTracker::SetTimeServerURLForTesting(const GURL& url) {
server_url_ = url;
}
+GURL NetworkTimeTracker::GetTimeServerURLForTesting() const {
+ return server_url_;
+}
+
void NetworkTimeTracker::SetMaxResponseSizeForTesting(size_t limit) {
max_response_size_ = limit;
}
@@ -302,6 +316,10 @@ void NetworkTimeTracker::WaitForFetchForTesting(uint32_t nonce) {
run_loop.Run();
}
+void NetworkTimeTracker::OverrideNonceForTesting(uint32_t nonce) {
+ query_signer_->OverrideNonceForTesting(kKeyVersion, nonce);
+}
+
base::TimeDelta NetworkTimeTracker::GetTimerDelayForTesting() const {
DCHECK(timer_.IsRunning());
return timer_.GetCurrentDelay();
@@ -376,8 +394,8 @@ bool NetworkTimeTracker::StartTimeFetch(const base::Closure& closure) {
DCHECK(thread_checker_.CalledOnValidThread());
// Check if the user is opted in to on-demand time fetches.
const std::string param = variations::GetVariationParamValueByFeature(
- kNetworkTimeServiceQuerying, kVariationsServiceEnableFetchesOnDemand);
- if (param != "true") {
+ kNetworkTimeServiceQuerying, kVariationsServiceFetchBehavior);
+ if (param == "background-only") {
return false;
}
@@ -536,7 +554,13 @@ void NetworkTimeTracker::OnURLFetchComplete(const net::URLFetcher* source) {
}
void NetworkTimeTracker::QueueCheckTime(base::TimeDelta delay) {
- timer_.Start(FROM_HERE, delay, this, &NetworkTimeTracker::CheckTime);
+ // Check if the user is opted in to background time fetches.
+ const std::string param = variations::GetVariationParamValueByFeature(
+ kNetworkTimeServiceQuerying, kVariationsServiceFetchBehavior);
+ if (base::FeatureList::IsEnabled(kNetworkTimeServiceQuerying) &&
+ param != "on-demand-only") {
+ timer_.Start(FROM_HERE, delay, this, &NetworkTimeTracker::CheckTime);
+ }
}
bool NetworkTimeTracker::ShouldIssueTimeQuery() {

Powered by Google App Engine
This is Rietveld 408576698