OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/http/http_stream_factory_impl_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 return result; | 478 return result; |
479 } | 479 } |
480 | 480 |
481 int HttpStreamFactoryImpl::Job::DoLoop(int result) { | 481 int HttpStreamFactoryImpl::Job::DoLoop(int result) { |
482 DCHECK_NE(next_state_, STATE_NONE); | 482 DCHECK_NE(next_state_, STATE_NONE); |
483 int rv = result; | 483 int rv = result; |
484 do { | 484 do { |
485 State state = next_state_; | 485 State state = next_state_; |
486 next_state_ = STATE_NONE; | 486 next_state_ = STATE_NONE; |
487 switch (state) { | 487 switch (state) { |
488 case STATE_START: | |
489 DCHECK_EQ(OK, rv); | |
490 rv = DoStart(); | |
491 break; | |
488 case STATE_RESOLVE_PROXY: | 492 case STATE_RESOLVE_PROXY: |
489 DCHECK_EQ(OK, rv); | 493 DCHECK_EQ(OK, rv); |
490 rv = DoResolveProxy(); | 494 rv = DoResolveProxy(); |
491 break; | 495 break; |
492 case STATE_RESOLVE_PROXY_COMPLETE: | 496 case STATE_RESOLVE_PROXY_COMPLETE: |
493 rv = DoResolveProxyComplete(rv); | 497 rv = DoResolveProxyComplete(rv); |
494 break; | 498 break; |
495 case STATE_WAIT_FOR_JOB: | 499 case STATE_WAIT_FOR_JOB: |
496 DCHECK_EQ(OK, rv); | 500 DCHECK_EQ(OK, rv); |
497 rv = DoWaitForJob(); | 501 rv = DoWaitForJob(); |
(...skipping 29 matching lines...) Expand all Loading... | |
527 NOTREACHED() << "bad state"; | 531 NOTREACHED() << "bad state"; |
528 rv = ERR_FAILED; | 532 rv = ERR_FAILED; |
529 break; | 533 break; |
530 } | 534 } |
531 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); | 535 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |
532 return rv; | 536 return rv; |
533 } | 537 } |
534 | 538 |
535 int HttpStreamFactoryImpl::Job::StartInternal() { | 539 int HttpStreamFactoryImpl::Job::StartInternal() { |
536 CHECK_EQ(STATE_NONE, next_state_); | 540 CHECK_EQ(STATE_NONE, next_state_); |
537 | 541 next_state_ = STATE_START; |
538 origin_ = HostPortPair(request_info_.url.HostNoBrackets(), | |
539 request_info_.url.EffectiveIntPort()); | |
540 origin_url_ = HttpStreamFactory::ApplyHostMappingRules( | |
541 request_info_.url, &origin_); | |
542 | |
543 net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB, | 542 net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB, |
544 HttpStreamJobParameters::Create(request_info_.url, | 543 HttpStreamJobParameters::Create(request_info_.url, |
545 origin_url_)); | 544 origin_url_)); |
wtc
2012/01/14 01:34:46
In the original code, we have already initialized
mmenke
2012/01/14 02:19:21
Definitely a bug. Thanks for spotting this.
| |
546 next_state_ = STATE_RESOLVE_PROXY; | |
547 int rv = RunLoop(OK); | 545 int rv = RunLoop(OK); |
548 DCHECK_EQ(ERR_IO_PENDING, rv); | 546 DCHECK_EQ(ERR_IO_PENDING, rv); |
549 return rv; | 547 return rv; |
550 } | 548 } |
551 | 549 |
550 int HttpStreamFactoryImpl::Job::DoStart() { | |
willchan no longer on Chromium
2011/12/12 18:24:16
Almost all the rest of our states have DoFoo() and
mmenke
2011/12/12 18:43:21
Currently it's expected to always return asynchron
willchan no longer on Chromium
2011/12/12 19:04:58
Oh I see. I think I'd like to modify all call site
mmenke
2011/12/12 19:10:03
Sure, will do.
mmenke
2011/12/13 16:35:00
Making this able to fail synchronously is enough o
mmenke
2011/12/13 16:44:32
Or I could just add an OnStartComplete function th
| |
551 // Don't connect to restricted ports. | |
552 int port = request_info_.url.EffectiveIntPort(); | |
553 if (!IsPortAllowedByDefault(port) && !IsPortAllowedByOverride(port)) | |
554 return ERR_UNSAFE_PORT; | |
wtc
2012/01/14 01:34:46
Before DoResolveProxyComplete() returns an error c
mmenke
2012/01/14 02:19:21
I agree. There's no fall through to automatically
| |
555 | |
556 origin_ = HostPortPair(request_info_.url.HostNoBrackets(), port); | |
557 origin_url_ = HttpStreamFactory::ApplyHostMappingRules( | |
558 request_info_.url, &origin_); | |
559 | |
560 next_state_ = STATE_RESOLVE_PROXY; | |
561 return OK; | |
562 } | |
563 | |
552 int HttpStreamFactoryImpl::Job::DoResolveProxy() { | 564 int HttpStreamFactoryImpl::Job::DoResolveProxy() { |
553 DCHECK(!pac_request_); | 565 DCHECK(!pac_request_); |
554 | 566 |
555 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 567 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
556 | 568 |
557 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { | 569 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { |
558 proxy_info_.UseDirect(); | 570 proxy_info_.UseDirect(); |
559 return OK; | 571 return OK; |
560 } | 572 } |
561 | 573 |
(...skipping 14 matching lines...) Expand all Loading... | |
576 | 588 |
577 if (proxy_info_.is_empty()) { | 589 if (proxy_info_.is_empty()) { |
578 // No proxies/direct to choose from. This happens when we don't support | 590 // No proxies/direct to choose from. This happens when we don't support |
579 // any of the proxies in the returned list. | 591 // any of the proxies in the returned list. |
580 result = ERR_NO_SUPPORTED_PROXIES; | 592 result = ERR_NO_SUPPORTED_PROXIES; |
581 } | 593 } |
582 } | 594 } |
583 | 595 |
584 if (result != OK) { | 596 if (result != OK) { |
585 if (dependent_job_) | 597 if (dependent_job_) |
586 dependent_job_->Resume(this); | 598 dependent_job_->Resume(this); |
wtc
2012/01/14 01:34:46
Should we set dependent_job_ to NULL after calling
mmenke
2012/01/14 02:19:21
It shouldn't really be needed, since if we fail, t
| |
587 return result; | 599 return result; |
588 } | 600 } |
589 | 601 |
590 if (blocking_job_) | 602 if (blocking_job_) |
591 next_state_ = STATE_WAIT_FOR_JOB; | 603 next_state_ = STATE_WAIT_FOR_JOB; |
592 else | 604 else |
593 next_state_ = STATE_INIT_CONNECTION; | 605 next_state_ = STATE_INIT_CONNECTION; |
594 return OK; | 606 return OK; |
595 } | 607 } |
596 | 608 |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1192 return false; | 1204 return false; |
1193 } | 1205 } |
1194 if (request_info_.method != "GET" && request_info_.method != "HEAD") { | 1206 if (request_info_.method != "GET" && request_info_.method != "HEAD") { |
1195 return false; | 1207 return false; |
1196 } | 1208 } |
1197 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( | 1209 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( |
1198 origin_); | 1210 origin_); |
1199 } | 1211 } |
1200 | 1212 |
1201 } // namespace net | 1213 } // namespace net |
OLD | NEW |