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

Side by Side 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: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/tabs/tab_discard_state.h" 5 #include "chrome/browser/ui/tabs/tab_discard_state.h"
6 6
7 #include "base/metrics/histogram.h"
7 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
8 9
9 using content::WebContents; 10 using content::WebContents;
10 11
11 namespace { 12 namespace {
12 13
13 const char kDiscardStateKey[] = "TabDiscardState"; 14 const char kDiscardStateKey[] = "TabDiscardState";
14 15
15 } // namespace 16 } // namespace
16 17
(...skipping 18 matching lines...) Expand all
35 } 36 }
36 37
37 // static 38 // static
38 bool TabDiscardState::IsDiscarded(WebContents* web_contents) { 39 bool TabDiscardState::IsDiscarded(WebContents* web_contents) {
39 TabDiscardState* discard_state = TabDiscardState::Get(web_contents); 40 TabDiscardState* discard_state = TabDiscardState::Get(web_contents);
40 return discard_state->is_discarded_; 41 return discard_state->is_discarded_;
41 } 42 }
42 43
43 // static 44 // static
44 void TabDiscardState::SetDiscardState(WebContents* web_contents, bool state) { 45 void TabDiscardState::SetDiscardState(WebContents* web_contents, bool state) {
45 TabDiscardState* discard_state = TabDiscardState::Get(web_contents); 46 TabDiscardState* discard_state = TabDiscardState::Get(web_contents);
chrisha 2015/09/25 17:11:52 Does this object only get called from a single thr
Georges Khalil 2015/09/25 18:36:25 Should all be on the UI thread. Added thread chec
47
48 if (discard_state->is_discarded_ && !state) {
49 static int reload_count = 0;
50 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.Discard.ReloadCount", ++reload_count, 1,
51 1000, 50);
52 }
53
46 discard_state->is_discarded_ = state; 54 discard_state->is_discarded_ = state;
47 } 55 }
48 56
49 // static 57 // static
50 int TabDiscardState::DiscardCount(WebContents* web_contents) { 58 int TabDiscardState::DiscardCount(WebContents* web_contents) {
51 TabDiscardState* discard_state = TabDiscardState::Get(web_contents); 59 TabDiscardState* discard_state = TabDiscardState::Get(web_contents);
52 return discard_state->discard_count_; 60 return discard_state->discard_count_;
53 } 61 }
54 62
55 // static 63 // static
56 void TabDiscardState::IncrementDiscardCount(WebContents* web_contents) { 64 void TabDiscardState::IncrementDiscardCount(WebContents* web_contents) {
57 TabDiscardState* discard_state = TabDiscardState::Get(web_contents); 65 TabDiscardState* discard_state = TabDiscardState::Get(web_contents);
58 discard_state->discard_count_++; 66 discard_state->discard_count_++;
59 } 67 }
60 68
61 // static 69 // static
62 void TabDiscardState::CopyState(content::WebContents* old_contents, 70 void TabDiscardState::CopyState(content::WebContents* old_contents,
63 content::WebContents* new_contents) { 71 content::WebContents* new_contents) {
64 TabDiscardState* old_state = Get(old_contents); 72 TabDiscardState* old_state = Get(old_contents);
65 TabDiscardState* new_State = Get(new_contents); 73 TabDiscardState* new_State = Get(new_contents);
66 *new_State = *old_state; 74 *new_State = *old_state;
67 } 75 }
OLDNEW
« 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