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