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 "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 5 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 Init(); | 214 Init(); |
215 } | 215 } |
216 URLRequestTestDelayedStartJob(net::URLRequest* request, bool auto_advance) | 216 URLRequestTestDelayedStartJob(net::URLRequest* request, bool auto_advance) |
217 : net::URLRequestTestJob(request, auto_advance) { | 217 : net::URLRequestTestJob(request, auto_advance) { |
218 Init(); | 218 Init(); |
219 } | 219 } |
220 URLRequestTestDelayedStartJob(net::URLRequest* request, | 220 URLRequestTestDelayedStartJob(net::URLRequest* request, |
221 const std::string& response_headers, | 221 const std::string& response_headers, |
222 const std::string& response_data, | 222 const std::string& response_data, |
223 bool auto_advance) | 223 bool auto_advance) |
224 : net::URLRequestTestJob( | 224 : net::URLRequestTestJob(request, |
225 request, response_headers, response_data, auto_advance) { | 225 request->context()->network_delegate(), |
| 226 response_headers, |
| 227 response_data, |
| 228 auto_advance) { |
226 Init(); | 229 Init(); |
227 } | 230 } |
228 | 231 |
229 // Do nothing until you're told to. | 232 // Do nothing until you're told to. |
230 virtual void Start() {} | 233 virtual void Start() {} |
231 | 234 |
232 // Finish starting a URL request whose job is an instance of | 235 // Finish starting a URL request whose job is an instance of |
233 // URLRequestTestDelayedStartJob. It is illegal to call this routine | 236 // URLRequestTestDelayedStartJob. It is illegal to call this routine |
234 // with a URLRequest that does not use URLRequestTestDelayedStartJob. | 237 // with a URLRequest that does not use URLRequestTestDelayedStartJob. |
235 static void CompleteStart(net::URLRequest* request) { | 238 static void CompleteStart(net::URLRequest* request) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 public: | 291 public: |
289 explicit URLRequestTestDelayedCompletionJob(net::URLRequest* request) | 292 explicit URLRequestTestDelayedCompletionJob(net::URLRequest* request) |
290 : net::URLRequestTestJob(request) {} | 293 : net::URLRequestTestJob(request) {} |
291 URLRequestTestDelayedCompletionJob(net::URLRequest* request, | 294 URLRequestTestDelayedCompletionJob(net::URLRequest* request, |
292 bool auto_advance) | 295 bool auto_advance) |
293 : net::URLRequestTestJob(request, auto_advance) {} | 296 : net::URLRequestTestJob(request, auto_advance) {} |
294 URLRequestTestDelayedCompletionJob(net::URLRequest* request, | 297 URLRequestTestDelayedCompletionJob(net::URLRequest* request, |
295 const std::string& response_headers, | 298 const std::string& response_headers, |
296 const std::string& response_data, | 299 const std::string& response_data, |
297 bool auto_advance) | 300 bool auto_advance) |
298 : net::URLRequestTestJob(request, response_headers, | 301 : net::URLRequestTestJob(request, |
299 response_data, auto_advance) {} | 302 request->context()->network_delegate(), |
| 303 response_headers, |
| 304 response_data, |
| 305 auto_advance) {} |
300 | 306 |
301 protected: | 307 protected: |
302 ~URLRequestTestDelayedCompletionJob() {} | 308 ~URLRequestTestDelayedCompletionJob() {} |
303 | 309 |
304 private: | 310 private: |
305 virtual bool NextReadAsync() OVERRIDE { return true; } | 311 virtual bool NextReadAsync() OVERRIDE { return true; } |
306 }; | 312 }; |
307 | 313 |
308 class URLRequestBigJob : public net::URLRequestSimpleJob { | 314 class URLRequestBigJob : public net::URLRequestSimpleJob { |
309 public: | 315 public: |
310 URLRequestBigJob(net::URLRequest* request) | 316 URLRequestBigJob(net::URLRequest* request, |
311 : net::URLRequestSimpleJob(request) { | 317 net::NetworkDelegate* network_delegate) |
| 318 : net::URLRequestSimpleJob(request, network_delegate) { |
312 } | 319 } |
313 | 320 |
314 virtual int GetData(std::string* mime_type, | 321 virtual int GetData(std::string* mime_type, |
315 std::string* charset, | 322 std::string* charset, |
316 std::string* data, | 323 std::string* data, |
317 const net::CompletionCallback& callback) const OVERRIDE { | 324 const net::CompletionCallback& callback) const OVERRIDE { |
318 *mime_type = "text/plain"; | 325 *mime_type = "text/plain"; |
319 *charset = "UTF-8"; | 326 *charset = "UTF-8"; |
320 | 327 |
321 std::string text; | 328 std::string text; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 571 |
565 // Our own net::URLRequestJob factory. | 572 // Our own net::URLRequestJob factory. |
566 static net::URLRequestJob* Factory(net::URLRequest* request, | 573 static net::URLRequestJob* Factory(net::URLRequest* request, |
567 const std::string& scheme) { | 574 const std::string& scheme) { |
568 if (test_fixture_->response_headers_.empty()) { | 575 if (test_fixture_->response_headers_.empty()) { |
569 if (delay_start_) { | 576 if (delay_start_) { |
570 return new URLRequestTestDelayedStartJob(request); | 577 return new URLRequestTestDelayedStartJob(request); |
571 } else if (delay_complete_) { | 578 } else if (delay_complete_) { |
572 return new URLRequestTestDelayedCompletionJob(request); | 579 return new URLRequestTestDelayedCompletionJob(request); |
573 } else if (scheme == "big-job") { | 580 } else if (scheme == "big-job") { |
574 return new URLRequestBigJob(request); | 581 return new URLRequestBigJob(request, |
| 582 request->context()->network_delegate()); |
575 } else { | 583 } else { |
576 return new net::URLRequestTestJob(request); | 584 return new net::URLRequestTestJob(request); |
577 } | 585 } |
578 } else { | 586 } else { |
579 if (delay_start_) { | 587 if (delay_start_) { |
580 return new URLRequestTestDelayedStartJob( | 588 return new URLRequestTestDelayedStartJob( |
581 request, test_fixture_->response_headers_, | 589 request, test_fixture_->response_headers_, |
582 test_fixture_->response_data_, false); | 590 test_fixture_->response_data_, false); |
583 } else if (delay_complete_) { | 591 } else if (delay_complete_) { |
584 return new URLRequestTestDelayedCompletionJob( | 592 return new URLRequestTestDelayedCompletionJob( |
585 request, test_fixture_->response_headers_, | 593 request, test_fixture_->response_headers_, |
586 test_fixture_->response_data_, false); | 594 test_fixture_->response_data_, false); |
587 } else { | 595 } else { |
588 return new net::URLRequestTestJob(request, | 596 return new net::URLRequestTestJob( |
589 test_fixture_->response_headers_, | 597 request, |
590 test_fixture_->response_data_, | 598 request->context()->network_delegate(), |
591 false); | 599 test_fixture_->response_headers_, |
| 600 test_fixture_->response_data_, |
| 601 false); |
592 } | 602 } |
593 } | 603 } |
594 } | 604 } |
595 | 605 |
596 void SetDelayedStartJobGeneration(bool delay_job_start) { | 606 void SetDelayedStartJobGeneration(bool delay_job_start) { |
597 delay_start_ = delay_job_start; | 607 delay_start_ = delay_job_start; |
598 } | 608 } |
599 | 609 |
600 void SetDelayedCompleteJobGeneration(bool delay_job_complete) { | 610 void SetDelayedCompleteJobGeneration(bool delay_job_complete) { |
601 delay_complete_ = delay_job_complete; | 611 delay_complete_ = delay_job_complete; |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 } | 1757 } |
1748 | 1758 |
1749 MessageLoop::current()->RunAllPending(); | 1759 MessageLoop::current()->RunAllPending(); |
1750 | 1760 |
1751 msgs.clear(); | 1761 msgs.clear(); |
1752 accum_.GetClassifiedMessages(&msgs); | 1762 accum_.GetClassifiedMessages(&msgs); |
1753 } | 1763 } |
1754 } | 1764 } |
1755 | 1765 |
1756 } // namespace content | 1766 } // namespace content |
OLD | NEW |