Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1530)

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host_unittest.cc

Issue 10855209: Refactoring: ProtocolHandler::MaybeCreateJob takes NetworkDelegate as argument (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest merge Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 private: 202 private:
203 IPC::Sender* dest_; 203 IPC::Sender* dest_;
204 204
205 DISALLOW_COPY_AND_ASSIGN(ForwardingFilter); 205 DISALLOW_COPY_AND_ASSIGN(ForwardingFilter);
206 }; 206 };
207 207
208 // This class is a variation on URLRequestTestJob in that it does 208 // This class is a variation on URLRequestTestJob in that it does
209 // not complete start upon entry, only when specifically told to. 209 // not complete start upon entry, only when specifically told to.
210 class URLRequestTestDelayedStartJob : public net::URLRequestTestJob { 210 class URLRequestTestDelayedStartJob : public net::URLRequestTestJob {
211 public: 211 public:
212 URLRequestTestDelayedStartJob(net::URLRequest* request) 212 URLRequestTestDelayedStartJob(net::URLRequest* request,
213 : net::URLRequestTestJob(request) { 213 net::NetworkDelegate* network_delegate)
214 Init(); 214 : net::URLRequestTestJob(request, network_delegate) {
215 }
216 URLRequestTestDelayedStartJob(net::URLRequest* request, bool auto_advance)
217 : net::URLRequestTestJob(request, auto_advance) {
218 Init(); 215 Init();
219 } 216 }
220 URLRequestTestDelayedStartJob(net::URLRequest* request, 217 URLRequestTestDelayedStartJob(net::URLRequest* request,
218 net::NetworkDelegate* network_delegate,
219 bool auto_advance)
220 : net::URLRequestTestJob(request, network_delegate, auto_advance) {
221 Init();
222 }
223 URLRequestTestDelayedStartJob(net::URLRequest* request,
224 net::NetworkDelegate* network_delegate,
221 const std::string& response_headers, 225 const std::string& response_headers,
222 const std::string& response_data, 226 const std::string& response_data,
223 bool auto_advance) 227 bool auto_advance)
224 : net::URLRequestTestJob( 228 : net::URLRequestTestJob(request,
225 request, response_headers, response_data, auto_advance) { 229 network_delegate,
230 response_headers,
231 response_data,
232 auto_advance) {
226 Init(); 233 Init();
227 } 234 }
228 235
229 // Do nothing until you're told to. 236 // Do nothing until you're told to.
230 virtual void Start() {} 237 virtual void Start() {}
231 238
232 // Finish starting a URL request whose job is an instance of 239 // Finish starting a URL request whose job is an instance of
233 // URLRequestTestDelayedStartJob. It is illegal to call this routine 240 // URLRequestTestDelayedStartJob. It is illegal to call this routine
234 // with a URLRequest that does not use URLRequestTestDelayedStartJob. 241 // with a URLRequest that does not use URLRequestTestDelayedStartJob.
235 static void CompleteStart(net::URLRequest* request) { 242 static void CompleteStart(net::URLRequest* request) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 URLRequestTestDelayedStartJob* next_; 286 URLRequestTestDelayedStartJob* next_;
280 }; 287 };
281 288
282 URLRequestTestDelayedStartJob* 289 URLRequestTestDelayedStartJob*
283 URLRequestTestDelayedStartJob::list_head_ = NULL; 290 URLRequestTestDelayedStartJob::list_head_ = NULL;
284 291
285 // This class is a variation on URLRequestTestJob in that it 292 // This class is a variation on URLRequestTestJob in that it
286 // returns IO_pending errors before every read, not just the first one. 293 // returns IO_pending errors before every read, not just the first one.
287 class URLRequestTestDelayedCompletionJob : public net::URLRequestTestJob { 294 class URLRequestTestDelayedCompletionJob : public net::URLRequestTestJob {
288 public: 295 public:
289 explicit URLRequestTestDelayedCompletionJob(net::URLRequest* request)
290 : net::URLRequestTestJob(request) {}
291 URLRequestTestDelayedCompletionJob(net::URLRequest* request, 296 URLRequestTestDelayedCompletionJob(net::URLRequest* request,
297 net::NetworkDelegate* network_delegate)
298 : net::URLRequestTestJob(request, network_delegate) {}
299 URLRequestTestDelayedCompletionJob(net::URLRequest* request,
300 net::NetworkDelegate* network_delegate,
292 bool auto_advance) 301 bool auto_advance)
293 : net::URLRequestTestJob(request, auto_advance) {} 302 : net::URLRequestTestJob(request, network_delegate, auto_advance) {}
294 URLRequestTestDelayedCompletionJob(net::URLRequest* request, 303 URLRequestTestDelayedCompletionJob(net::URLRequest* request,
304 net::NetworkDelegate* network_delegate,
295 const std::string& response_headers, 305 const std::string& response_headers,
296 const std::string& response_data, 306 const std::string& response_data,
297 bool auto_advance) 307 bool auto_advance)
298 : net::URLRequestTestJob(request, response_headers, 308 : net::URLRequestTestJob(request,
299 response_data, auto_advance) {} 309 network_delegate,
310 response_headers,
311 response_data,
312 auto_advance) {}
300 313
301 protected: 314 protected:
302 ~URLRequestTestDelayedCompletionJob() {} 315 ~URLRequestTestDelayedCompletionJob() {}
303 316
304 private: 317 private:
305 virtual bool NextReadAsync() OVERRIDE { return true; } 318 virtual bool NextReadAsync() OVERRIDE { return true; }
306 }; 319 };
307 320
308 class URLRequestBigJob : public net::URLRequestSimpleJob { 321 class URLRequestBigJob : public net::URLRequestSimpleJob {
309 public: 322 public:
310 URLRequestBigJob(net::URLRequest* request) 323 URLRequestBigJob(net::URLRequest* request,
311 : net::URLRequestSimpleJob(request) { 324 net::NetworkDelegate* network_delegate)
325 : net::URLRequestSimpleJob(request, network_delegate) {
312 } 326 }
313 327
314 virtual int GetData(std::string* mime_type, 328 virtual int GetData(std::string* mime_type,
315 std::string* charset, 329 std::string* charset,
316 std::string* data, 330 std::string* data,
317 const net::CompletionCallback& callback) const OVERRIDE { 331 const net::CompletionCallback& callback) const OVERRIDE {
318 *mime_type = "text/plain"; 332 *mime_type = "text/plain";
319 *charset = "UTF-8"; 333 *charset = "UTF-8";
320 334
321 std::string text; 335 std::string text;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 DCHECK(scheme_.empty()); 571 DCHECK(scheme_.empty());
558 DCHECK(!old_factory_); 572 DCHECK(!old_factory_);
559 scheme_ = scheme; 573 scheme_ = scheme;
560 old_factory_ = net::URLRequest::Deprecated::RegisterProtocolFactory( 574 old_factory_ = net::URLRequest::Deprecated::RegisterProtocolFactory(
561 scheme_, &ResourceDispatcherHostTest::Factory); 575 scheme_, &ResourceDispatcherHostTest::Factory);
562 EnsureSchemeIsAllowed(scheme); 576 EnsureSchemeIsAllowed(scheme);
563 } 577 }
564 578
565 // Our own net::URLRequestJob factory. 579 // Our own net::URLRequestJob factory.
566 static net::URLRequestJob* Factory(net::URLRequest* request, 580 static net::URLRequestJob* Factory(net::URLRequest* request,
581 net::NetworkDelegate* network_delegate,
567 const std::string& scheme) { 582 const std::string& scheme) {
568 if (test_fixture_->response_headers_.empty()) { 583 if (test_fixture_->response_headers_.empty()) {
569 if (delay_start_) { 584 if (delay_start_) {
570 return new URLRequestTestDelayedStartJob(request); 585 return new URLRequestTestDelayedStartJob(request, network_delegate);
571 } else if (delay_complete_) { 586 } else if (delay_complete_) {
572 return new URLRequestTestDelayedCompletionJob(request); 587 return new URLRequestTestDelayedCompletionJob(request,
588 network_delegate);
573 } else if (scheme == "big-job") { 589 } else if (scheme == "big-job") {
574 return new URLRequestBigJob(request); 590 return new URLRequestBigJob(request, network_delegate);
575 } else { 591 } else {
576 return new net::URLRequestTestJob(request); 592 return new net::URLRequestTestJob(request, network_delegate);
577 } 593 }
578 } else { 594 } else {
579 if (delay_start_) { 595 if (delay_start_) {
580 return new URLRequestTestDelayedStartJob( 596 return new URLRequestTestDelayedStartJob(
581 request, test_fixture_->response_headers_, 597 request, network_delegate,
582 test_fixture_->response_data_, false); 598 test_fixture_->response_headers_, test_fixture_->response_data_,
599 false);
583 } else if (delay_complete_) { 600 } else if (delay_complete_) {
584 return new URLRequestTestDelayedCompletionJob( 601 return new URLRequestTestDelayedCompletionJob(
585 request, test_fixture_->response_headers_, 602 request, network_delegate,
586 test_fixture_->response_data_, false); 603 test_fixture_->response_headers_, test_fixture_->response_data_,
604 false);
587 } else { 605 } else {
588 return new net::URLRequestTestJob(request, 606 return new net::URLRequestTestJob(
589 test_fixture_->response_headers_, 607 request, network_delegate,
590 test_fixture_->response_data_, 608 test_fixture_->response_headers_, test_fixture_->response_data_,
591 false); 609 false);
592 } 610 }
593 } 611 }
594 } 612 }
595 613
596 void SetDelayedStartJobGeneration(bool delay_job_start) { 614 void SetDelayedStartJobGeneration(bool delay_job_start) {
597 delay_start_ = delay_job_start; 615 delay_start_ = delay_job_start;
598 } 616 }
599 617
600 void SetDelayedCompleteJobGeneration(bool delay_job_complete) { 618 void SetDelayedCompleteJobGeneration(bool delay_job_complete) {
601 delay_complete_ = delay_job_complete; 619 delay_complete_ = delay_job_complete;
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 } 1765 }
1748 1766
1749 MessageLoop::current()->RunAllPending(); 1767 MessageLoop::current()->RunAllPending();
1750 1768
1751 msgs.clear(); 1769 msgs.clear();
1752 accum_.GetClassifiedMessages(&msgs); 1770 accum_.GetClassifiedMessages(&msgs);
1753 } 1771 }
1754 } 1772 }
1755 1773
1756 } // namespace content 1774 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/net/view_http_cache_job_factory.cc ('k') | content/browser/resource_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698