| Index: chrome/browser/android/data_usage/tab_data_use_entry.cc
|
| diff --git a/chrome/browser/android/data_usage/tab_data_use_entry.cc b/chrome/browser/android/data_usage/tab_data_use_entry.cc
|
| index 041fe4dfdc40edd4e3f1575e7240fc9b9613bcc6..545432b0a8c4cf27b07b58f84c5cce30f08775f7 100644
|
| --- a/chrome/browser/android/data_usage/tab_data_use_entry.cc
|
| +++ b/chrome/browser/android/data_usage/tab_data_use_entry.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/gtest_prod_util.h"
|
| #include "base/macros.h"
|
| +#include "base/metrics/histogram_macros.h"
|
|
|
| namespace {
|
|
|
| @@ -21,6 +22,11 @@ const unsigned int kClosedTabExpirationDurationSeconds = 30; // 30 seconds.
|
| const unsigned int kOpenTabExpirationDurationSeconds =
|
| 60 * 60 * 24 * 5; // 5 days.
|
|
|
| +const char kUMATrackingSessionLifetimeSecondsHistogram[] =
|
| + "DataUse.TabModel.TrackingSessionLifetime";
|
| +const char kUMAOldInactiveSessionRemovalDurationSecondsHistogram[] =
|
| + "DataUse.TabModel.OldInactiveSessionRemovalDuration";
|
| +
|
| } // namespace
|
|
|
| namespace chrome {
|
| @@ -75,6 +81,12 @@ bool TabDataUseEntry::EndTracking() {
|
| return false;
|
|
|
| back_iterator->end_time = Now();
|
| +
|
| + UMA_HISTOGRAM_CUSTOM_TIMES(
|
| + kUMATrackingSessionLifetimeSecondsHistogram,
|
| + back_iterator->end_time - back_iterator->start_time,
|
| + base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(1), 50);
|
| +
|
| return true;
|
| }
|
|
|
| @@ -96,8 +108,6 @@ bool TabDataUseEntry::IsExpired() const {
|
| if (latest_session_time.is_null() ||
|
| ((now - latest_session_time) >
|
| base::TimeDelta::FromSeconds(kOpenTabExpirationDurationSeconds))) {
|
| - // TODO(rajendrant): Add UMA to track deletion of entries corresponding to
|
| - // existing tabs.
|
| return true;
|
| }
|
| return false;
|
| @@ -146,9 +156,16 @@ const base::TimeTicks TabDataUseEntry::GetLatestStartOrEndTime() const {
|
| }
|
|
|
| void TabDataUseEntry::CompactSessionHistory() {
|
| - // TODO(rajendrant): Add UMA to track how often old sessions are lost.
|
| - while (sessions_.size() > kMaxSessionsPerTab)
|
| + while (sessions_.size() > kMaxSessionsPerTab) {
|
| + const auto& front = sessions_.front();
|
| + DCHECK(!front.end_time.is_null());
|
| + // Track how often old sessions are lost.
|
| + UMA_HISTOGRAM_CUSTOM_TIMES(
|
| + kUMAOldInactiveSessionRemovalDurationSecondsHistogram,
|
| + Now() - front.end_time, base::TimeDelta::FromSeconds(1),
|
| + base::TimeDelta::FromHours(1), 50);
|
| sessions_.pop_front();
|
| + }
|
| }
|
|
|
| } // namespace android
|
|
|