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

Side by Side Diff: net/http/http_stream_factory_impl_job.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
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 "net/http/http_stream_factory_impl_job.h" 5 #include "net/http/http_stream_factory_impl_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 void HttpStreamFactoryImpl::Job::Start(Request* request) { 127 void HttpStreamFactoryImpl::Job::Start(Request* request) {
128 DCHECK(request); 128 DCHECK(request);
129 request_ = request; 129 request_ = request;
130 StartInternal(); 130 StartInternal();
131 } 131 }
132 132
133 int HttpStreamFactoryImpl::Job::Preconnect(int num_streams) { 133 int HttpStreamFactoryImpl::Job::Preconnect(int num_streams) {
134 DCHECK_GT(num_streams, 0); 134 DCHECK_GT(num_streams, 0);
135 HostPortPair origin_server =
136 HostPortPair(request_info_.url.HostNoBrackets(),
137 request_info_.url.EffectiveIntPort());
138 base::WeakPtr<HttpServerProperties> http_server_properties = 135 base::WeakPtr<HttpServerProperties> http_server_properties =
139 session_->http_server_properties(); 136 session_->http_server_properties();
140 if (http_server_properties && 137 if (http_server_properties && http_server_properties->SupportsSpdy(
141 http_server_properties->SupportsSpdy(origin_server)) { 138 HostPortPair::FromURL(request_info_.url))) {
142 num_streams_ = 1; 139 num_streams_ = 1;
143 } else { 140 } else {
144 num_streams_ = num_streams; 141 num_streams_ = num_streams;
145 } 142 }
146 return StartInternal(); 143 return StartInternal();
147 } 144 }
148 145
149 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth( 146 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth(
150 const AuthCredentials& credentials) { 147 const AuthCredentials& credentials) {
151 DCHECK(establishing_tunnel_); 148 DCHECK(establishing_tunnel_);
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 607
611 int HttpStreamFactoryImpl::Job::StartInternal() { 608 int HttpStreamFactoryImpl::Job::StartInternal() {
612 CHECK_EQ(STATE_NONE, next_state_); 609 CHECK_EQ(STATE_NONE, next_state_);
613 next_state_ = STATE_START; 610 next_state_ = STATE_START;
614 int rv = RunLoop(OK); 611 int rv = RunLoop(OK);
615 DCHECK_EQ(ERR_IO_PENDING, rv); 612 DCHECK_EQ(ERR_IO_PENDING, rv);
616 return rv; 613 return rv;
617 } 614 }
618 615
619 int HttpStreamFactoryImpl::Job::DoStart() { 616 int HttpStreamFactoryImpl::Job::DoStart() {
620 int port = request_info_.url.EffectiveIntPort(); 617 origin_ = HostPortPair::FromURL(request_info_.url);
621 origin_ = HostPortPair(request_info_.url.HostNoBrackets(), port);
622 origin_url_ = stream_factory_->ApplyHostMappingRules( 618 origin_url_ = stream_factory_->ApplyHostMappingRules(
623 request_info_.url, &origin_); 619 request_info_.url, &origin_);
624 620
625 net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB, 621 net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB,
626 base::Bind(&NetLogHttpStreamJobCallback, 622 base::Bind(&NetLogHttpStreamJobCallback,
627 &request_info_.url, &origin_url_, 623 &request_info_.url, &origin_url_,
628 priority_)); 624 priority_));
629 625
630 // Don't connect to restricted ports. 626 // Don't connect to restricted ports.
631 bool is_port_allowed = IsPortAllowedByDefault(port); 627 bool is_port_allowed = IsPortAllowedByDefault(origin_.port());
632 if (request_info_.url.SchemeIs("ftp")) { 628 if (request_info_.url.SchemeIs("ftp")) {
633 // Never share connection with other jobs for FTP requests. 629 // Never share connection with other jobs for FTP requests.
634 DCHECK(!waiting_job_); 630 DCHECK(!waiting_job_);
635 631
636 is_port_allowed = IsPortAllowedByFtp(port); 632 is_port_allowed = IsPortAllowedByFtp(origin_.port());
637 } 633 }
638 if (!is_port_allowed && !IsPortAllowedByOverride(port)) { 634 if (!is_port_allowed && !IsPortAllowedByOverride(origin_.port())) {
639 if (waiting_job_) { 635 if (waiting_job_) {
640 waiting_job_->Resume(this); 636 waiting_job_->Resume(this);
641 waiting_job_ = NULL; 637 waiting_job_ = NULL;
642 } 638 }
643 return ERR_UNSAFE_PORT; 639 return ERR_UNSAFE_PORT;
644 } 640 }
645 641
646 next_state_ = STATE_RESOLVE_PROXY; 642 next_state_ = STATE_RESOLVE_PROXY;
647 return OK; 643 return OK;
648 } 644 }
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 1463
1468 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { 1464 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) {
1469 HistogramBrokenAlternateProtocolLocation( 1465 HistogramBrokenAlternateProtocolLocation(
1470 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); 1466 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN);
1471 session_->http_server_properties()->SetBrokenAlternateProtocol( 1467 session_->http_server_properties()->SetBrokenAlternateProtocol(
1472 HostPortPair::FromURL(request_info_.url)); 1468 HostPortPair::FromURL(request_info_.url));
1473 } 1469 }
1474 } 1470 }
1475 1471
1476 } // namespace net 1472 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl.cc ('k') | net/http/http_stream_factory_impl_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698