Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Unified Diff: chrome/browser/metrics/first_web_contents_profiler.cc

Issue 1407093003: Add start/finish navigation to startup metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a2_better_ownership_model_firstwebcontentsprofiler
Patch Set: rebase on trunk Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
« no previous file with comments | « chrome/browser/metrics/first_web_contents_profiler.h ('k') | components/startup_metric_utils/startup_metric_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698