| Index: chrome/browser/prerender/prerender_test_utils.cc
|
| diff --git a/chrome/browser/prerender/prerender_test_utils.cc b/chrome/browser/prerender/prerender_test_utils.cc
|
| index abded1130aa8f308e7d8cd03b5ef85343dab4949..5cd4402eab27784729705a2c2315b295998c2100 100644
|
| --- a/chrome/browser/prerender/prerender_test_utils.cc
|
| +++ b/chrome/browser/prerender/prerender_test_utils.cc
|
| @@ -177,12 +177,10 @@ class HangingURLRequestJob : public net::URLRequestJob {
|
|
|
| class HangingFirstRequestInterceptor : public net::URLRequestInterceptor {
|
| public:
|
| - HangingFirstRequestInterceptor(const base::FilePath& file,
|
| - base::Closure callback)
|
| - : file_(file),
|
| - callback_(callback),
|
| - first_run_(true) {
|
| - }
|
| + HangingFirstRequestInterceptor(
|
| + const base::FilePath& file,
|
| + base::Callback<void(net::URLRequest*)> callback)
|
| + : file_(file), callback_(callback), first_run_(true) {}
|
| ~HangingFirstRequestInterceptor() override {}
|
|
|
| net::URLRequestJob* MaybeInterceptRequest(
|
| @@ -190,10 +188,8 @@ class HangingFirstRequestInterceptor : public net::URLRequestInterceptor {
|
| net::NetworkDelegate* network_delegate) const override {
|
| if (first_run_) {
|
| first_run_ = false;
|
| - if (!callback_.is_null()) {
|
| - BrowserThread::PostTask(
|
| - BrowserThread::UI, FROM_HERE, callback_);
|
| - }
|
| + if (!callback_.is_null())
|
| + callback_.Run(request);
|
| return new HangingURLRequestJob(request, network_delegate);
|
| }
|
| return new net::URLRequestMockHTTPJob(
|
| @@ -206,7 +202,7 @@ class HangingFirstRequestInterceptor : public net::URLRequestInterceptor {
|
|
|
| private:
|
| base::FilePath file_;
|
| - base::Closure callback_;
|
| + base::Callback<void(net::URLRequest*)> callback_;
|
| mutable bool first_run_;
|
| };
|
|
|
| @@ -251,6 +247,17 @@ class NeverRunsExternalProtocolHandlerDelegate
|
| void FinishedProcessingCheck() override { NOTREACHED(); }
|
| };
|
|
|
| +void CreateHangingFirstRequestInterceptorOnIO(
|
| + const GURL& url,
|
| + const base::FilePath& file,
|
| + base::Callback<void(net::URLRequest*)> callback_io) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + std::unique_ptr<net::URLRequestInterceptor> interceptor(
|
| + new HangingFirstRequestInterceptor(file, callback_io));
|
| + net::URLRequestFilter::GetInstance()->AddUrlInterceptor(
|
| + url, std::move(interceptor));
|
| +}
|
| +
|
| } // namespace
|
|
|
| RequestCounter::RequestCounter() : count_(0), expected_count_(-1) {}
|
| @@ -801,13 +808,15 @@ void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file) {
|
| file, content::BrowserThread::GetBlockingPool()));
|
| }
|
|
|
| -void CreateHangingFirstRequestInterceptorOnIO(
|
| - const GURL& url, const base::FilePath& file, base::Closure callback) {
|
| - CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - std::unique_ptr<net::URLRequestInterceptor> interceptor(
|
| - new HangingFirstRequestInterceptor(file, callback));
|
| - net::URLRequestFilter::GetInstance()->AddUrlInterceptor(
|
| - url, std::move(interceptor));
|
| +void CreateHangingFirstRequestInterceptor(
|
| + const GURL& url,
|
| + const base::FilePath& file,
|
| + base::Callback<void(net::URLRequest*)> callback_io) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&CreateHangingFirstRequestInterceptorOnIO, url, file,
|
| + callback_io));
|
| }
|
|
|
| } // namespace test_utils
|
|
|