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 #include <utility> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
12 #include "base/location.h" | 13 #include "base/location.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
15 #include "base/metrics/sparse_histogram.h" | 16 #include "base/metrics/sparse_histogram.h" |
16 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
18 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 const AlternativeService* alternative_service, | 66 const AlternativeService* alternative_service, |
66 RequestPriority priority, | 67 RequestPriority priority, |
67 NetLogCaptureMode /* capture_mode */) { | 68 NetLogCaptureMode /* capture_mode */) { |
68 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 69 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
69 if (source.IsValid()) | 70 if (source.IsValid()) |
70 source.AddToEventParameters(dict.get()); | 71 source.AddToEventParameters(dict.get()); |
71 dict->SetString("original_url", original_url->GetOrigin().spec()); | 72 dict->SetString("original_url", original_url->GetOrigin().spec()); |
72 dict->SetString("url", url->GetOrigin().spec()); | 73 dict->SetString("url", url->GetOrigin().spec()); |
73 dict->SetString("alternative_service", alternative_service->ToString()); | 74 dict->SetString("alternative_service", alternative_service->ToString()); |
74 dict->SetString("priority", RequestPriorityToString(priority)); | 75 dict->SetString("priority", RequestPriorityToString(priority)); |
75 return dict.Pass(); | 76 return std::move(dict); |
76 } | 77 } |
77 | 78 |
78 // Returns parameters associated with the Proto (with NPN negotiation) of a HTTP | 79 // Returns parameters associated with the Proto (with NPN negotiation) of a HTTP |
79 // stream. | 80 // stream. |
80 scoped_ptr<base::Value> NetLogHttpStreamProtoCallback( | 81 scoped_ptr<base::Value> NetLogHttpStreamProtoCallback( |
81 const SSLClientSocket::NextProtoStatus status, | 82 const SSLClientSocket::NextProtoStatus status, |
82 const std::string* proto, | 83 const std::string* proto, |
83 NetLogCaptureMode /* capture_mode */) { | 84 NetLogCaptureMode /* capture_mode */) { |
84 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 85 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
85 | 86 |
86 dict->SetString("next_proto_status", | 87 dict->SetString("next_proto_status", |
87 SSLClientSocket::NextProtoStatusToString(status)); | 88 SSLClientSocket::NextProtoStatusToString(status)); |
88 dict->SetString("proto", *proto); | 89 dict->SetString("proto", *proto); |
89 return dict.Pass(); | 90 return std::move(dict); |
90 } | 91 } |
91 | 92 |
92 HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, | 93 HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, |
93 HttpNetworkSession* session, | 94 HttpNetworkSession* session, |
94 const HttpRequestInfo& request_info, | 95 const HttpRequestInfo& request_info, |
95 RequestPriority priority, | 96 RequestPriority priority, |
96 const SSLConfig& server_ssl_config, | 97 const SSLConfig& server_ssl_config, |
97 const SSLConfig& proxy_ssl_config, | 98 const SSLConfig& proxy_ssl_config, |
98 NetLog* net_log) | 99 NetLog* net_log) |
99 : Job(stream_factory, | 100 : Job(stream_factory, |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 DCHECK(!IsSpdyAlternative()); | 1253 DCHECK(!IsSpdyAlternative()); |
1253 // We may get ftp scheme when fetching ftp resources through proxy. | 1254 // We may get ftp scheme when fetching ftp resources through proxy. |
1254 bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && | 1255 bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && |
1255 (request_info_.url.SchemeIs("http") || | 1256 (request_info_.url.SchemeIs("http") || |
1256 request_info_.url.SchemeIs("ftp")); | 1257 request_info_.url.SchemeIs("ftp")); |
1257 if (stream_factory_->for_websockets_) { | 1258 if (stream_factory_->for_websockets_) { |
1258 DCHECK(request_); | 1259 DCHECK(request_); |
1259 DCHECK(request_->websocket_handshake_stream_create_helper()); | 1260 DCHECK(request_->websocket_handshake_stream_create_helper()); |
1260 websocket_stream_.reset( | 1261 websocket_stream_.reset( |
1261 request_->websocket_handshake_stream_create_helper() | 1262 request_->websocket_handshake_stream_create_helper() |
1262 ->CreateBasicStream(connection_.Pass(), using_proxy)); | 1263 ->CreateBasicStream(std::move(connection_), using_proxy)); |
1263 } else { | 1264 } else { |
1264 stream_.reset(new HttpBasicStream(connection_.release(), using_proxy)); | 1265 stream_.reset(new HttpBasicStream(connection_.release(), using_proxy)); |
1265 } | 1266 } |
1266 return OK; | 1267 return OK; |
1267 } | 1268 } |
1268 | 1269 |
1269 CHECK(!stream_.get()); | 1270 CHECK(!stream_.get()); |
1270 | 1271 |
1271 bool direct = !IsHttpsProxyAndHttpUrl(); | 1272 bool direct = !IsHttpsProxyAndHttpUrl(); |
1272 if (existing_spdy_session_.get()) { | 1273 if (existing_spdy_session_.get()) { |
(...skipping 13 matching lines...) Expand all Loading... |
1286 int result = valid_spdy_session_pool_->FindAvailableSession( | 1287 int result = valid_spdy_session_pool_->FindAvailableSession( |
1287 spdy_session_key, net_log_, &spdy_session); | 1288 spdy_session_key, net_log_, &spdy_session); |
1288 if (result != OK) { | 1289 if (result != OK) { |
1289 return result; | 1290 return result; |
1290 } | 1291 } |
1291 if (spdy_session) { | 1292 if (spdy_session) { |
1292 return SetSpdyHttpStreamOrBidirectionalStreamJob(spdy_session, direct); | 1293 return SetSpdyHttpStreamOrBidirectionalStreamJob(spdy_session, direct); |
1293 } | 1294 } |
1294 | 1295 |
1295 result = valid_spdy_session_pool_->CreateAvailableSessionFromSocket( | 1296 result = valid_spdy_session_pool_->CreateAvailableSessionFromSocket( |
1296 spdy_session_key, connection_.Pass(), net_log_, spdy_certificate_error_, | 1297 spdy_session_key, std::move(connection_), net_log_, |
1297 using_ssl_, &spdy_session); | 1298 spdy_certificate_error_, using_ssl_, &spdy_session); |
1298 if (result != OK) { | 1299 if (result != OK) { |
1299 return result; | 1300 return result; |
1300 } | 1301 } |
1301 | 1302 |
1302 if (!spdy_session->HasAcceptableTransportSecurity()) { | 1303 if (!spdy_session->HasAcceptableTransportSecurity()) { |
1303 spdy_session->CloseSessionOnError( | 1304 spdy_session->CloseSessionOnError( |
1304 ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY, ""); | 1305 ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY, ""); |
1305 return ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY; | 1306 return ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY; |
1306 } | 1307 } |
1307 | 1308 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 } | 1641 } |
1641 | 1642 |
1642 int HttpStreamFactoryImpl::Job::ValidSpdySessionPool:: | 1643 int HttpStreamFactoryImpl::Job::ValidSpdySessionPool:: |
1643 CreateAvailableSessionFromSocket(const SpdySessionKey& key, | 1644 CreateAvailableSessionFromSocket(const SpdySessionKey& key, |
1644 scoped_ptr<ClientSocketHandle> connection, | 1645 scoped_ptr<ClientSocketHandle> connection, |
1645 const BoundNetLog& net_log, | 1646 const BoundNetLog& net_log, |
1646 int certificate_error_code, | 1647 int certificate_error_code, |
1647 bool is_secure, | 1648 bool is_secure, |
1648 base::WeakPtr<SpdySession>* spdy_session) { | 1649 base::WeakPtr<SpdySession>* spdy_session) { |
1649 *spdy_session = spdy_session_pool_->CreateAvailableSessionFromSocket( | 1650 *spdy_session = spdy_session_pool_->CreateAvailableSessionFromSocket( |
1650 key, connection.Pass(), net_log, certificate_error_code, is_secure); | 1651 key, std::move(connection), net_log, certificate_error_code, is_secure); |
1651 return CheckAlternativeServiceValidityForOrigin(*spdy_session); | 1652 return CheckAlternativeServiceValidityForOrigin(*spdy_session); |
1652 } | 1653 } |
1653 | 1654 |
1654 int HttpStreamFactoryImpl::Job::ValidSpdySessionPool:: | 1655 int HttpStreamFactoryImpl::Job::ValidSpdySessionPool:: |
1655 CheckAlternativeServiceValidityForOrigin( | 1656 CheckAlternativeServiceValidityForOrigin( |
1656 base::WeakPtr<SpdySession> spdy_session) { | 1657 base::WeakPtr<SpdySession> spdy_session) { |
1657 // For an alternative Job, server_.host() might be different than | 1658 // For an alternative Job, server_.host() might be different than |
1658 // origin_url_.host(), therefore it needs to be verified that the former | 1659 // origin_url_.host(), therefore it needs to be verified that the former |
1659 // provides a certificate that is valid for the latter. | 1660 // provides a certificate that is valid for the latter. |
1660 if (!is_spdy_alternative_ || !spdy_session || | 1661 if (!is_spdy_alternative_ || !spdy_session || |
(...skipping 28 matching lines...) Expand all Loading... |
1689 if (connection_->socket()) { | 1690 if (connection_->socket()) { |
1690 ConnectionAttempts socket_attempts; | 1691 ConnectionAttempts socket_attempts; |
1691 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1692 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
1692 request_->AddConnectionAttempts(socket_attempts); | 1693 request_->AddConnectionAttempts(socket_attempts); |
1693 } else { | 1694 } else { |
1694 request_->AddConnectionAttempts(connection_->connection_attempts()); | 1695 request_->AddConnectionAttempts(connection_->connection_attempts()); |
1695 } | 1696 } |
1696 } | 1697 } |
1697 | 1698 |
1698 } // namespace net | 1699 } // namespace net |
OLD | NEW |