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

Side by Side Diff: chrome/browser/metrics/tab_usage_recorder.cc

Issue 2757293004: Remove DCHECK when initializing the TabUsageRecorder. (Closed)
Patch Set: Created 3 years, 9 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/metrics/tab_usage_recorder.h ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/metrics/tab_usage_recorder.h" 5 #include "chrome/browser/metrics/tab_usage_recorder.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "content/public/browser/web_contents_user_data.h" 10 #include "content/public/browser/web_contents_user_data.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 "Tab.TimeToReactivation.Important", time_to_reactivation, 83 "Tab.TimeToReactivation.Important", time_to_reactivation,
84 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(2), 100); 84 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(2), 100);
85 } else { 85 } else {
86 UMA_HISTOGRAM_CUSTOM_TIMES( 86 UMA_HISTOGRAM_CUSTOM_TIMES(
87 "Tab.TimeToReactivation.Normal", time_to_reactivation, 87 "Tab.TimeToReactivation.Normal", time_to_reactivation,
88 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(2), 100); 88 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(2), 100);
89 } 89 }
90 } 90 }
91 91
92 // static 92 // static
93 void TabUsageRecorder::Initialize() { 93 void TabUsageRecorder::InitializeIfNeeded() {
94 DCHECK(!g_tab_usage_recorder); 94 if (!g_tab_usage_recorder)
95 g_tab_usage_recorder = new TabUsageRecorder(); 95 g_tab_usage_recorder = new TabUsageRecorder();
96 } 96 }
97 97
98 void TabUsageRecorder::OnTabDeactivated(content::WebContents* contents) { 98 void TabUsageRecorder::OnTabDeactivated(content::WebContents* contents) {
99 GetWebContentsData(contents)->RecordTabDeactivation(); 99 GetWebContentsData(contents)->RecordTabDeactivation();
100 } 100 }
101 101
102 void TabUsageRecorder::OnTabReactivated(content::WebContents* contents) { 102 void TabUsageRecorder::OnTabReactivated(content::WebContents* contents) {
103 GetWebContentsData(contents)->RecordTabReactivation(); 103 GetWebContentsData(contents)->RecordTabReactivation();
104 } 104 }
105 105
(...skipping 20 matching lines...) Expand all
126 126
127 TabUsageRecorder::~TabUsageRecorder() = default; 127 TabUsageRecorder::~TabUsageRecorder() = default;
128 128
129 TabUsageRecorder::WebContentsData* TabUsageRecorder::GetWebContentsData( 129 TabUsageRecorder::WebContentsData* TabUsageRecorder::GetWebContentsData(
130 content::WebContents* contents) { 130 content::WebContents* contents) {
131 WebContentsData::CreateForWebContents(contents); 131 WebContentsData::CreateForWebContents(contents);
132 return WebContentsData::FromWebContents(contents); 132 return WebContentsData::FromWebContents(contents);
133 } 133 }
134 134
135 } // namespace metrics 135 } // namespace metrics
OLDNEW
« no previous file with comments | « chrome/browser/metrics/tab_usage_recorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698