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

Unified Diff: components/page_load_metrics/browser/metrics_web_contents_observer.h

Issue 1476503004: [page_load_metrics] User Initiated Abort Tracking (Observer version) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_observer
Patch Set: Created 5 years 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: components/page_load_metrics/browser/metrics_web_contents_observer.h
diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer.h b/components/page_load_metrics/browser/metrics_web_contents_observer.h
index 524e1c01beef82435c40f99efa2e02853ec841e3..95e2130a57d8c4b22bfbe37cc23e5f6856720934 100644
--- a/components/page_load_metrics/browser/metrics_web_contents_observer.h
+++ b/components/page_load_metrics/browser/metrics_web_contents_observer.h
@@ -8,6 +8,7 @@
#include <map>
#include "base/macros.h"
+#include "base/memory/scoped_vector.h"
#include "base/observer_list.h"
#include "base/time/time.h"
#include "components/page_load_metrics/browser/page_load_metrics_observer.h"
@@ -72,6 +73,10 @@ const char kHistogramFirstBackground[] =
"PageLoad.Timing2.NavigationToFirstBackground";
const char kHistogramFirstForeground[] =
"PageLoad.Timing2.NavigationToFirstForeground";
+const char kHistogramBackgroundBeforePaint[] =
+ "PageLoad.Timing2.NavigationToFirstBackgroundBeforePaint";
+const char kHistogramProvisionalBackground[] =
+ "PageLoad.Timing2.Provisional.NavigationToFirstBackground";
const char kProvisionalEvents[] = "PageLoad.Events.Provisional";
const char kCommittedEvents[] = "PageLoad.Events.Committed";
@@ -224,14 +229,18 @@ class PageLoadTracker {
void AddObserver(scoped_ptr<PageLoadMetricsObserver> observer);
+ // If the user performs some abort-like action while we are tracking this page
+ // load, notify the tracker. Note that we may not classify this as an abort if
+ // we've already performed a first paint.
+ void NotifyAbort(UserAbortType abort_type, const base::TimeTicks& timestamp);
+
private:
PageLoadExtraInfo GetPageLoadMetricsInfo();
// Only valid to call post-commit.
const GURL& committed_url();
- base::TimeDelta GetBackgroundDelta();
- void RecordTimingHistograms();
- void RecordRappor();
+ void RecordTimingHistograms(const PageLoadExtraInfo& info);
+ void RecordRappor(const PageLoadExtraInfo& info);
// Whether the renderer should be sending timing IPCs to this page load.
bool renderer_tracked_;
@@ -241,6 +250,11 @@ class PageLoadTracker {
// The navigation start in TimeTicks, not the wall time reported by Blink.
const base::TimeTicks navigation_start_;
+ // Will be ABORT_NONE if we have not aborted this load yet. Otherwise will
+ // be the first abort action the user performed.
+ UserAbortType abort_type_;
+ base::TimeTicks abort_time_;
+
// We record separate metrics for events that occur after a background,
// because metrics like layout/paint are delayed artificially
// when they occur in the background.
@@ -285,15 +299,20 @@ class MetricsWebContentsObserver
content::NavigationHandle* navigation_handle) override;
void DidRedirectNavigation(
content::NavigationHandle* navigation_handle) override;
-
+ void NavigationStopped() override;
void WasShown() override;
void WasHidden() override;
-
void RenderProcessGone(base::TerminationStatus status) override;
private:
friend class content::WebContentsUserData<MetricsWebContentsObserver>;
+ // Notify all loads, provisional and committed, that we performed an action
+ // that might abort them.
+ void NotifyAbortAllLoads(UserAbortType abort_type);
+ void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type,
+ const base::TimeTicks& timestamp);
+
void OnTimingUpdated(content::RenderFrameHost*, const PageLoadTiming& timing);
// True if the web contents is currently in the foreground.
@@ -309,6 +328,12 @@ class MetricsWebContentsObserver
// valid until commit time, when we remove it from the map.
std::map<content::NavigationHandle*, scoped_ptr<PageLoadTracker>>
provisional_loads_;
+ // Tracks aborted provisional loads for a little bit longer than usual (one
+ // more navigation commit at the max), in order to better understand how the
+ // navigation failed. This is because most provisional loads are destroyed and
+ // vanish before we get signal about what caused the abort (new navigation,
+ // stop button, etc.).
+ ScopedVector<PageLoadTracker> aborted_provisional_loads_;
kinuko 2015/12/09 04:57:51 nit: vector<scoped_ptr<>> should work now
Charlie Harrison 2015/12/09 22:46:43 Done.
scoped_ptr<PageLoadTracker> committed_load_;
DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);

Powered by Google App Engine
This is Rietveld 408576698