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

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

Issue 1415773004: Refactor ownership model for FirstWebContentsProfiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a1_more_abandons_and_umabandons
Patch Set: fix compile 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/metrics/first_web_contents_profiler.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #if !defined(OS_ANDROID) 5 #if !defined(OS_ANDROID)
6 6
7 #include "chrome/browser/metrics/first_web_contents_profiler.h" 7 #include "chrome/browser/metrics/first_web_contents_profiler.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 base::ThreadTaskRunnerHandle::Get()->PostTask( 90 base::ThreadTaskRunnerHandle::Get()->PostTask(
91 FROM_HERE, 91 FROM_HERE,
92 base::Bind(&RecordUIResponsiveness, responsiveness_histogram, 92 base::Bind(&RecordUIResponsiveness, responsiveness_histogram,
93 unresponsiveness_histogram, base::Time::Now(), 93 unresponsiveness_histogram, base::Time::Now(),
94 base::Time::Now(), 94 base::Time::Now(),
95 base::TimeDelta::FromMilliseconds(kInitialDelayMs))); 95 base::TimeDelta::FromMilliseconds(kInitialDelayMs)));
96 } 96 }
97 97
98 } // namespace 98 } // namespace
99 99
100 scoped_ptr<FirstWebContentsProfiler> 100 // static
101 FirstWebContentsProfiler::CreateProfilerForFirstWebContents( 101 void FirstWebContentsProfiler::Start() {
102 Delegate* delegate) { 102 for (chrome::BrowserIterator browser_it; !browser_it.done();
103 DCHECK(delegate); 103 browser_it.Next()) {
104 for (chrome::BrowserIterator iterator; !iterator.done(); iterator.Next()) {
105 Browser* browser = *iterator;
106 content::WebContents* web_contents = 104 content::WebContents* web_contents =
107 browser->tab_strip_model()->GetActiveWebContents(); 105 browser_it->tab_strip_model()->GetActiveWebContents();
108 if (web_contents) { 106 if (web_contents) {
109 return scoped_ptr<FirstWebContentsProfiler>( 107 new FirstWebContentsProfiler(web_contents);
Alexei Svitkine (slow) 2015/11/13 17:29:00 Add a comment about the lifetime here.
gab 2015/11/13 19:22:21 Good point, done.
110 new FirstWebContentsProfiler(web_contents, delegate)); 108 return;
111 } 109 }
112 } 110 }
113 return nullptr;
114 } 111 }
115 112
116 FirstWebContentsProfiler::FirstWebContentsProfiler( 113 FirstWebContentsProfiler::FirstWebContentsProfiler(
117 content::WebContents* web_contents, 114 content::WebContents* web_contents)
118 Delegate* delegate)
119 : content::WebContentsObserver(web_contents), 115 : content::WebContentsObserver(web_contents),
120 initial_entry_committed_(false), 116 initial_entry_committed_(false),
121 collected_paint_metric_(false), 117 collected_paint_metric_(false),
122 collected_load_metric_(false), 118 collected_load_metric_(false),
123 delegate_(delegate),
124 responsiveness_histogram_(NULL), 119 responsiveness_histogram_(NULL),
125 responsiveness_1sec_histogram_(NULL), 120 responsiveness_1sec_histogram_(NULL),
126 responsiveness_10sec_histogram_(NULL), 121 responsiveness_10sec_histogram_(NULL),
127 unresponsiveness_histogram_(NULL), 122 unresponsiveness_histogram_(NULL),
128 unresponsiveness_1sec_histogram_(NULL), 123 unresponsiveness_1sec_histogram_(NULL),
129 unresponsiveness_10sec_histogram_(NULL) { 124 unresponsiveness_10sec_histogram_(NULL) {
130 InitHistograms(); 125 InitHistograms();
131 } 126 }
132 127
133 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() { 128 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 UMA_HISTOGRAM_ENUMERATION("Startup.FirstWebContents.FinishReason", 213 UMA_HISTOGRAM_ENUMERATION("Startup.FirstWebContents.FinishReason",
219 finish_reason, FinishReason::ENUM_MAX); 214 finish_reason, FinishReason::ENUM_MAX);
220 if (!collected_paint_metric_) { 215 if (!collected_paint_metric_) {
221 UMA_HISTOGRAM_ENUMERATION("Startup.FirstWebContents.FinishReason_NoPaint", 216 UMA_HISTOGRAM_ENUMERATION("Startup.FirstWebContents.FinishReason_NoPaint",
222 finish_reason, FinishReason::ENUM_MAX); 217 finish_reason, FinishReason::ENUM_MAX);
223 } 218 }
224 if (!collected_load_metric_) { 219 if (!collected_load_metric_) {
225 UMA_HISTOGRAM_ENUMERATION("Startup.FirstWebContents.FinishReason_NoLoad", 220 UMA_HISTOGRAM_ENUMERATION("Startup.FirstWebContents.FinishReason_NoLoad",
226 finish_reason, FinishReason::ENUM_MAX); 221 finish_reason, FinishReason::ENUM_MAX);
227 } 222 }
228 delegate_->ProfilerFinishedCollectingMetrics(); 223 delete this;
229 } 224 }
230 225
231 void FirstWebContentsProfiler::InitHistograms() { 226 void FirstWebContentsProfiler::InitHistograms() {
232 const std::string responsiveness_histogram_name = 227 const std::string responsiveness_histogram_name =
233 "Startup.FirstWebContents.UIResponsive"; 228 "Startup.FirstWebContents.UIResponsive";
234 responsiveness_histogram_ = base::Histogram::FactoryTimeGet( 229 responsiveness_histogram_ = base::Histogram::FactoryTimeGet(
235 responsiveness_histogram_name, base::TimeDelta::FromMilliseconds(1), 230 responsiveness_histogram_name, base::TimeDelta::FromMilliseconds(1),
236 base::TimeDelta::FromSeconds(60), 100, 231 base::TimeDelta::FromSeconds(60), 100,
237 base::Histogram::kUmaTargetedHistogramFlag); 232 base::Histogram::kUmaTargetedHistogramFlag);
238 233
(...skipping 26 matching lines...) Expand all
265 100, base::Histogram::kUmaTargetedHistogramFlag); 260 100, base::Histogram::kUmaTargetedHistogramFlag);
266 261
267 const std::string unresponsiveness_10sec_histogram_name = 262 const std::string unresponsiveness_10sec_histogram_name =
268 "Startup.FirstWebContents.UINotResponsive_10sec"; 263 "Startup.FirstWebContents.UINotResponsive_10sec";
269 unresponsiveness_10sec_histogram_ = base::Histogram::FactoryTimeGet( 264 unresponsiveness_10sec_histogram_ = base::Histogram::FactoryTimeGet(
270 unresponsiveness_10sec_histogram_name, 265 unresponsiveness_10sec_histogram_name,
271 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(60), 266 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(60),
272 100, base::Histogram::kUmaTargetedHistogramFlag); 267 100, base::Histogram::kUmaTargetedHistogramFlag);
273 } 268 }
274 #endif // !defined(OS_ANDROID) 269 #endif // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « chrome/browser/metrics/first_web_contents_profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698