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

Unified Diff: chrome/browser/ui/tabs/tab_discard_state.cc

Issue 1366203003: Fix tab discarding reload count metric. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ThreadChecker ==> DCHECK_CURRENTLY_ON Created 5 years, 3 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 | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/tabs/tab_discard_state.cc
diff --git a/chrome/browser/ui/tabs/tab_discard_state.cc b/chrome/browser/ui/tabs/tab_discard_state.cc
index 7a7e8f05592e7e53ab1f097f6cbd95f17e81544c..da2a386de64f523d7567ef891daa9ba3932564a4 100644
--- a/chrome/browser/ui/tabs/tab_discard_state.cc
+++ b/chrome/browser/ui/tabs/tab_discard_state.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/tabs/tab_discard_state.h"
+#include "base/metrics/histogram.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
using content::WebContents;
@@ -16,6 +18,7 @@ const char kDiscardStateKey[] = "TabDiscardState";
// static
TabDiscardState* TabDiscardState::Get(WebContents* web_contents) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
TabDiscardState* discard_state = static_cast<TabDiscardState*>(
web_contents->GetUserData(&kDiscardStateKey));
@@ -31,6 +34,7 @@ TabDiscardState* TabDiscardState::Get(WebContents* web_contents) {
// static
void TabDiscardState::Set(WebContents* web_contents, TabDiscardState* state) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
web_contents->SetUserData(&kDiscardStateKey, state);
}
@@ -43,6 +47,12 @@ bool TabDiscardState::IsDiscarded(WebContents* web_contents) {
// static
void TabDiscardState::SetDiscardState(WebContents* web_contents, bool state) {
TabDiscardState* discard_state = TabDiscardState::Get(web_contents);
+ if (discard_state->is_discarded_ && !state) {
+ static int reload_count = 0;
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.Discard.ReloadCount", ++reload_count, 1,
+ 1000, 50);
+ }
+
discard_state->is_discarded_ = state;
}
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698