| OLD | NEW |
| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 void MarkDestruction(FinalStatus reason); | 230 void MarkDestruction(FinalStatus reason); |
| 231 | 231 |
| 232 base::RunLoop wait_loop_; | 232 base::RunLoop wait_loop_; |
| 233 FinalStatus expected_final_status_; | 233 FinalStatus expected_final_status_; |
| 234 bool saw_correct_status_; | 234 bool saw_correct_status_; |
| 235 std::unique_ptr<DestructionMarker> marker_; | 235 std::unique_ptr<DestructionMarker> marker_; |
| 236 | 236 |
| 237 DISALLOW_COPY_AND_ASSIGN(DestructionWaiter); | 237 DISALLOW_COPY_AND_ASSIGN(DestructionWaiter); |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 // Wait until a PrerenderManager has seen a first contentful paint. |
| 241 class FirstContentfulPaintManagerWaiter : public PrerenderManagerObserver { |
| 242 public: |
| 243 // Create and return a pointer to a |FirstContentfulPaintManagerWaiter|. The |
| 244 // instance is owned by the |PrerenderManager|. |
| 245 static FirstContentfulPaintManagerWaiter* Create(PrerenderManager* manager); |
| 246 |
| 247 ~FirstContentfulPaintManagerWaiter() override; |
| 248 |
| 249 void OnFirstContentfulPaint() override; |
| 250 |
| 251 // Wait for a first contentful paint to be seen by our PrerenderManager. |
| 252 void Wait(); |
| 253 |
| 254 private: |
| 255 FirstContentfulPaintManagerWaiter(); |
| 256 |
| 257 std::unique_ptr<base::RunLoop> waiter_; |
| 258 bool saw_fcp_; |
| 259 |
| 260 DISALLOW_COPY_AND_ASSIGN(FirstContentfulPaintManagerWaiter); |
| 261 }; |
| 262 |
| 240 // PrerenderContentsFactory that uses TestPrerenderContents. | 263 // PrerenderContentsFactory that uses TestPrerenderContents. |
| 241 class TestPrerenderContentsFactory : public PrerenderContents::Factory { | 264 class TestPrerenderContentsFactory : public PrerenderContents::Factory { |
| 242 public: | 265 public: |
| 243 TestPrerenderContentsFactory(); | 266 TestPrerenderContentsFactory(); |
| 244 | 267 |
| 245 ~TestPrerenderContentsFactory() override; | 268 ~TestPrerenderContentsFactory() override; |
| 246 | 269 |
| 247 std::unique_ptr<TestPrerender> ExpectPrerenderContents( | 270 std::unique_ptr<TestPrerender> ExpectPrerenderContents( |
| 248 FinalStatus final_status); | 271 FinalStatus final_status); |
| 249 | 272 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 // |file| afterwards. When the first load has been scheduled, runs |callback| on | 408 // |file| afterwards. When the first load has been scheduled, runs |callback| on |
| 386 // the UI thread. | 409 // the UI thread. |
| 387 void CreateHangingFirstRequestInterceptorOnIO( | 410 void CreateHangingFirstRequestInterceptorOnIO( |
| 388 const GURL& url, const base::FilePath& file, base::Closure callback); | 411 const GURL& url, const base::FilePath& file, base::Closure callback); |
| 389 | 412 |
| 390 } // namespace test_utils | 413 } // namespace test_utils |
| 391 | 414 |
| 392 } // namespace prerender | 415 } // namespace prerender |
| 393 | 416 |
| 394 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_ | 417 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_ |
| OLD | NEW |