| 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.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( | 49 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( |
| 50 const HttpRequestInfo& request_info, | 50 const HttpRequestInfo& request_info, |
| 51 RequestPriority priority, | 51 RequestPriority priority, |
| 52 const SSLConfig& server_ssl_config, | 52 const SSLConfig& server_ssl_config, |
| 53 const SSLConfig& proxy_ssl_config, | 53 const SSLConfig& proxy_ssl_config, |
| 54 HttpStreamRequest::Delegate* delegate, | 54 HttpStreamRequest::Delegate* delegate, |
| 55 const BoundNetLog& net_log) { | 55 const BoundNetLog& net_log) { |
| 56 DCHECK(!for_websockets_); | 56 DCHECK(!for_websockets_); |
| 57 return RequestStreamInternal(request_info, priority, server_ssl_config, | 57 return RequestStreamInternal(request_info, |
| 58 proxy_ssl_config, delegate, nullptr, | 58 priority, |
| 59 HttpStreamRequest::HTTP_STREAM, net_log); | 59 server_ssl_config, |
| 60 proxy_ssl_config, |
| 61 delegate, |
| 62 NULL, |
| 63 net_log); |
| 60 } | 64 } |
| 61 | 65 |
| 62 HttpStreamRequest* HttpStreamFactoryImpl::RequestWebSocketHandshakeStream( | 66 HttpStreamRequest* HttpStreamFactoryImpl::RequestWebSocketHandshakeStream( |
| 63 const HttpRequestInfo& request_info, | 67 const HttpRequestInfo& request_info, |
| 64 RequestPriority priority, | 68 RequestPriority priority, |
| 65 const SSLConfig& server_ssl_config, | 69 const SSLConfig& server_ssl_config, |
| 66 const SSLConfig& proxy_ssl_config, | 70 const SSLConfig& proxy_ssl_config, |
| 67 HttpStreamRequest::Delegate* delegate, | 71 HttpStreamRequest::Delegate* delegate, |
| 68 WebSocketHandshakeStreamBase::CreateHelper* create_helper, | 72 WebSocketHandshakeStreamBase::CreateHelper* create_helper, |
| 69 const BoundNetLog& net_log) { | 73 const BoundNetLog& net_log) { |
| 70 DCHECK(for_websockets_); | 74 DCHECK(for_websockets_); |
| 71 DCHECK(create_helper); | 75 DCHECK(create_helper); |
| 72 return RequestStreamInternal(request_info, priority, server_ssl_config, | 76 return RequestStreamInternal(request_info, |
| 73 proxy_ssl_config, delegate, create_helper, | 77 priority, |
| 74 HttpStreamRequest::HTTP_STREAM, net_log); | 78 server_ssl_config, |
| 79 proxy_ssl_config, |
| 80 delegate, |
| 81 create_helper, |
| 82 net_log); |
| 75 } | 83 } |
| 76 | 84 |
| 77 HttpStreamRequest* HttpStreamFactoryImpl::RequestBidirectionalStreamJob( | 85 HttpStreamRequest* HttpStreamFactoryImpl::RequestBidirectionalStreamJob( |
| 78 const HttpRequestInfo& request_info, | 86 const HttpRequestInfo& request_info, |
| 79 RequestPriority priority, | 87 RequestPriority priority, |
| 80 const SSLConfig& server_ssl_config, | 88 const SSLConfig& server_ssl_config, |
| 81 const SSLConfig& proxy_ssl_config, | 89 const SSLConfig& proxy_ssl_config, |
| 82 HttpStreamRequest::Delegate* delegate, | 90 HttpStreamRequest::Delegate* delegate, |
| 83 const BoundNetLog& net_log) { | 91 const BoundNetLog& net_log) { |
| 84 DCHECK(!for_websockets_); | 92 DCHECK(!for_websockets_); |
| 85 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme)); | 93 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme)); |
| 86 | 94 |
| 87 return RequestStreamInternal( | 95 // TODO(xunjieli): Create QUIC's version of BidirectionalStreamJob. |
| 88 request_info, priority, server_ssl_config, proxy_ssl_config, delegate, | 96 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
| 89 nullptr, HttpStreamRequest::BIDIRECTIONAL_STREAM, net_log); | 97 HostPortPair server = HostPortPair::FromURL(request_info.url); |
| 98 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); |
| 99 Request* request = |
| 100 new Request(request_info.url, this, delegate, nullptr, net_log, |
| 101 Request::BIDIRECTIONAL_STREAM_SPDY_JOB); |
| 102 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, |
| 103 proxy_ssl_config, server, origin_url, net_log.net_log()); |
| 104 request->AttachJob(job); |
| 105 |
| 106 job->Start(request); |
| 107 return request; |
| 108 |
| 109 #else |
| 110 DCHECK(false); |
| 111 return nullptr; |
| 112 #endif |
| 90 } | 113 } |
| 91 | 114 |
| 92 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( | 115 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( |
| 93 const HttpRequestInfo& request_info, | 116 const HttpRequestInfo& request_info, |
| 94 RequestPriority priority, | 117 RequestPriority priority, |
| 95 const SSLConfig& server_ssl_config, | 118 const SSLConfig& server_ssl_config, |
| 96 const SSLConfig& proxy_ssl_config, | 119 const SSLConfig& proxy_ssl_config, |
| 97 HttpStreamRequest::Delegate* delegate, | 120 HttpStreamRequest::Delegate* delegate, |
| 98 WebSocketHandshakeStreamBase::CreateHelper* | 121 WebSocketHandshakeStreamBase::CreateHelper* |
| 99 websocket_handshake_stream_create_helper, | 122 websocket_handshake_stream_create_helper, |
| 100 HttpStreamRequest::StreamType stream_type, | |
| 101 const BoundNetLog& net_log) { | 123 const BoundNetLog& net_log) { |
| 102 Request* request = new Request(request_info.url, this, delegate, | 124 Request* request = new Request(request_info.url, this, delegate, |
| 103 websocket_handshake_stream_create_helper, | 125 websocket_handshake_stream_create_helper, |
| 104 net_log, stream_type); | 126 net_log, Request::HTTP_STREAM); |
| 105 HostPortPair server = HostPortPair::FromURL(request_info.url); | 127 HostPortPair server = HostPortPair::FromURL(request_info.url); |
| 106 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); | 128 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); |
| 107 | 129 |
| 108 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, | 130 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, |
| 109 proxy_ssl_config, server, origin_url, net_log.net_log()); | 131 proxy_ssl_config, server, origin_url, net_log.net_log()); |
| 110 request->AttachJob(job); | 132 request->AttachJob(job); |
| 111 | 133 |
| 112 const AlternativeService alternative_service = | 134 const AlternativeService alternative_service = |
| 113 GetAlternativeServiceFor(request_info, delegate); | 135 GetAlternativeServiceFor(request_info, delegate); |
| 114 | 136 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // queue (Order by priority first, then FIFO within same priority). Unclear | 331 // queue (Order by priority first, then FIFO within same priority). Unclear |
| 310 // that it matters here. | 332 // that it matters here. |
| 311 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) | 333 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) |
| 312 break; | 334 break; |
| 313 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); | 335 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); |
| 314 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); | 336 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); |
| 315 if (for_websockets_) { | 337 if (for_websockets_) { |
| 316 // TODO(ricea): Restore this code path when WebSocket over SPDY | 338 // TODO(ricea): Restore this code path when WebSocket over SPDY |
| 317 // implementation is ready. | 339 // implementation is ready. |
| 318 NOTREACHED(); | 340 NOTREACHED(); |
| 319 } else if (request->stream_type() == | 341 } else if (request->for_bidirectional()) { |
| 320 HttpStreamRequest::BIDIRECTIONAL_STREAM) { | |
| 321 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) | 342 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
| 322 request->OnBidirectionalStreamJobReady( | 343 request->OnBidirectionalStreamJobReady( |
| 323 nullptr, used_ssl_config, used_proxy_info, | 344 nullptr, used_ssl_config, used_proxy_info, |
| 324 new BidirectionalStreamSpdyJob(spdy_session)); | 345 new BidirectionalStreamSpdyJob(spdy_session)); |
| 325 #else | 346 #else |
| 326 DCHECK(false); | 347 DCHECK(false); |
| 327 #endif | 348 #endif |
| 328 } else { | 349 } else { |
| 329 bool use_relative_url = direct || request->url().SchemeIs("https"); | 350 bool use_relative_url = direct || request->url().SchemeIs("https"); |
| 330 request->OnStreamReady( | 351 request->OnStreamReady( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 360 return true; | 381 return true; |
| 361 | 382 |
| 362 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) | 383 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) |
| 363 return true; | 384 return true; |
| 364 | 385 |
| 365 return ContainsKey(session_->params().quic_host_whitelist, | 386 return ContainsKey(session_->params().quic_host_whitelist, |
| 366 base::ToLowerASCII(host)); | 387 base::ToLowerASCII(host)); |
| 367 } | 388 } |
| 368 | 389 |
| 369 } // namespace net | 390 } // namespace net |
| OLD | NEW |