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

Side by Side Diff: chrome/browser/prerender/prerender_test_utils.h

Issue 2423383002: [Prerender] first contentful paint histograms. (Closed)
Patch Set: comments Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_ 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_ 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <functional> 9 #include <functional>
10 #include <memory> 10 #include <memory>
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 void MarkDestruction(FinalStatus reason); 235 void MarkDestruction(FinalStatus reason);
236 236
237 base::RunLoop wait_loop_; 237 base::RunLoop wait_loop_;
238 FinalStatus expected_final_status_; 238 FinalStatus expected_final_status_;
239 bool saw_correct_status_; 239 bool saw_correct_status_;
240 std::unique_ptr<DestructionMarker> marker_; 240 std::unique_ptr<DestructionMarker> marker_;
241 241
242 DISALLOW_COPY_AND_ASSIGN(DestructionWaiter); 242 DISALLOW_COPY_AND_ASSIGN(DestructionWaiter);
243 }; 243 };
244 244
245 // Wait until a PrerenderManager has seen a first contentful paint.
246 class FirstContentfulPaintManagerWaiter : public PrerenderManagerObserver {
247 public:
248 // Create and return a pointer to a |FirstContentfulPaintManagerWaiter|. The
249 // instance is owned by the |PrerenderManager|.
250 static FirstContentfulPaintManagerWaiter* Create(PrerenderManager* manager);
251 ~FirstContentfulPaintManagerWaiter();
252
253 void OnFirstContentfulPaint() override;
254
255 // Wait for a first contentful paint to be seen by our PrerenderManager.
256 void Wait();
257
258 private:
259 FirstContentfulPaintManagerWaiter();
260
261 std::unique_ptr<base::RunLoop> waiter_;
262 bool saw_fcp_;
263 };
264
245 // PrerenderContentsFactory that uses TestPrerenderContents. 265 // PrerenderContentsFactory that uses TestPrerenderContents.
246 class TestPrerenderContentsFactory : public PrerenderContents::Factory { 266 class TestPrerenderContentsFactory : public PrerenderContents::Factory {
247 public: 267 public:
248 TestPrerenderContentsFactory(); 268 TestPrerenderContentsFactory();
249 269
250 ~TestPrerenderContentsFactory() override; 270 ~TestPrerenderContentsFactory() override;
251 271
252 std::unique_ptr<TestPrerender> ExpectPrerenderContents( 272 std::unique_ptr<TestPrerender> ExpectPrerenderContents(
253 FinalStatus final_status); 273 FinalStatus final_status);
254 274
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 const base::WeakPtr<RequestCounter>& counter); 396 const base::WeakPtr<RequestCounter>& counter);
377 397
378 // Makes |url| respond to requests with the contents of |file|. 398 // Makes |url| respond to requests with the contents of |file|.
379 void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file); 399 void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file);
380 400
381 } // namespace test_utils 401 } // namespace test_utils
382 402
383 } // namespace prerender 403 } // namespace prerender
384 404
385 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_ 405 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698