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

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

Issue 1169503002: Do not record startup metrics when non-browser UI was displayed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added macro to completely disable the test on chromeos Created 5 years, 6 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
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 "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "base/process/process_info.h" 11 #include "base/process/process_info.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_iterator.h" 14 #include "chrome/browser/ui/browser_iterator.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "components/metrics/profiler/tracking_synchronizer.h" 16 #include "components/metrics/profiler/tracking_synchronizer.h"
17 #include "components/metrics/proto/profiler_event.pb.h" 17 #include "components/metrics/proto/profiler_event.pb.h"
18 #include "components/startup_metric_utils/startup_metric_utils.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 20
20 namespace { 21 namespace {
21 // The initial delay for responsiveness prober in milliseconds. 22 // The initial delay for responsiveness prober in milliseconds.
22 const int kInitialDelayMs = 20; 23 const int kInitialDelayMs = 20;
23 24
24 // The following is the multiplier is used to delay the probe for 25 // The following is the multiplier is used to delay the probe for
25 // responsiveness. 26 // responsiveness.
26 const double kBackoffMultiplier = 1.5; 27 const double kBackoffMultiplier = 1.5;
27 28
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 responsiveness_1sec_histogram_(NULL), 118 responsiveness_1sec_histogram_(NULL),
118 responsiveness_10sec_histogram_(NULL), 119 responsiveness_10sec_histogram_(NULL),
119 unresponsiveness_histogram_(NULL), 120 unresponsiveness_histogram_(NULL),
120 unresponsiveness_1sec_histogram_(NULL), 121 unresponsiveness_1sec_histogram_(NULL),
121 unresponsiveness_10sec_histogram_(NULL) { 122 unresponsiveness_10sec_histogram_(NULL) {
122 process_creation_time_ = base::CurrentProcessInfo::CreationTime(); 123 process_creation_time_ = base::CurrentProcessInfo::CreationTime();
123 InitHistograms(); 124 InitHistograms();
124 } 125 }
125 126
126 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() { 127 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() {
127 if (collected_paint_metric_) 128 if (collected_paint_metric_ ||
129 startup_metric_utils::WasNonBrowserUIDisplayed())
128 return; 130 return;
gab 2015/06/09 15:52:28 nit: Add {} when either conditional or body spans
129 131
130 collected_paint_metric_ = true; 132 collected_paint_metric_ = true;
131 if (!process_creation_time_.is_null()) { 133 if (!process_creation_time_.is_null()) {
132 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; 134 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_;
133 135
134 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.NonEmptyPaint", 136 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.NonEmptyPaint",
135 elapsed); 137 elapsed);
136 } 138 }
137 139
138 metrics::TrackingSynchronizer::OnProfilingPhaseCompleted( 140 metrics::TrackingSynchronizer::OnProfilingPhaseCompleted(
(...skipping 13 matching lines...) Expand all
152 unresponsiveness_1sec_histogram_), 154 unresponsiveness_1sec_histogram_),
153 base::TimeDelta::FromSeconds(1)); 155 base::TimeDelta::FromSeconds(1));
154 156
155 base::MessageLoop::current()->PostDelayedTask( 157 base::MessageLoop::current()->PostDelayedTask(
156 FROM_HERE, 158 FROM_HERE,
157 base::Bind(&MeasureUIResponsiveness, responsiveness_10sec_histogram_, 159 base::Bind(&MeasureUIResponsiveness, responsiveness_10sec_histogram_,
158 unresponsiveness_10sec_histogram_), 160 unresponsiveness_10sec_histogram_),
159 base::TimeDelta::FromSeconds(10)); 161 base::TimeDelta::FromSeconds(10));
160 162
161 if (IsFinishedCollectingMetrics()) 163 if (IsFinishedCollectingMetrics())
162 FinishedCollectingMetrics(); 164 FinishedCollectingMetrics();
gab 2015/06/09 15:52:28 We should call FinishedCollectingMetrics() right a
163 } 165 }
164 166
165 void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() { 167 void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() {
166 if (collected_load_metric_) 168 if (collected_paint_metric_ ||
169 startup_metric_utils::WasNonBrowserUIDisplayed())
167 return; 170 return;
168 171
169 collected_load_metric_ = true; 172 collected_load_metric_ = true;
170 if (!process_creation_time_.is_null()) { 173 if (!process_creation_time_.is_null()) {
171 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; 174 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_;
172 175
173 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.MainFrameLoad", 176 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.MainFrameLoad",
174 elapsed); 177 elapsed);
175 } 178 }
176 179
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 100, base::Histogram::kUmaTargetedHistogramFlag); 230 100, base::Histogram::kUmaTargetedHistogramFlag);
228 231
229 const std::string unresponsiveness_10sec_histogram_name = 232 const std::string unresponsiveness_10sec_histogram_name =
230 "Startup.FirstWebContents.UINotResponsive_10sec"; 233 "Startup.FirstWebContents.UINotResponsive_10sec";
231 unresponsiveness_10sec_histogram_ = base::Histogram::FactoryTimeGet( 234 unresponsiveness_10sec_histogram_ = base::Histogram::FactoryTimeGet(
232 unresponsiveness_10sec_histogram_name, 235 unresponsiveness_10sec_histogram_name,
233 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(60), 236 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(60),
234 100, base::Histogram::kUmaTargetedHistogramFlag); 237 100, base::Histogram::kUmaTargetedHistogramFlag);
235 } 238 }
236 #endif // !defined(OS_ANDROID) 239 #endif // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/simple_message_box_mac.mm » ('j') | chrome/browser/ui/profile_error_browsertest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698