Chromium Code Reviews| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 session_->http_server_properties(); | 174 session_->http_server_properties(); |
| 175 if (http_server_properties && | 175 if (http_server_properties && |
| 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 MessageLoop::current()->PostTask( |
| 186 DCHECK(establishing_tunnel_); | 186 FROM_HERE, |
| 187 next_state_ = STATE_RESTART_TUNNEL_AUTH; | 187 base::Bind(&HttpStreamFactoryImpl::Job::DoRestartTunnelWithProxyAuth, |
|
cbentzel
2012/01/20 02:09:46
Is this to prevent potential reentrancy if OnNeeds
Ryan Hamilton
2012/01/20 04:20:04
Yes... Specifically, we want to invoke the callbac
| |
| 188 stream_.reset(); | 188 ptr_factory_.GetWeakPtr())); |
| 189 return RunLoop(OK); | 189 return ERR_IO_PENDING; |
| 190 } | |
| 191 | |
| 192 void HttpStreamFactoryImpl::Job::DoRestartTunnelWithProxyAuth() { | |
| 193 tunnel_auth_handled_callback_.Run(OK); | |
| 190 } | 194 } |
| 191 | 195 |
| 192 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { | 196 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { |
| 193 switch (next_state_) { | 197 switch (next_state_) { |
| 194 case STATE_RESOLVE_PROXY_COMPLETE: | 198 case STATE_RESOLVE_PROXY_COMPLETE: |
| 195 return session_->proxy_service()->GetLoadState(pac_request_); | 199 return session_->proxy_service()->GetLoadState(pac_request_); |
| 196 case STATE_CREATE_STREAM_COMPLETE: | 200 case STATE_CREATE_STREAM_COMPLETE: |
| 197 return connection_->GetLoadState(); | 201 return connection_->GetLoadState(); |
| 198 case STATE_INIT_CONNECTION_COMPLETE: | 202 case STATE_INIT_CONNECTION_COMPLETE: |
| 199 return LOAD_STATE_SENDING_REQUEST; | 203 return LOAD_STATE_SENDING_REQUEST; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 HttpAuthController* auth_controller) { | 339 HttpAuthController* auth_controller) { |
| 336 DCHECK(!IsPreconnecting()); | 340 DCHECK(!IsPreconnecting()); |
| 337 if (IsOrphaned()) | 341 if (IsOrphaned()) |
| 338 stream_factory_->OnOrphanedJobComplete(this); | 342 stream_factory_->OnOrphanedJobComplete(this); |
| 339 else | 343 else |
| 340 request_->OnNeedsProxyAuth( | 344 request_->OnNeedsProxyAuth( |
| 341 this, response, server_ssl_config_, proxy_info_, auth_controller); | 345 this, response, server_ssl_config_, proxy_info_, auth_controller); |
| 342 // |this| may be deleted after this call. | 346 // |this| may be deleted after this call. |
| 343 } | 347 } |
| 344 | 348 |
| 349 void HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback( | |
| 350 const HttpResponseInfo& response_info, | |
| 351 HttpAuthController* auth_controller, | |
| 352 CompletionCallback callback) { | |
| 353 tunnel_auth_handled_callback_ = callback; | |
|
cbentzel
2012/01/20 02:09:46
Should this DCHECK that callback is non-null?
Ryan Hamilton
2012/01/20 04:20:04
Steve had the same suggestion, but it's an object,
cbentzel
2012/01/20 11:15:46
I meant DCHECK(!callback.is_null());
I try to use
Ryan Hamilton
2012/01/20 17:20:13
Ah! I see. I added a check that callback is not
| |
| 354 request_->OnNeedsProxyAuth( | |
| 355 this, response_info, server_ssl_config_, proxy_info_, auth_controller); | |
| 356 // |this| may be deleted after this call. | |
| 357 } | |
| 358 | |
| 345 void HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback( | 359 void HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback( |
| 346 SSLCertRequestInfo* cert_info) { | 360 SSLCertRequestInfo* cert_info) { |
| 347 DCHECK(!IsPreconnecting()); | 361 DCHECK(!IsPreconnecting()); |
| 348 if (IsOrphaned()) | 362 if (IsOrphaned()) |
| 349 stream_factory_->OnOrphanedJobComplete(this); | 363 stream_factory_->OnOrphanedJobComplete(this); |
| 350 else | 364 else |
| 351 request_->OnNeedsClientAuth(this, server_ssl_config_, cert_info); | 365 request_->OnNeedsClientAuth(this, server_ssl_config_, cert_info); |
| 352 // |this| may be deleted after this call. | 366 // |this| may be deleted after this call. |
| 353 } | 367 } |
| 354 | 368 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 return ERR_IO_PENDING; | 423 return ERR_IO_PENDING; |
| 410 } | 424 } |
| 411 | 425 |
| 412 switch (result) { | 426 switch (result) { |
| 413 case ERR_PROXY_AUTH_REQUESTED: | 427 case ERR_PROXY_AUTH_REQUESTED: |
| 414 { | 428 { |
| 415 DCHECK(connection_.get()); | 429 DCHECK(connection_.get()); |
| 416 DCHECK(connection_->socket()); | 430 DCHECK(connection_->socket()); |
| 417 DCHECK(establishing_tunnel_); | 431 DCHECK(establishing_tunnel_); |
| 418 | 432 |
| 419 HttpProxyClientSocket* http_proxy_socket = | 433 ProxyClientSocket* proxy_socket = |
| 420 static_cast<HttpProxyClientSocket*>(connection_->socket()); | 434 static_cast<ProxyClientSocket*>(connection_->socket()); |
| 421 const HttpResponseInfo* tunnel_auth_response = | 435 const HttpResponseInfo* tunnel_auth_response = |
| 422 http_proxy_socket->GetConnectResponseInfo(); | 436 proxy_socket->GetConnectResponseInfo(); |
| 423 | 437 |
| 424 next_state_ = STATE_WAITING_USER_ACTION; | 438 next_state_ = STATE_WAITING_USER_ACTION; |
| 425 MessageLoop::current()->PostTask( | 439 MessageLoop::current()->PostTask( |
| 426 FROM_HERE, | 440 FROM_HERE, |
| 427 base::Bind( | 441 base::Bind( |
| 428 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, | 442 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, |
| 429 ptr_factory_.GetWeakPtr(), | 443 ptr_factory_.GetWeakPtr(), |
| 430 *tunnel_auth_response, | 444 *tunnel_auth_response, |
| 431 http_proxy_socket->auth_controller())); | 445 proxy_socket->auth_controller())); |
| 432 } | 446 } |
| 433 return ERR_IO_PENDING; | 447 return ERR_IO_PENDING; |
| 434 | 448 |
| 435 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: | 449 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: |
| 436 MessageLoop::current()->PostTask( | 450 MessageLoop::current()->PostTask( |
| 437 FROM_HERE, | 451 FROM_HERE, |
| 438 base::Bind( | 452 base::Bind( |
| 439 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, | 453 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, |
| 440 ptr_factory_.GetWeakPtr(), | 454 ptr_factory_.GetWeakPtr(), |
| 441 connection_->ssl_error_response_info().cert_request_info)); | 455 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, | 728 request_info_.extra_headers, |
| 715 request_info_.load_flags, | 729 request_info_.load_flags, |
| 716 request_info_.priority, | 730 request_info_.priority, |
| 717 session_, | 731 session_, |
| 718 proxy_info_, | 732 proxy_info_, |
| 719 ShouldForceSpdySSL(), | 733 ShouldForceSpdySSL(), |
| 720 want_spdy_over_npn, | 734 want_spdy_over_npn, |
| 721 server_ssl_config_, | 735 server_ssl_config_, |
| 722 proxy_ssl_config_, | 736 proxy_ssl_config_, |
| 723 net_log_, | 737 net_log_, |
| 724 num_streams_); | 738 num_streams_, |
| 739 base::Bind(&HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback, | |
| 740 ptr_factory_.GetWeakPtr())); | |
| 725 } else { | 741 } else { |
| 726 return InitSocketHandleForHttpRequest( | 742 return InitSocketHandleForHttpRequest( |
| 727 origin_url_, request_info_.extra_headers, request_info_.load_flags, | 743 origin_url_, request_info_.extra_headers, request_info_.load_flags, |
| 728 request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(), | 744 request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(), |
| 729 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_, | 745 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_, |
| 730 connection_.get(), io_callback_); | 746 connection_.get(), |
| 747 base::Bind(&HttpStreamFactoryImpl::Job::OnNeedsProxyTunnelAuthCallback, | |
| 748 ptr_factory_.GetWeakPtr()), | |
| 749 io_callback_); | |
| 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 |