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..c450bbe1cba4f882c93da751b384dcc41fa78ecf 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 "base/threading/thread_checker.h" |
#include "content/public/browser/web_contents.h" |
using content::WebContents; |
@@ -12,10 +14,14 @@ namespace { |
const char kDiscardStateKey[] = "TabDiscardState"; |
+// Ensures that all access is done on the same thread. |
+base::ThreadChecker thread_checker; |
chrisha
2015/09/28 15:07:49
The thread check remembers the thread on which it
Georges Khalil
2015/09/28 18:41:13
I was under the (wrong) impression that it remembe
|
+ |
} // namespace |
// static |
TabDiscardState* TabDiscardState::Get(WebContents* web_contents) { |
+ DCHECK(thread_checker.CalledOnValidThread()); |
TabDiscardState* discard_state = static_cast<TabDiscardState*>( |
web_contents->GetUserData(&kDiscardStateKey)); |
@@ -43,6 +49,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; |
} |