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

Unified Diff: chrome/browser/prerender/prerender_test_utils.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_test_utils.h
diff --git a/chrome/browser/prerender/prerender_test_utils.h b/chrome/browser/prerender/prerender_test_utils.h
index dac536759737441a66807d202e570dbf7160fe08..9ee89cae8aeac59e571379c535063e2f0d574798 100644
--- a/chrome/browser/prerender/prerender_test_utils.h
+++ b/chrome/browser/prerender/prerender_test_utils.h
@@ -17,6 +17,7 @@
#include "base/run_loop.h"
#include "base/test/histogram_tester.h"
#include "chrome/browser/external_protocol/external_protocol_handler.h"
+#include "chrome/browser/page_load_metrics/observers/prerender_page_load_metrics_observer.h"
#include "chrome/browser/prerender/prerender_contents.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
@@ -237,6 +238,27 @@ class DestructionWaiter {
DISALLOW_COPY_AND_ASSIGN(DestructionWaiter);
};
+// Wait until a PrerenderManager has seen a first contentful paint.
+class FirstContentfulPaintManagerWaiter : public PrerenderManagerObserver {
+ public:
+ // Create and return a pointer to a |FirstContentfulPaintManagerWaiter|. The
+ // instance is owned by the |PrerenderManager|.
+ static FirstContentfulPaintManagerWaiter* Create(PrerenderManager* manager);
+
+ ~FirstContentfulPaintManagerWaiter() override;
+
+ void OnFirstContentfulPaint() override;
+
+ // Wait for a first contentful paint to be seen by our PrerenderManager.
+ void Wait();
+
+ private:
+ FirstContentfulPaintManagerWaiter();
+
+ std::unique_ptr<base::RunLoop> waiter_;
+ bool saw_fcp_;
+};
pasko 2016/12/20 19:33:34 nit: DISALLOW_COPY_AND_ASSIGN?
mattcary 2016/12/21 17:08:58 Done.
+
// PrerenderContentsFactory that uses TestPrerenderContents.
class TestPrerenderContentsFactory : public PrerenderContents::Factory {
public:
@@ -363,6 +385,17 @@ class PrerenderInProcessBrowserTest : virtual public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(PrerenderInProcessBrowserTest);
};
+// A test observer that allows the observed navigation start time to be set.
+class TestPrerenderPageLoadMetricsObserver
+ : public PrerenderPageLoadMetricsObserver {
+ public:
+ using PrerenderPageLoadMetricsObserver::PrerenderPageLoadMetricsObserver;
pasko 2016/12/20 19:33:34 thanks for letting me know about inherited constru
mattcary 2016/12/21 17:08:58 Ack I think it was actually from digit@ and notes
+
+ void SetNavigationStartTo(base::TimeTicks ticks) {
+ SetNavigationStartTicksForTesting(ticks);
pasko 2016/12/20 19:33:34 The only thing this class does is forwarding to th
mattcary 2016/12/21 17:08:59 It seems to be common to hide testing code with pr
pasko 2016/12/21 18:39:09 Ah, now I see where it is coming from. I think it
mattcary 2016/12/22 10:49:07 Acknowledged.
+ }
+};
pasko 2016/12/20 19:33:34 nit: DISALLOW_COPY_AND_ASSIGN?
mattcary 2016/12/21 17:08:59 Done.
+
// Makes |url| respond to requests with the contents of |file|, counting the
// number that start in |counter|.
void CreateCountingInterceptorOnIO(

Powered by Google App Engine
This is Rietveld 408576698