| OLD | NEW |
| 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 UMA_HISTOGRAM_ENUMERATION("Net.HttpStreamFactoryJob.Main.State", state_, | 378 UMA_HISTOGRAM_ENUMERATION("Net.HttpStreamFactoryJob.Main.State", state_, |
| 379 STATE_MAX); | 379 STATE_MAX); |
| 380 } else if (job_type_ == ALTERNATIVE) { | 380 } else if (job_type_ == ALTERNATIVE) { |
| 381 UMA_HISTOGRAM_ENUMERATION("Net.HttpStreamFactoryJob.Alt.NextState", | 381 UMA_HISTOGRAM_ENUMERATION("Net.HttpStreamFactoryJob.Alt.NextState", |
| 382 next_state_, STATE_MAX); | 382 next_state_, STATE_MAX); |
| 383 UMA_HISTOGRAM_ENUMERATION("Net.HttpStreamFactoryJob.Alt.State", state_, | 383 UMA_HISTOGRAM_ENUMERATION("Net.HttpStreamFactoryJob.Alt.State", state_, |
| 384 STATE_MAX); | 384 STATE_MAX); |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 | 387 |
| 388 void HttpStreamFactoryImpl::Job::GetSSLInfo() { | 388 void HttpStreamFactoryImpl::Job::GetSSLInfo(SSLInfo* ssl_info) { |
| 389 DCHECK(using_ssl_); | 389 DCHECK(using_ssl_); |
| 390 DCHECK(!establishing_tunnel_); | 390 DCHECK(!establishing_tunnel_); |
| 391 DCHECK(connection_.get() && connection_->socket()); | 391 DCHECK(connection_.get() && connection_->socket()); |
| 392 SSLClientSocket* ssl_socket = | 392 SSLClientSocket* ssl_socket = |
| 393 static_cast<SSLClientSocket*>(connection_->socket()); | 393 static_cast<SSLClientSocket*>(connection_->socket()); |
| 394 ssl_socket->GetSSLInfo(&ssl_info_); | 394 ssl_socket->GetSSLInfo(ssl_info); |
| 395 } | 395 } |
| 396 | 396 |
| 397 SpdySessionKey HttpStreamFactoryImpl::Job::GetSpdySessionKey() const { | 397 SpdySessionKey HttpStreamFactoryImpl::Job::GetSpdySessionKey() const { |
| 398 // In the case that we're using an HTTPS proxy for an HTTP url, | 398 // In the case that we're using an HTTPS proxy for an HTTP url, |
| 399 // we look for a SPDY session *to* the proxy, instead of to the | 399 // we look for a SPDY session *to* the proxy, instead of to the |
| 400 // origin server. | 400 // origin server. |
| 401 if (IsHttpsProxyAndHttpUrl()) { | 401 if (IsHttpsProxyAndHttpUrl()) { |
| 402 return SpdySessionKey(proxy_info_.proxy_server().host_port_pair(), | 402 return SpdySessionKey(proxy_info_.proxy_server().host_port_pair(), |
| 403 ProxyServer::Direct(), PRIVACY_MODE_DISABLED); | 403 ProxyServer::Direct(), PRIVACY_MODE_DISABLED); |
| 404 } | 404 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 if (job_type_ == PRECONNECT) { | 556 if (job_type_ == PRECONNECT) { |
| 557 base::ThreadTaskRunnerHandle::Get()->PostTask( | 557 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 558 FROM_HERE, | 558 FROM_HERE, |
| 559 base::Bind(&HttpStreamFactoryImpl::Job::OnPreconnectsComplete, | 559 base::Bind(&HttpStreamFactoryImpl::Job::OnPreconnectsComplete, |
| 560 ptr_factory_.GetWeakPtr())); | 560 ptr_factory_.GetWeakPtr())); |
| 561 return; | 561 return; |
| 562 } | 562 } |
| 563 | 563 |
| 564 if (IsCertificateError(result)) { | 564 if (IsCertificateError(result)) { |
| 565 // Retrieve SSL information from the socket. | 565 // Retrieve SSL information from the socket. |
| 566 GetSSLInfo(); | 566 SSLInfo ssl_info; |
| 567 GetSSLInfo(&ssl_info); |
| 567 | 568 |
| 568 next_state_ = STATE_WAITING_USER_ACTION; | 569 next_state_ = STATE_WAITING_USER_ACTION; |
| 569 base::ThreadTaskRunnerHandle::Get()->PostTask( | 570 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 570 FROM_HERE, | 571 FROM_HERE, |
| 571 base::Bind(&HttpStreamFactoryImpl::Job::OnCertificateErrorCallback, | 572 base::Bind(&HttpStreamFactoryImpl::Job::OnCertificateErrorCallback, |
| 572 ptr_factory_.GetWeakPtr(), result, ssl_info_)); | 573 ptr_factory_.GetWeakPtr(), result, ssl_info)); |
| 573 return; | 574 return; |
| 574 } | 575 } |
| 575 | 576 |
| 576 switch (result) { | 577 switch (result) { |
| 577 case ERR_PROXY_AUTH_REQUESTED: { | 578 case ERR_PROXY_AUTH_REQUESTED: { |
| 578 UMA_HISTOGRAM_BOOLEAN("Net.ProxyAuthRequested.HasConnection", | 579 UMA_HISTOGRAM_BOOLEAN("Net.ProxyAuthRequested.HasConnection", |
| 579 connection_.get() != NULL); | 580 connection_.get() != NULL); |
| 580 if (!connection_.get()) { | 581 if (!connection_.get()) { |
| 581 base::ThreadTaskRunnerHandle::Get()->PostTask( | 582 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 582 FROM_HERE, | 583 FROM_HERE, |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 } | 1382 } |
| 1382 | 1383 |
| 1383 should_reconsider_proxy_ = true; | 1384 should_reconsider_proxy_ = true; |
| 1384 return error; | 1385 return error; |
| 1385 } | 1386 } |
| 1386 | 1387 |
| 1387 int HttpStreamFactoryImpl::Job::HandleCertificateError(int error) { | 1388 int HttpStreamFactoryImpl::Job::HandleCertificateError(int error) { |
| 1388 DCHECK(using_ssl_); | 1389 DCHECK(using_ssl_); |
| 1389 DCHECK(IsCertificateError(error)); | 1390 DCHECK(IsCertificateError(error)); |
| 1390 | 1391 |
| 1391 SSLClientSocket* ssl_socket = | 1392 SSLInfo ssl_info; |
| 1392 static_cast<SSLClientSocket*>(connection_->socket()); | 1393 GetSSLInfo(&ssl_info); |
| 1393 ssl_socket->GetSSLInfo(&ssl_info_); | |
| 1394 | 1394 |
| 1395 if (!ssl_info_.cert) { | 1395 if (!ssl_info.cert) { |
| 1396 // If the server's certificate could not be parsed, there is no way | 1396 // If the server's certificate could not be parsed, there is no way |
| 1397 // to gracefully recover this, so just pass the error up. | 1397 // to gracefully recover this, so just pass the error up. |
| 1398 return error; | 1398 return error; |
| 1399 } | 1399 } |
| 1400 | 1400 |
| 1401 // Add the bad certificate to the set of allowed certificates in the | 1401 // Add the bad certificate to the set of allowed certificates in the |
| 1402 // SSL config object. This data structure will be consulted after calling | 1402 // SSL config object. This data structure will be consulted after calling |
| 1403 // RestartIgnoringLastError(). And the user will be asked interactively | 1403 // RestartIgnoringLastError(). And the user will be asked interactively |
| 1404 // before RestartIgnoringLastError() is ever called. | 1404 // before RestartIgnoringLastError() is ever called. |
| 1405 server_ssl_config_.allowed_bad_certs.emplace_back(ssl_info_.cert, | 1405 server_ssl_config_.allowed_bad_certs.emplace_back(ssl_info.cert, |
| 1406 ssl_info_.cert_status); | 1406 ssl_info.cert_status); |
| 1407 | 1407 |
| 1408 int load_flags = request_info_.load_flags; | 1408 int load_flags = request_info_.load_flags; |
| 1409 if (session_->params().ignore_certificate_errors) | 1409 if (session_->params().ignore_certificate_errors) |
| 1410 load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; | 1410 load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; |
| 1411 if (ssl_socket->IgnoreCertError(error, load_flags)) | 1411 if (SSLClientSocket::IgnoreCertError(error, load_flags)) |
| 1412 return OK; | 1412 return OK; |
| 1413 return error; | 1413 return error; |
| 1414 } | 1414 } |
| 1415 | 1415 |
| 1416 ClientSocketPoolManager::SocketGroupType | 1416 ClientSocketPoolManager::SocketGroupType |
| 1417 HttpStreamFactoryImpl::Job::GetSocketGroup() const { | 1417 HttpStreamFactoryImpl::Job::GetSocketGroup() const { |
| 1418 std::string scheme = origin_url_.scheme(); | 1418 std::string scheme = origin_url_.scheme(); |
| 1419 if (scheme == url::kHttpsScheme || scheme == url::kWssScheme) | 1419 if (scheme == url::kHttpsScheme || scheme == url::kWssScheme) |
| 1420 return ClientSocketPoolManager::SSL_GROUP; | 1420 return ClientSocketPoolManager::SSL_GROUP; |
| 1421 | 1421 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 bool enable_ip_based_pooling, | 1504 bool enable_ip_based_pooling, |
| 1505 NetLog* net_log) { | 1505 NetLog* net_log) { |
| 1506 return base::MakeUnique<HttpStreamFactoryImpl::Job>( | 1506 return base::MakeUnique<HttpStreamFactoryImpl::Job>( |
| 1507 delegate, job_type, session, request_info, priority, proxy_info, | 1507 delegate, job_type, session, request_info, priority, proxy_info, |
| 1508 server_ssl_config, proxy_ssl_config, destination, origin_url, | 1508 server_ssl_config, proxy_ssl_config, destination, origin_url, |
| 1509 AlternativeService(), alternative_proxy_server, enable_ip_based_pooling, | 1509 AlternativeService(), alternative_proxy_server, enable_ip_based_pooling, |
| 1510 net_log); | 1510 net_log); |
| 1511 } | 1511 } |
| 1512 | 1512 |
| 1513 } // namespace net | 1513 } // namespace net |
| OLD | NEW |