Chromium Code Reviews| Index: chrome/browser/prerender/prerender_manager.h |
| diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h |
| index ee4bf7f2ff1fb9cb782c31ddd4a59ef4c8c6da70..3ac49e451f08aad5e97006cb6b246fdebbdc22fa 100644 |
| --- a/chrome/browser/prerender/prerender_manager.h |
| +++ b/chrome/browser/prerender/prerender_manager.h |
| @@ -103,6 +103,12 @@ class PrerenderManager : public content::NotificationObserver, |
| CLEAR_MAX = 0x1 << 2 |
| }; |
| + // Observer interface for PrerenderManager events. |
| + class Observer { |
|
pasko
2016/11/17 19:52:16
A toplevel class PrerenderManagerObserver is prefe
mattcary
2016/11/18 09:21:11
Done.
I was copying what PrerenderContents was do
|
| + public: |
| + virtual void OnFirstContentfulPaint() = 0; |
|
pasko
2016/11/17 19:52:16
should have a comment saying on which thread all t
mattcary
2016/11/18 09:21:11
Done.
|
| + }; |
| + |
| // Owned by a Profile object for the lifetime of the profile. |
| explicit PrerenderManager(Profile* profile); |
| ~PrerenderManager() override; |
| @@ -219,13 +225,18 @@ class PrerenderManager : public content::NotificationObserver, |
| bool is_main_resource, |
| int redirect_count); |
| - // Records the time to first contentful paint. |
| + // Records the time to first contentful paint for no state prefetch loads. |
|
pasko
2016/11/17 19:52:16
is it rather for loads that were recently prefetch
mattcary
2016/11/18 09:21:11
Done.
|
| // 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); |
| + void RecordNoStateFirstContentfulPaint(const GURL& url, |
| + bool is_no_store, |
| + base::TimeDelta time); |
| + |
| + // Records the perceived first contentful paint time for a prerendered page, |
| + // analogous to |RecordPerceivedPageLoadTime|. |
| + void RecordPerceivedFirstContentfulPaint(content::WebContents* web_contents, |
| + base::TimeDelta time); |
| static PrerenderManagerMode GetMode(); |
| static void SetMode(PrerenderManagerMode mode); |
| @@ -329,6 +340,16 @@ class PrerenderManager : public content::NotificationObserver, |
| void SetTickClockForTesting( |
| std::unique_ptr<base::SimpleTestTickClock> tick_clock); |
| + void DisablePageLoadMetricsObserverForTesting() { |
|
pasko
2016/11/17 19:52:16
I see a few tests calling this, does something bre
mattcary
2016/11/18 09:21:11
Yes, if it's not disabled there will be a race bet
Bryan McQuade
2016/11/18 14:52:37
You do get a bit less complete test coverage this
mattcary
2016/11/18 15:14:13
We already have logging of the histogram counts el
|
| + page_load_metric_observer_disabled_ = true; |
| + } |
| + |
| + bool PageLoadMetricsObserverDisabledForTesting() const { |
| + return page_load_metric_observer_disabled_; |
| + } |
| + |
| + void AddObserver(std::unique_ptr<Observer> observer); |
| + |
| // Notification that a prerender has completed and its bytes should be |
| // recorded. |
| void RecordNetworkBytes(Origin origin, bool used, int64_t prerender_bytes); |
| @@ -610,6 +631,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<Observer>> observers_; |
| + |
| base::WeakPtrFactory<PrerenderManager> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |