Chromium Code Reviews| 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 #include "chrome/browser/metrics/first_web_contents_profiler.h" | 5 #include "chrome/browser/metrics/first_web_contents_profiler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "components/metrics/profiler/tracking_synchronizer.h" | 18 #include "components/metrics/profiler/tracking_synchronizer.h" |
| 19 #include "components/metrics/proto/profiler_event.pb.h" | 19 #include "components/metrics/proto/profiler_event.pb.h" |
| 20 #include "components/startup_metric_utils/browser/startup_metric_utils.h" | 20 #include "components/startup_metric_utils/browser/startup_metric_utils.h" |
| 21 #include "content/public/browser/navigation_handle.h" | 21 #include "content/public/browser/navigation_handle.h" |
| 22 #include "content/public/browser/render_frame_host.h" | |
| 23 #include "content/public/browser/render_process_host.h" | |
| 22 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_observer.h" | 25 #include "content/public/browser/web_contents_observer.h" |
| 24 #include "content/public/common/browser_side_navigation_policy.h" | 26 #include "content/public/common/browser_side_navigation_policy.h" |
| 25 | 27 |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 class FirstWebContentsProfiler : public content::WebContentsObserver { | 30 class FirstWebContentsProfiler : public content::WebContentsObserver { |
| 29 public: | 31 public: |
| 30 FirstWebContentsProfiler(content::WebContents* web_contents, | 32 FirstWebContentsProfiler(content::WebContents* web_contents, |
| 31 startup_metric_utils::WebContentsWorkload workload); | 33 startup_metric_utils::WebContentsWorkload workload); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() { | 101 void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() { |
| 100 if (collected_paint_metric_) | 102 if (collected_paint_metric_) |
| 101 return; | 103 return; |
| 102 if (startup_metric_utils::WasMainWindowStartupInterrupted()) { | 104 if (startup_metric_utils::WasMainWindowStartupInterrupted()) { |
| 103 FinishedCollectingMetrics(FinishReason::ABANDON_BLOCKING_UI); | 105 FinishedCollectingMetrics(FinishReason::ABANDON_BLOCKING_UI); |
| 104 return; | 106 return; |
| 105 } | 107 } |
| 106 | 108 |
| 107 collected_paint_metric_ = true; | 109 collected_paint_metric_ = true; |
| 108 startup_metric_utils::RecordFirstWebContentsNonEmptyPaint( | 110 startup_metric_utils::RecordFirstWebContentsNonEmptyPaint( |
| 109 base::TimeTicks::Now()); | 111 base::TimeTicks::Now(), web_contents() |
| 112 ->GetMainFrame() | |
| 113 ->GetProcess() | |
| 114 ->GetInitTimeForNavigationMetrics()); | |
|
Bryan McQuade
2017/05/26 22:28:42
I notice that the comment for GetInitTimeForNaviga
hans
2017/05/31 19:48:57
I'm not familiar with PlzNagigate (looks like some
| |
| 110 | 115 |
| 111 metrics::TrackingSynchronizer::OnProfilingPhaseCompleted( | 116 metrics::TrackingSynchronizer::OnProfilingPhaseCompleted( |
| 112 metrics::ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT); | 117 metrics::ProfilerEventProto::EVENT_FIRST_NONEMPTY_PAINT); |
| 113 | 118 |
| 114 if (IsFinishedCollectingMetrics()) | 119 if (IsFinishedCollectingMetrics()) |
| 115 FinishedCollectingMetrics(FinishReason::DONE); | 120 FinishedCollectingMetrics(FinishReason::DONE); |
| 116 } | 121 } |
| 117 | 122 |
| 118 void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() { | 123 void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() { |
| 119 if (collected_load_metric_) | 124 if (collected_load_metric_) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 const bool single_tab = browser_list->size() == 1 && tab_strip->count() == 1; | 254 const bool single_tab = browser_list->size() == 1 && tab_strip->count() == 1; |
| 250 | 255 |
| 251 // FirstWebContentsProfiler owns itself and is also bound to | 256 // FirstWebContentsProfiler owns itself and is also bound to |
| 252 // |web_contents|'s lifetime by observing WebContentsDestroyed(). | 257 // |web_contents|'s lifetime by observing WebContentsDestroyed(). |
| 253 new FirstWebContentsProfiler(web_contents, | 258 new FirstWebContentsProfiler(web_contents, |
| 254 single_tab ? WebContentsWorkload::SINGLE_TAB | 259 single_tab ? WebContentsWorkload::SINGLE_TAB |
| 255 : WebContentsWorkload::MULTI_TABS); | 260 : WebContentsWorkload::MULTI_TABS); |
| 256 } | 261 } |
| 257 | 262 |
| 258 } // namespace metrics | 263 } // namespace metrics |
| OLD | NEW |