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

Unified Diff: chrome/browser/metrics/variations_service.cc

Issue 10375055: Minor cleanups to variation_service.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/variations_service.cc
===================================================================
--- chrome/browser/metrics/variations_service.cc (revision 135898)
+++ chrome/browser/metrics/variations_service.cc (working copy)
@@ -44,6 +44,11 @@
return chrome::VersionInfo::CHANNEL_UNKNOWN;
}
+// Converts |date_time| in chrome_variations::Study date format to base::Time.
+base::Time ConvertStudyDateToBaseTime(int64 date_time) {
+ return base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(date_time);
+}
+
} // namespace
// Static
@@ -162,7 +167,7 @@
const std::string& version_string) {
const Version current_version(version_string);
if (!current_version.IsValid()) {
- DCHECK(false);
+ NOTREACHED();
return false;
}
@@ -188,18 +193,16 @@
// static
bool VariationsService::CheckStudyDate(const chrome_variations::Study& study,
const base::Time& date_time) {
- const base::Time epoch = base::Time::UnixEpoch();
-
if (study.has_start_date()) {
const base::Time start_date =
- epoch + base::TimeDelta::FromSeconds(study.start_date());
+ ConvertStudyDateToBaseTime(study.start_date());
if (date_time < start_date)
return false;
}
if (study.has_expiry_date()) {
const base::Time expiry_date =
- epoch + base::TimeDelta::FromSeconds(study.expiry_date());
+ ConvertStudyDateToBaseTime(study.expiry_date());
if (date_time >= expiry_date)
return false;
}
@@ -253,9 +256,8 @@
return;
}
- const base::Time epoch = base::Time::UnixEpoch();
const base::Time expiry_date =
- epoch + base::TimeDelta::FromSeconds(study.expiry_date());
+ ConvertStudyDateToBaseTime(study.expiry_date());
base::Time::Exploded exploded_end_date;
expiry_date.UTCExplode(&exploded_end_date);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698