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 86fd62067fc4039e35f52940c4372c8bfc2e93db..69de1bd51a4be0714df6db48a9affd259427fc45 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 { |
@@ -120,6 +122,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), |
delegate_(delegate), |
responsiveness_histogram_(NULL), |
responsiveness_1sec_histogram_(NULL), |
@@ -183,6 +187,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( |
clamy
2015/10/28 11:55:59
I think this can be merged inside DidFinishNavigat
gab
2015/10/28 20:17:38
Awesome, done :-)! (also added IsMainFrame() to th
Charlie Reis
2015/10/28 20:58:26
IsSamePage means you haven't left the current docu
|
const content::LoadCommittedDetails& load_details) { |
// Abandon profiling on any navigation to a different page as it: |
@@ -193,7 +237,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; |
} |