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

Unified Diff: chrome/browser/android/data_usage/tab_data_use_entry.cc

Issue 1444133002: Add UMA histograms for data usage tab model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed jwd comments Created 5 years, 1 month 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
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

Powered by Google App Engine
This is Rietveld 408576698