OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h " | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h " |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 const int kMaxDaysSinceUnixEpoch = 365 * 1000; // 1000 years. | 389 const int kMaxDaysSinceUnixEpoch = 365 * 1000; // 1000 years. |
390 if (time_since_unix_epoch.InDays() < kMinDaysSinceUnixEpoch || | 390 if (time_since_unix_epoch.InDays() < kMinDaysSinceUnixEpoch || |
391 time_since_unix_epoch.InDays() > kMaxDaysSinceUnixEpoch) { | 391 time_since_unix_epoch.InDays() > kMaxDaysSinceUnixEpoch) { |
392 return; | 392 return; |
393 } | 393 } |
394 | 394 |
395 // Determine how many days it has been since the last update. | 395 // Determine how many days it has been since the last update. |
396 int64 then_internal = prefs->GetInt64( | 396 int64 then_internal = prefs->GetInt64( |
397 data_reduction_proxy::prefs::kDailyHttpContentLengthLastUpdateDate); | 397 data_reduction_proxy::prefs::kDailyHttpContentLengthLastUpdateDate); |
398 | 398 |
399 #if defined(OS_WIN) | |
400 base::Time then_midnight = base::Time::FromInternalValue(then_internal); | |
401 base::Time midnight = | |
402 base::Time::FromInternalValue( | |
403 (now.ToInternalValue() / base::Time::kMicrosecondsPerDay) * | |
404 base::Time::kMicrosecondsPerDay); | |
405 #else | |
406 // Local midnight could have been shifted due to time zone change. | 399 // Local midnight could have been shifted due to time zone change. |
407 base::Time then_midnight = | 400 // If time is null then don't care if midnight will be wrong shifted due to |
408 base::Time::FromInternalValue(then_internal).LocalMidnight(); | 401 // time zone change because it's still too much time ago. |
402 base::Time then_midnight; | |
403 if (then_internal != 0) { | |
bengr
2014/08/25 21:37:08
nit: We shouldn't use or assume anything about the
| |
404 then_midnight = | |
405 base::Time::FromInternalValue(then_internal).LocalMidnight(); | |
406 } | |
409 base::Time midnight = now.LocalMidnight(); | 407 base::Time midnight = now.LocalMidnight(); |
410 #endif | |
411 | 408 |
412 int days_since_last_update = (midnight - then_midnight).InDays(); | 409 int days_since_last_update = (midnight - then_midnight).InDays(); |
413 | 410 |
414 // Each day, we calculate the total number of bytes received and the total | 411 // Each day, we calculate the total number of bytes received and the total |
415 // size of all corresponding resources before any data-reducing recompression | 412 // size of all corresponding resources before any data-reducing recompression |
416 // is applied. These values are used to compute the data savings realized | 413 // is applied. These values are used to compute the data savings realized |
417 // by applying our compression techniques. Totals for the last | 414 // by applying our compression techniques. Totals for the last |
418 // |kNumDaysInHistory| days are maintained. | 415 // |kNumDaysInHistory| days are maintained. |
419 DailyDataSavingUpdate total( | 416 DailyDataSavingUpdate total( |
420 data_reduction_proxy::prefs::kDailyHttpOriginalContentLength, | 417 data_reduction_proxy::prefs::kDailyHttpOriginalContentLength, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 UpdateContentLengthPrefsForDataReductionProxy( | 531 UpdateContentLengthPrefsForDataReductionProxy( |
535 received_content_length, | 532 received_content_length, |
536 original_content_length, | 533 original_content_length, |
537 with_data_reduction_proxy_enabled, | 534 with_data_reduction_proxy_enabled, |
538 request_type, | 535 request_type, |
539 base::Time::Now(), | 536 base::Time::Now(), |
540 prefs); | 537 prefs); |
541 } | 538 } |
542 | 539 |
543 } // namespace data_reduction_proxy | 540 } // namespace data_reduction_proxy |
OLD | NEW |