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

Unified Diff: chrome/browser/prerender/prerender_manager.h

Issue 2423383002: [Prerender] first contentful paint histograms. (Closed)
Patch Set: comments Created 4 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: chrome/browser/prerender/prerender_manager.h
diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h
index 428c3a7b733ae870bbfdfd5b432a002b9cb3ca65..8b3b76e9939fb03e54a3ab5240d14b0d048d874a 100644
--- a/chrome/browser/prerender/prerender_manager.h
+++ b/chrome/browser/prerender/prerender_manager.h
@@ -65,6 +65,15 @@ class PrerenderInProcessBrowserTest;
class PrerenderHandle;
class PrerenderHistory;
+// Observer interface for PrerenderManager events.
+class PrerenderManagerObserver {
+ public:
+ virtual ~PrerenderManagerObserver();
+
+ // Called from the UI thread.
+ virtual void OnFirstContentfulPaint() = 0;
+};
+
// PrerenderManager is responsible for initiating and keeping prerendered
// views of web pages. All methods must be called on the UI thread unless
// indicated otherwise.
@@ -206,13 +215,31 @@ class PrerenderManager : public content::NotificationObserver,
bool is_main_resource,
int redirect_count);
- // Records the time to first contentful paint.
- // Must not be called for prefetch loads (which are never rendered anyway).
- // |is_no_store| must be true if the main resource has a "no-store" cache
- // control HTTP header.
- void RecordFirstContentfulPaint(const GURL& url,
- bool is_no_store,
- base::TimeDelta time);
+ // Called when a NoStatePrefetch first contentful paint has fired.
+ void RecordPrefetchFirstContentfulPaint(Origin origin,
+ bool is_no_store,
+ bool was_hidden,
+ base::TimeDelta time,
+ base::TimeDelta prefetch_age);
+
+ // Records the time to first contentful paint for loads that previously had a
+ // no state prefetch load. Must not be called for prefetch loads themselves
+ // (which are never rendered anyway). |is_no_store| must be true if the main
+ // resource has a "no-store" cache control HTTP header.
+ void RecordNoStateFirstContentfulPaint(const GURL& url,
+ bool is_no_store,
+ bool was_hidden,
+ base::TimeDelta time);
+
+ // Records the perceived first contentful paint time for a prerendered page,
+ // analogous to |RecordPerceivedPageLoadTime|. The FCP ticks is in absolute
+ // time; this has the disadvantage that the histogram will mix browser and
+ // renderer ticks, but there seems to be no way around that.
+ void RecordPrerenderFirstContentfulPaint(const GURL& url,
+ content::WebContents* web_contents,
+ bool is_no_store,
+ bool was_hidden,
+ base::TimeTicks ticks);
static PrerenderManagerMode GetMode();
static void SetMode(PrerenderManagerMode mode);
@@ -314,6 +341,16 @@ class PrerenderManager : public content::NotificationObserver,
void SetTickClockForTesting(
std::unique_ptr<base::SimpleTestTickClock> tick_clock);
+ void DisablePageLoadMetricsObserverForTesting() {
+ page_load_metric_observer_disabled_ = true;
+ }
+
+ bool PageLoadMetricsObserverDisabledForTesting() const {
+ return page_load_metric_observer_disabled_;
+ }
+
+ void AddObserver(std::unique_ptr<PrerenderManagerObserver> observer);
pasko 2016/12/20 19:33:34 This method is used only for testing afaict. If it
+
// Notification that a prerender has completed and its bytes should be
// recorded.
void RecordNetworkBytes(Origin origin, bool used, int64_t prerender_bytes);
@@ -502,6 +539,11 @@ class PrerenderManager : public content::NotificationObserver,
// so cannot immediately be deleted.
void DeleteOldWebContents();
+ // Get information associated with a possible prefetch of |url|.
+ void GetPrefetchInformation(const GURL& url,
+ base::TimeDelta* prefetch_age,
+ Origin* origin);
+
// Cleans up old NavigationRecord's.
void CleanUpOldNavigations(std::vector<NavigationRecord>* navigations,
base::TimeDelta max_age);
@@ -597,6 +639,10 @@ class PrerenderManager : public content::NotificationObserver,
std::unique_ptr<base::Clock> clock_;
std::unique_ptr<base::TickClock> tick_clock_;
+ bool page_load_metric_observer_disabled_;
+
+ std::vector<std::unique_ptr<PrerenderManagerObserver>> observers_;
+
base::WeakPtrFactory<PrerenderManager> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PrerenderManager);

Powered by Google App Engine
This is Rietveld 408576698