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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 DISALLOW_COPY_AND_ASSIGN(PrerenderInProcessBrowserTest); | 363 DISALLOW_COPY_AND_ASSIGN(PrerenderInProcessBrowserTest); |
364 }; | 364 }; |
365 | 365 |
366 // Makes |url| respond to requests with the contents of |file|, counting the | 366 // Makes |url| respond to requests with the contents of |file|, counting the |
367 // number that start in |counter|. | 367 // number that start in |counter|. |
368 void CreateCountingInterceptorOnIO( | 368 void CreateCountingInterceptorOnIO( |
369 const GURL& url, | 369 const GURL& url, |
370 const base::FilePath& file, | 370 const base::FilePath& file, |
371 const base::WeakPtr<RequestCounter>& counter); | 371 const base::WeakPtr<RequestCounter>& counter); |
372 | 372 |
373 // Checks that |url| has been requested with net::LOAD_PREFETCH. Pings |counter| | 373 // When the |url| hits the net::URLRequestFilter (on the IO thread), executes |
374 // after the flag is checked. | 374 // the |callback_io| providing the request to it, also pings the |counter| on UI |
375 void CreatePrefetchOnlyInterceptorOnIO( | 375 // thread. Does not modify the behavior or the request job. |
| 376 void InterceptRequestAndCount( |
376 const GURL& url, | 377 const GURL& url, |
377 const base::WeakPtr<RequestCounter>& counter); | 378 RequestCounter* counter, |
| 379 base::Callback<void(net::URLRequest*)> callback_io); |
378 | 380 |
379 // Makes |url| respond to requests with the contents of |file|. | 381 // Makes |url| respond to requests with the contents of |file|. |
380 void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file); | 382 void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file); |
381 | 383 |
382 // Makes |url| never respond on the first load, and then with the contents of | 384 // Makes |url| never respond on the first load, and then with the contents of |
383 // |file| afterwards. When the first load has been scheduled, runs |callback| on | 385 // |file| afterwards. When the first load has been scheduled, runs |callback| on |
384 // the UI thread. | 386 // the UI thread. |
385 void CreateHangingFirstRequestInterceptorOnIO( | 387 void CreateHangingFirstRequestInterceptorOnIO( |
386 const GURL& url, const base::FilePath& file, base::Closure callback); | 388 const GURL& url, const base::FilePath& file, base::Closure callback); |
387 | 389 |
388 } // namespace test_utils | 390 } // namespace test_utils |
389 | 391 |
390 } // namespace prerender | 392 } // namespace prerender |
391 | 393 |
392 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_ | 394 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TEST_UTILS_H_ |
OLD | NEW |