OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/prerender/prerender_test_utils.h" | 5 #include "chrome/browser/prerender/prerender_test_utils.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 class MockHTTPJob : public net::URLRequestMockHTTPJob { | 55 class MockHTTPJob : public net::URLRequestMockHTTPJob { |
56 public: | 56 public: |
57 MockHTTPJob(net::URLRequest* request, | 57 MockHTTPJob(net::URLRequest* request, |
58 net::NetworkDelegate* delegate, | 58 net::NetworkDelegate* delegate, |
59 const base::FilePath& file) | 59 const base::FilePath& file) |
60 : net::URLRequestMockHTTPJob( | 60 : net::URLRequestMockHTTPJob( |
61 request, | 61 request, |
62 delegate, | 62 delegate, |
63 file, | 63 file, |
64 base::CreateTaskRunnerWithTraits( | 64 base::CreateTaskRunnerWithTraits( |
65 base::TaskTraits() | 65 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
66 .MayBlock() | 66 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})) {} |
67 .WithPriority(base::TaskPriority::BACKGROUND) | |
68 .WithShutdownBehavior( | |
69 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))) {} | |
70 | 67 |
71 void set_start_callback(const base::Closure& start_callback) { | 68 void set_start_callback(const base::Closure& start_callback) { |
72 start_callback_ = start_callback; | 69 start_callback_ = start_callback; |
73 } | 70 } |
74 | 71 |
75 void Start() override { | 72 void Start() override { |
76 if (!start_callback_.is_null()) | 73 if (!start_callback_.is_null()) |
77 start_callback_.Run(); | 74 start_callback_.Run(); |
78 net::URLRequestMockHTTPJob::Start(); | 75 net::URLRequestMockHTTPJob::Start(); |
79 } | 76 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 net::NetworkDelegate* network_delegate) const override { | 190 net::NetworkDelegate* network_delegate) const override { |
194 if (first_run_) { | 191 if (first_run_) { |
195 first_run_ = false; | 192 first_run_ = false; |
196 if (!callback_.is_null()) | 193 if (!callback_.is_null()) |
197 callback_.Run(request); | 194 callback_.Run(request); |
198 return new HangingURLRequestJob(request, network_delegate); | 195 return new HangingURLRequestJob(request, network_delegate); |
199 } | 196 } |
200 return new net::URLRequestMockHTTPJob( | 197 return new net::URLRequestMockHTTPJob( |
201 request, network_delegate, file_, | 198 request, network_delegate, file_, |
202 base::CreateTaskRunnerWithTraits( | 199 base::CreateTaskRunnerWithTraits( |
203 base::TaskTraits() | 200 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
204 .MayBlock() | 201 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})); |
205 .WithPriority(base::TaskPriority::BACKGROUND) | |
206 .WithShutdownBehavior( | |
207 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN))); | |
208 } | 202 } |
209 | 203 |
210 private: | 204 private: |
211 base::FilePath file_; | 205 base::FilePath file_; |
212 base::Callback<void(net::URLRequest*)> callback_; | 206 base::Callback<void(net::URLRequest*)> callback_; |
213 mutable bool first_run_; | 207 mutable bool first_run_; |
214 }; | 208 }; |
215 | 209 |
216 // An ExternalProtocolHandler that blocks everything and asserts it never is | 210 // An ExternalProtocolHandler that blocks everything and asserts it never is |
217 // called. | 211 // called. |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 828 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
835 content::BrowserThread::PostTask( | 829 content::BrowserThread::PostTask( |
836 content::BrowserThread::IO, FROM_HERE, | 830 content::BrowserThread::IO, FROM_HERE, |
837 base::BindOnce(&CreateHangingFirstRequestInterceptorOnIO, url, file, | 831 base::BindOnce(&CreateHangingFirstRequestInterceptorOnIO, url, file, |
838 callback_io)); | 832 callback_io)); |
839 } | 833 } |
840 | 834 |
841 } // namespace test_utils | 835 } // namespace test_utils |
842 | 836 |
843 } // namespace prerender | 837 } // namespace prerender |
OLD | NEW |