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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 http_server_properties->SupportsSpdy(origin_server)) { | 176 http_server_properties->SupportsSpdy(origin_server)) { |
177 num_streams_ = 1; | 177 num_streams_ = 1; |
178 } else { | 178 } else { |
179 num_streams_ = num_streams; | 179 num_streams_ = num_streams; |
180 } | 180 } |
181 return StartInternal(); | 181 return StartInternal(); |
182 } | 182 } |
183 | 183 |
184 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth( | 184 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth( |
185 const AuthCredentials& credentials) { | 185 const AuthCredentials& credentials) { |
186 DCHECK(establishing_tunnel_); | 186 MessageLoop::current()->PostTask( |
187 next_state_ = STATE_RESTART_TUNNEL_AUTH; | 187 FROM_HERE, |
188 stream_.reset(); | 188 base::Bind(&HttpStreamFactoryImpl::Job::ReallyRestartTunnelWithProxyAuth, |
189 return RunLoop(OK); | 189 ptr_factory_.GetWeakPtr())); |
190 return ERR_IO_PENDING; | |
191 } | |
192 | |
193 void HttpStreamFactoryImpl::Job::ReallyRestartTunnelWithProxyAuth() { | |
194 tunnel_auth_handled_callback_.Run(OK); | |
190 } | 195 } |
191 | 196 |
192 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { | 197 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { |
193 switch (next_state_) { | 198 switch (next_state_) { |
194 case STATE_RESOLVE_PROXY_COMPLETE: | 199 case STATE_RESOLVE_PROXY_COMPLETE: |
195 return session_->proxy_service()->GetLoadState(pac_request_); | 200 return session_->proxy_service()->GetLoadState(pac_request_); |
196 case STATE_CREATE_STREAM_COMPLETE: | 201 case STATE_CREATE_STREAM_COMPLETE: |
197 return connection_->GetLoadState(); | 202 return connection_->GetLoadState(); |
198 case STATE_INIT_CONNECTION_COMPLETE: | 203 case STATE_INIT_CONNECTION_COMPLETE: |
199 return LOAD_STATE_SENDING_REQUEST; | 204 return LOAD_STATE_SENDING_REQUEST; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 HttpAuthController* auth_controller) { | 340 HttpAuthController* auth_controller) { |
336 DCHECK(!IsPreconnecting()); | 341 DCHECK(!IsPreconnecting()); |
337 if (IsOrphaned()) | 342 if (IsOrphaned()) |
338 stream_factory_->OnOrphanedJobComplete(this); | 343 stream_factory_->OnOrphanedJobComplete(this); |
339 else | 344 else |
340 request_->OnNeedsProxyAuth( | 345 request_->OnNeedsProxyAuth( |
341 this, response, server_ssl_config_, proxy_info_, auth_controller); | 346 this, response, server_ssl_config_, proxy_info_, auth_controller); |
342 // |this| may be deleted after this call. | 347 // |this| may be deleted after this call. |
343 } | 348 } |
344 | 349 |
350 void HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback( | |
351 const HttpResponseInfo& response_info, | |
352 HttpAuthController* auth_controller, | |
353 CompletionCallback callback) { | |
354 tunnel_auth_handled_callback_ = callback; | |
355 request_->OnNeedsProxyAuth( | |
356 this, response_info, server_ssl_config_, proxy_info_, auth_controller); | |
357 // |this| may be deleted after this call. | |
358 } | |
359 | |
345 void HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback( | 360 void HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback( |
346 SSLCertRequestInfo* cert_info) { | 361 SSLCertRequestInfo* cert_info) { |
347 DCHECK(!IsPreconnecting()); | 362 DCHECK(!IsPreconnecting()); |
348 if (IsOrphaned()) | 363 if (IsOrphaned()) |
349 stream_factory_->OnOrphanedJobComplete(this); | 364 stream_factory_->OnOrphanedJobComplete(this); |
350 else | 365 else |
351 request_->OnNeedsClientAuth(this, server_ssl_config_, cert_info); | 366 request_->OnNeedsClientAuth(this, server_ssl_config_, cert_info); |
352 // |this| may be deleted after this call. | 367 // |this| may be deleted after this call. |
353 } | 368 } |
354 | 369 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 return ERR_IO_PENDING; | 424 return ERR_IO_PENDING; |
410 } | 425 } |
411 | 426 |
412 switch (result) { | 427 switch (result) { |
413 case ERR_PROXY_AUTH_REQUESTED: | 428 case ERR_PROXY_AUTH_REQUESTED: |
414 { | 429 { |
415 DCHECK(connection_.get()); | 430 DCHECK(connection_.get()); |
416 DCHECK(connection_->socket()); | 431 DCHECK(connection_->socket()); |
417 DCHECK(establishing_tunnel_); | 432 DCHECK(establishing_tunnel_); |
418 | 433 |
419 HttpProxyClientSocket* http_proxy_socket = | 434 ProxyClientSocket* proxy_socket = |
420 static_cast<HttpProxyClientSocket*>(connection_->socket()); | 435 static_cast<ProxyClientSocket*>(connection_->socket()); |
421 const HttpResponseInfo* tunnel_auth_response = | 436 const HttpResponseInfo* tunnel_auth_response = |
422 http_proxy_socket->GetConnectResponseInfo(); | 437 proxy_socket->GetConnectResponseInfo(); |
423 | 438 |
424 next_state_ = STATE_WAITING_USER_ACTION; | 439 next_state_ = STATE_WAITING_USER_ACTION; |
425 MessageLoop::current()->PostTask( | 440 MessageLoop::current()->PostTask( |
426 FROM_HERE, | 441 FROM_HERE, |
427 base::Bind( | 442 base::Bind( |
428 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, | 443 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, |
429 ptr_factory_.GetWeakPtr(), | 444 ptr_factory_.GetWeakPtr(), |
430 *tunnel_auth_response, | 445 *tunnel_auth_response, |
431 http_proxy_socket->auth_controller())); | 446 proxy_socket->auth_controller())); |
432 } | 447 } |
433 return ERR_IO_PENDING; | 448 return ERR_IO_PENDING; |
434 | 449 |
435 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: | 450 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: |
436 MessageLoop::current()->PostTask( | 451 MessageLoop::current()->PostTask( |
437 FROM_HERE, | 452 FROM_HERE, |
438 base::Bind( | 453 base::Bind( |
439 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, | 454 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, |
440 ptr_factory_.GetWeakPtr(), | 455 ptr_factory_.GetWeakPtr(), |
441 connection_->ssl_error_response_info().cert_request_info)); | 456 connection_->ssl_error_response_info().cert_request_info)); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 request_info_.extra_headers, | 729 request_info_.extra_headers, |
715 request_info_.load_flags, | 730 request_info_.load_flags, |
716 request_info_.priority, | 731 request_info_.priority, |
717 session_, | 732 session_, |
718 proxy_info_, | 733 proxy_info_, |
719 ShouldForceSpdySSL(), | 734 ShouldForceSpdySSL(), |
720 want_spdy_over_npn, | 735 want_spdy_over_npn, |
721 server_ssl_config_, | 736 server_ssl_config_, |
722 proxy_ssl_config_, | 737 proxy_ssl_config_, |
723 net_log_, | 738 net_log_, |
724 num_streams_); | 739 num_streams_, |
740 base::Bind(&HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback, | |
741 base::Unretained(this))); | |
akalin
2012/01/19 22:12:48
weakptr?
Ryan Hamilton
2012/01/19 23:11:19
Done.
| |
725 } else { | 742 } else { |
726 return InitSocketHandleForHttpRequest( | 743 return InitSocketHandleForHttpRequest( |
727 origin_url_, request_info_.extra_headers, request_info_.load_flags, | 744 origin_url_, request_info_.extra_headers, request_info_.load_flags, |
728 request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(), | 745 request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(), |
729 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_, | 746 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_, |
730 connection_.get(), io_callback_); | 747 connection_.get(), io_callback_, |
748 base::Bind(&HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback, | |
749 base::Unretained(this))); | |
akalin
2012/01/19 22:12:48
weakptr?
Ryan Hamilton
2012/01/19 23:11:19
Done.
| |
731 } | 750 } |
732 } | 751 } |
733 | 752 |
734 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { | 753 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { |
735 if (IsPreconnecting()) { | 754 if (IsPreconnecting()) { |
736 DCHECK_EQ(OK, result); | 755 DCHECK_EQ(OK, result); |
737 return OK; | 756 return OK; |
738 } | 757 } |
739 | 758 |
740 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable | 759 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1208 return false; | 1227 return false; |
1209 } | 1228 } |
1210 if (request_info_.method != "GET" && request_info_.method != "HEAD") { | 1229 if (request_info_.method != "GET" && request_info_.method != "HEAD") { |
1211 return false; | 1230 return false; |
1212 } | 1231 } |
1213 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( | 1232 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( |
1214 origin_); | 1233 origin_); |
1215 } | 1234 } |
1216 | 1235 |
1217 } // namespace net | 1236 } // namespace net |
OLD | NEW |