Chromium Code Reviews| 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..3d129249a52af2934ac593e8d901dc8068c68c05 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[] = |
|
tbansal1
2015/11/16 17:17:38
Remove Seconds/Minutes etc. from the variable name
Raj
2015/11/16 20:09:37
Not sure. Each UMA needs different precision.
|
| + "DataUse.TabModel.TrackingSessionLifetime"; |
| +const char kUMAOldInactiveSessionRemovaltimeSecondsHistogram[] = |
| + "DataUse.TabModel.OldInactiveSessionRemovaltime"; |
| + |
| } // namespace |
| namespace chrome { |
| @@ -75,6 +81,12 @@ bool TabDataUseEntry::EndTracking() { |
| return false; |
| back_iterator->end_time = Now(); |
| + |
| + UMA_HISTOGRAM_COUNTS_1000( |
|
tbansal1
2015/11/16 17:17:38
TIMES?
Raj
2015/11/16 20:09:36
Tracking session lifetime in the range of 1 second
|
| + kUMATrackingSessionLifetimeSecondsHistogram, |
| + base::TimeDelta(back_iterator->end_time - back_iterator->start_time) |
| + .InSeconds()); |
| + |
| 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,15 @@ 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_COUNTS_1000( |
| + kUMAOldInactiveSessionRemovaltimeSecondsHistogram, |
|
tbansal1
2015/11/16 17:17:38
TIMES?
Raj
2015/11/16 20:09:36
Tracking old inactive tracking session removal tim
|
| + base::TimeDelta(Now() - front.end_time).InSeconds()); |
| sessions_.pop_front(); |
| + } |
| } |
| } // namespace android |