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

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: Using DidFinishNavigation() 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 a95ff37d65df883ea517cd442d3dd8f612f1e33f..c6c25d14eb306a5b1efa24fcd2ce6c3f5ab76f26 100644
--- a/chrome/browser/metrics/first_web_contents_profiler.cc
+++ b/chrome/browser/metrics/first_web_contents_profiler.cc
@@ -22,6 +22,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 +117,9 @@ 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),
+ collected_main_navigation_finished_all_metric_(false),
responsiveness_histogram_(NULL),
responsiveness_1sec_histogram_(NULL),
responsiveness_10sec_histogram_(NULL),
@@ -125,6 +129,9 @@ FirstWebContentsProfiler::FirstWebContentsProfiler(
InitHistograms();
}
+FirstWebContentsProfiler::~FirstWebContentsProfiler() {
+}
+
void FirstWebContentsProfiler::DidFirstVisuallyNonEmptyPaint() {
if (collected_paint_metric_)
return;
@@ -178,6 +185,62 @@ void FirstWebContentsProfiler::DocumentOnLoadCompletedInMainFrame() {
FinishedCollectingMetrics(FinishReason::DONE);
}
+void FirstWebContentsProfiler::DidStartNavigation(
+ content::NavigationHandle* navigation_handle) {
+ if (startup_metric_utils::WasNonBrowserUIDisplayed()) {
+ FinishedCollectingMetrics(FinishReason::ABANDON_BLOCKING_UI);
+ return;
+ }
+
+ if (!navigation_handle->IsInMainFrame())
+ return;
+
+ // Record that the navigation identified by |navigation_handle| has started.
+ // DidFinishNavigation() assumes that every |navigation_handle| seen here is a
+ // new navigation, assert that this is true.
+ bool new_navigation =
+ main_navigation_handles_.insert(navigation_handle).second;
+ DCHECK(new_navigation);
+
+ if (!collected_main_navigation_start_metric_) {
+ 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_all_metric_)
+ return;
+
+ if (startup_metric_utils::WasNonBrowserUIDisplayed()) {
+ FinishedCollectingMetrics(FinishReason::ABANDON_BLOCKING_UI);
+ return;
+ }
+
+ if (!navigation_handle->IsInMainFrame())
+ return;
clamy 2015/10/22 17:21:07 You may also need to check whether the navigation
gab 2015/10/22 20:37:39 Good point, even added it as an explicit early exi
+
+ // Remove |navigation_handle| from the tracked |main_navigation_handles_|.
+ size_t handles_tracked = main_navigation_handles_.erase(navigation_handle);
+ DCHECK_EQ(handles_tracked, 1U);
+
+ // First navigation in main frame is complete.
+ if (!collected_main_navigation_finished_metric_) {
+ collected_main_navigation_finished_metric_ = true;
+ startup_metric_utils::RecordFirstWebContentsMainNavigationFinishedFirst(
+ base::Time::Now());
+ }
+
+ // All known navigations in main frame are complete.
+ if (main_navigation_handles_.empty()) {
+ collected_main_navigation_finished_all_metric_ = true;
+ startup_metric_utils::RecordFirstWebContentsMainNavigationFinishedAll(
clamy 2015/10/22 17:21:07 I don't think this is really needed. While it's t
gab 2015/10/22 20:37:39 Ah ok, maybe this should be made clearer in WebCon
+ base::Time::Now());
+ }
+}
+
void FirstWebContentsProfiler::NavigationEntryCommitted(
const content::LoadCommittedDetails& load_details) {
// Abandon profiling on any navigation to a different page as it:
« 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