| OLD | NEW |
| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_) |
| 128 return; | 129 return; |
| 130 if (startup_metric_utils::WasNonBrowserUIDisplayed()) { |
| 131 FinishedCollectingMetrics(); |
| 132 return; |
| 133 } |
| 129 | 134 |
| 130 collected_paint_metric_ = true; | 135 collected_paint_metric_ = true; |
| 131 if (!process_creation_time_.is_null()) { | 136 if (!process_creation_time_.is_null()) { |
| 132 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; | 137 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; |
| 133 | 138 |
| 134 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.NonEmptyPaint", | 139 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.NonEmptyPaint", |
| 135 elapsed); | 140 elapsed); |
| 136 } | 141 } |
| 137 | 142 |
| 138 metrics::TrackingSynchronizer::OnProfilingPhaseCompleted( | 143 metrics::TrackingSynchronizer::OnProfilingPhaseCompleted( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 158 unresponsiveness_10sec_histogram_), | 163 unresponsiveness_10sec_histogram_), |
| 159 base::TimeDelta::FromSeconds(10)); | 164 base::TimeDelta::FromSeconds(10)); |
| 160 | 165 |
| 161 if (IsFinishedCollectingMetrics()) | 166 if (IsFinishedCollectingMetrics()) |
| 162 FinishedCollectingMetrics(); | 167 FinishedCollectingMetrics(); |
| 163 } | 168 } |
| 164 | 169 |
| 165 void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() { | 170 void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() { |
| 166 if (collected_load_metric_) | 171 if (collected_load_metric_) |
| 167 return; | 172 return; |
| 173 if (startup_metric_utils::WasNonBrowserUIDisplayed()) { |
| 174 FinishedCollectingMetrics(); |
| 175 return; |
| 176 } |
| 168 | 177 |
| 169 collected_load_metric_ = true; | 178 collected_load_metric_ = true; |
| 170 if (!process_creation_time_.is_null()) { | 179 if (!process_creation_time_.is_null()) { |
| 171 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; | 180 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; |
| 172 | 181 |
| 173 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.MainFrameLoad", | 182 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.MainFrameLoad", |
| 174 elapsed); | 183 elapsed); |
| 175 } | 184 } |
| 176 | 185 |
| 177 if (IsFinishedCollectingMetrics()) | 186 if (IsFinishedCollectingMetrics()) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 100, base::Histogram::kUmaTargetedHistogramFlag); | 236 100, base::Histogram::kUmaTargetedHistogramFlag); |
| 228 | 237 |
| 229 const std::string unresponsiveness_10sec_histogram_name = | 238 const std::string unresponsiveness_10sec_histogram_name = |
| 230 "Startup.FirstWebContents.UINotResponsive_10sec"; | 239 "Startup.FirstWebContents.UINotResponsive_10sec"; |
| 231 unresponsiveness_10sec_histogram_ = base::Histogram::FactoryTimeGet( | 240 unresponsiveness_10sec_histogram_ = base::Histogram::FactoryTimeGet( |
| 232 unresponsiveness_10sec_histogram_name, | 241 unresponsiveness_10sec_histogram_name, |
| 233 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(60), | 242 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(60), |
| 234 100, base::Histogram::kUmaTargetedHistogramFlag); | 243 100, base::Histogram::kUmaTargetedHistogramFlag); |
| 235 } | 244 } |
| 236 #endif // !defined(OS_ANDROID) | 245 #endif // !defined(OS_ANDROID) |
| OLD | NEW |