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

Unified Diff: components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc

Issue 479793002: Fix midnight determination (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't use internal time representation Created 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
index 7143f7c209f51362a20bf16032c80bfe5367839b..c6c1c9a97978b03bc964e7a6200d65d4eedba43b 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_metrics.cc
@@ -396,18 +396,14 @@ void UpdateContentLengthPrefsForDataReductionProxy(
int64 then_internal = prefs->GetInt64(
data_reduction_proxy::prefs::kDailyHttpContentLengthLastUpdateDate);
-#if defined(OS_WIN)
- base::Time then_midnight = base::Time::FromInternalValue(then_internal);
- base::Time midnight =
- base::Time::FromInternalValue(
- (now.ToInternalValue() / base::Time::kMicrosecondsPerDay) *
- base::Time::kMicrosecondsPerDay);
-#else
// Local midnight could have been shifted due to time zone change.
- base::Time then_midnight =
- base::Time::FromInternalValue(then_internal).LocalMidnight();
+ // If time is null then don't care if midnight will be wrong shifted due to
+ // time zone change because it's still too much time ago.
+ base::Time then_midnight = base::Time::FromInternalValue(then_internal);
+ if (!then_midnight.is_null()) {
+ then_midnight = then_midnight.LocalMidnight();
+ }
base::Time midnight = now.LocalMidnight();
-#endif
int days_since_last_update = (midnight - then_midnight).InDays();
« 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