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