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

Unified Diff: components/network_time/network_time_tracker.cc

Issue 2448943004: Add experimental feature info to certificate reports (Closed)
Patch Set: cleanup 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 3734c32d2ef07b49ec89d44afa81256de29f93fb..6f19044c856d5a200c96b8414a1f5bcbb74e47b6 100644
--- a/components/network_time/network_time_tracker.cc
+++ b/components/network_time/network_time_tracker.cc
@@ -288,6 +288,23 @@ void NetworkTimeTracker::UpdateNetworkTime(base::Time network_time,
pref_service_->Set(prefs::kNetworkTimeMapping, time_mapping);
}
+bool NetworkTimeTracker::AreTimeFetchesEnabled() const {
+ return base::FeatureList::IsEnabled(kNetworkTimeServiceQuerying);
+}
+
+NetworkTimeTracker::FetchBehavior NetworkTimeTracker::GetFetchBehavior() const {
+ const std::string param = variations::GetVariationParamValueByFeature(
+ kNetworkTimeServiceQuerying, kVariationsServiceFetchBehavior);
+ if (param == "background-only") {
+ return FETCHES_IN_BACKGROUND_ONLY;
+ } else if (param == "on-demand-only") {
+ return FETCHES_ON_DEMAND_ONLY;
+ } else if (param == "background-and-on-demand") {
+ return FETCHES_IN_BACKGROUND_AND_ON_DEMAND;
+ }
+ return FETCH_BEHAVIOR_UNKNOWN;
+}
+
void NetworkTimeTracker::SetTimeServerURLForTesting(const GURL& url) {
server_url_ = url;
}
@@ -395,7 +412,8 @@ bool NetworkTimeTracker::StartTimeFetch(const base::Closure& closure) {
// Check if the user is opted in to on-demand time fetches.
const std::string param = variations::GetVariationParamValueByFeature(
kNetworkTimeServiceQuerying, kVariationsServiceFetchBehavior);
- if (param == "background-only") {
+ if (!AreTimeFetchesEnabled() ||
+ GetFetchBehavior() == FETCHES_IN_BACKGROUND_ONLY) {
return false;
}
@@ -554,18 +572,14 @@ void NetworkTimeTracker::OnURLFetchComplete(const net::URLFetcher* source) {
}
void NetworkTimeTracker::QueueCheckTime(base::TimeDelta delay) {
- // 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") {
+ if (AreTimeFetchesEnabled() && GetFetchBehavior() != FETCHES_ON_DEMAND_ONLY) {
timer_.Start(FROM_HERE, delay, this, &NetworkTimeTracker::CheckTime);
}
}
bool NetworkTimeTracker::ShouldIssueTimeQuery() {
// Do not query the time service if not enabled via Variations Service.
- if (!base::FeatureList::IsEnabled(kNetworkTimeServiceQuerying)) {
+ if (!AreTimeFetchesEnabled()) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698