| Index: chrome/browser/metrics/first_web_contents_profiler.cc
|
| diff --git a/chrome/browser/metrics/first_web_contents_profiler.cc b/chrome/browser/metrics/first_web_contents_profiler.cc
|
| index a95ff37d65df883ea517cd442d3dd8f612f1e33f..faa688f97ede2616c6cca7db78468222c79ded8b 100644
|
| --- a/chrome/browser/metrics/first_web_contents_profiler.cc
|
| +++ b/chrome/browser/metrics/first_web_contents_profiler.cc
|
| @@ -9,6 +9,7 @@
|
| #include <string>
|
|
|
| #include "base/location.h"
|
| +#include "base/logging.h"
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/process/process_info.h"
|
| #include "base/single_thread_task_runner.h"
|
| @@ -22,6 +23,7 @@
|
| #include "components/startup_metric_utils/startup_metric_utils.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/navigation_details.h"
|
| +#include "content/public/browser/navigation_handle.h"
|
|
|
| namespace {
|
|
|
| @@ -116,6 +118,8 @@ FirstWebContentsProfiler::FirstWebContentsProfiler(
|
| initial_entry_committed_(false),
|
| collected_paint_metric_(false),
|
| collected_load_metric_(false),
|
| + collected_main_navigation_start_metric_(false),
|
| + collected_main_navigation_finished_metric_(false),
|
| responsiveness_histogram_(NULL),
|
| responsiveness_1sec_histogram_(NULL),
|
| responsiveness_10sec_histogram_(NULL),
|
| @@ -178,6 +182,46 @@ void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() {
|
| FinishedCollectingMetrics(FinishReason::DONE);
|
| }
|
|
|
| +void FirstWebContentsProfiler::DidStartNavigation(
|
| + content::NavigationHandle* navigation_handle) {
|
| + if (collected_main_navigation_start_metric_)
|
| + return;
|
| + if (startup_metric_utils::WasNonBrowserUIDisplayed()) {
|
| + FinishedCollectingMetrics(FinishReason::ABANDON_BLOCKING_UI);
|
| + return;
|
| + }
|
| +
|
| + // The first navigation has to be the main frame's.
|
| + DCHECK(navigation_handle->IsInMainFrame());
|
| +
|
| + collected_main_navigation_start_metric_ = true;
|
| + startup_metric_utils::RecordFirstWebContentsMainNavigationStart(
|
| + base::Time::Now());
|
| +}
|
| +
|
| +void FirstWebContentsProfiler::DidFinishNavigation(
|
| + content::NavigationHandle* navigation_handle) {
|
| + if (collected_main_navigation_finished_metric_)
|
| + return;
|
| + if (startup_metric_utils::WasNonBrowserUIDisplayed()) {
|
| + FinishedCollectingMetrics(FinishReason::ABANDON_BLOCKING_UI);
|
| + return;
|
| + }
|
| +
|
| + // The first navigation has to be the main frame's.
|
| + DCHECK(navigation_handle->IsInMainFrame());
|
| +
|
| + if (!navigation_handle->HasCommitted() ||
|
| + navigation_handle->IsErrorPage()) {
|
| + FinishedCollectingMetrics(FinishReason::ABANDON_NAVIGATION_ERROR);
|
| + return;
|
| + }
|
| +
|
| + collected_main_navigation_finished_metric_ = true;
|
| + startup_metric_utils::RecordFirstWebContentsMainNavigationFinished(
|
| + base::Time::Now());
|
| +}
|
| +
|
| void FirstWebContentsProfiler::NavigationEntryCommitted(
|
| const content::LoadCommittedDetails& load_details) {
|
| // Abandon profiling on any navigation to a different page as it:
|
| @@ -188,7 +232,7 @@ void FirstWebContentsProfiler::NavigationEntryCommitted(
|
| // page that does trigger it.
|
| if (load_details.is_navigation_to_different_page()) {
|
| if (initial_entry_committed_)
|
| - FinishedCollectingMetrics(FinishReason::ABANDON_NAVIGATION);
|
| + FinishedCollectingMetrics(FinishReason::ABANDON_NEW_NAVIGATION);
|
| else
|
| initial_entry_committed_ = true;
|
| }
|
|
|