| 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 <string> |
| 10 |
| 9 #include "base/location.h" | 11 #include "base/location.h" |
| 10 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/process/process_info.h" | 13 #include "base/process/process_info.h" |
| 12 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 14 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 15 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_iterator.h" | 18 #include "chrome/browser/ui/browser_iterator.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "components/metrics/profiler/tracking_synchronizer.h" | 20 #include "components/metrics/profiler/tracking_synchronizer.h" |
| 19 #include "components/metrics/proto/profiler_event.pb.h" | 21 #include "components/metrics/proto/profiler_event.pb.h" |
| 22 #include "components/startup_metric_utils/startup_metric_utils.h" |
| 20 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 21 | 24 |
| 22 namespace { | 25 namespace { |
| 23 // The initial delay for responsiveness prober in milliseconds. | 26 // The initial delay for responsiveness prober in milliseconds. |
| 24 const int kInitialDelayMs = 20; | 27 const int kInitialDelayMs = 20; |
| 25 | 28 |
| 26 // The following is the multiplier is used to delay the probe for | 29 // The following is the multiplier is used to delay the probe for |
| 27 // responsiveness. | 30 // responsiveness. |
| 28 const double kBackoffMultiplier = 1.5; | 31 const double kBackoffMultiplier = 1.5; |
| 29 | 32 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 unresponsiveness_histogram_(NULL), | 124 unresponsiveness_histogram_(NULL), |
| 122 unresponsiveness_1sec_histogram_(NULL), | 125 unresponsiveness_1sec_histogram_(NULL), |
| 123 unresponsiveness_10sec_histogram_(NULL) { | 126 unresponsiveness_10sec_histogram_(NULL) { |
| 124 process_creation_time_ = base::CurrentProcessInfo::CreationTime(); | 127 process_creation_time_ = base::CurrentProcessInfo::CreationTime(); |
| 125 InitHistograms(); | 128 InitHistograms(); |
| 126 } | 129 } |
| 127 | 130 |
| 128 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() { | 131 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() { |
| 129 if (collected_paint_metric_) | 132 if (collected_paint_metric_) |
| 130 return; | 133 return; |
| 134 if (startup_metric_utils::WasNonBrowserUIDisplayed()) { |
| 135 FinishedCollectingMetrics(); |
| 136 return; |
| 137 } |
| 131 | 138 |
| 132 collected_paint_metric_ = true; | 139 collected_paint_metric_ = true; |
| 133 if (!process_creation_time_.is_null()) { | 140 if (!process_creation_time_.is_null()) { |
| 134 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; | 141 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; |
| 135 | 142 |
| 136 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.NonEmptyPaint", | 143 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.NonEmptyPaint", |
| 137 elapsed); | 144 elapsed); |
| 138 } | 145 } |
| 139 | 146 |
| 140 metrics::TrackingSynchronizer::OnProfilingPhaseCompleted( | 147 metrics::TrackingSynchronizer::OnProfilingPhaseCompleted( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 160 unresponsiveness_10sec_histogram_), | 167 unresponsiveness_10sec_histogram_), |
| 161 base::TimeDelta::FromSeconds(10)); | 168 base::TimeDelta::FromSeconds(10)); |
| 162 | 169 |
| 163 if (IsFinishedCollectingMetrics()) | 170 if (IsFinishedCollectingMetrics()) |
| 164 FinishedCollectingMetrics(); | 171 FinishedCollectingMetrics(); |
| 165 } | 172 } |
| 166 | 173 |
| 167 void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() { | 174 void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() { |
| 168 if (collected_load_metric_) | 175 if (collected_load_metric_) |
| 169 return; | 176 return; |
| 177 if (startup_metric_utils::WasNonBrowserUIDisplayed()) { |
| 178 FinishedCollectingMetrics(); |
| 179 return; |
| 180 } |
| 170 | 181 |
| 171 collected_load_metric_ = true; | 182 collected_load_metric_ = true; |
| 172 if (!process_creation_time_.is_null()) { | 183 if (!process_creation_time_.is_null()) { |
| 173 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; | 184 base::TimeDelta elapsed = base::Time::Now() - process_creation_time_; |
| 174 | 185 |
| 175 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.MainFrameLoad", | 186 UMA_HISTOGRAM_LONG_TIMES_100("Startup.FirstWebContents.MainFrameLoad", |
| 176 elapsed); | 187 elapsed); |
| 177 } | 188 } |
| 178 | 189 |
| 179 if (IsFinishedCollectingMetrics()) | 190 if (IsFinishedCollectingMetrics()) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 100, base::Histogram::kUmaTargetedHistogramFlag); | 240 100, base::Histogram::kUmaTargetedHistogramFlag); |
| 230 | 241 |
| 231 const std::string unresponsiveness_10sec_histogram_name = | 242 const std::string unresponsiveness_10sec_histogram_name = |
| 232 "Startup.FirstWebContents.UINotResponsive_10sec"; | 243 "Startup.FirstWebContents.UINotResponsive_10sec"; |
| 233 unresponsiveness_10sec_histogram_ = base::Histogram::FactoryTimeGet( | 244 unresponsiveness_10sec_histogram_ = base::Histogram::FactoryTimeGet( |
| 234 unresponsiveness_10sec_histogram_name, | 245 unresponsiveness_10sec_histogram_name, |
| 235 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(60), | 246 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(60), |
| 236 100, base::Histogram::kUmaTargetedHistogramFlag); | 247 100, base::Histogram::kUmaTargetedHistogramFlag); |
| 237 } | 248 } |
| 238 #endif // !defined(OS_ANDROID) | 249 #endif // !defined(OS_ANDROID) |
| OLD | NEW |