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" |
11 #include "net/base/net_util.h" | 11 #include "net/base/net_util.h" |
12 #include "net/http/http_network_session.h" | 12 #include "net/http/http_network_session.h" |
13 #include "net/http/http_server_properties.h" | 13 #include "net/http/http_server_properties.h" |
14 #include "net/http/http_stream_factory_impl_job.h" | 14 #include "net/http/http_stream_factory_impl_job.h" |
15 #include "net/http/http_stream_factory_impl_request.h" | 15 #include "net/http/http_stream_factory_impl_request.h" |
16 #include "net/log/net_log.h" | 16 #include "net/log/net_log.h" |
| 17 #include "net/net_features.h" |
17 #include "net/quic/quic_server_id.h" | 18 #include "net/quic/quic_server_id.h" |
18 #include "net/spdy/spdy_http_stream.h" | 19 #include "net/spdy/spdy_http_stream.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 #if defined(ENABLE_BIDIRECTIONAL_STREAM) | 22 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
22 #include "net/spdy/bidirectional_stream_spdy_job.h" | 23 #include "net/spdy/bidirectional_stream_spdy_job.h" |
23 #endif | 24 #endif |
24 | 25 |
25 namespace net { | 26 namespace net { |
26 | 27 |
27 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, | 28 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, |
28 bool for_websockets) | 29 bool for_websockets) |
29 : session_(session), | 30 : session_(session), |
30 for_websockets_(for_websockets) {} | 31 for_websockets_(for_websockets) {} |
31 | 32 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 const HttpRequestInfo& request_info, | 85 const HttpRequestInfo& request_info, |
85 RequestPriority priority, | 86 RequestPriority priority, |
86 const SSLConfig& server_ssl_config, | 87 const SSLConfig& server_ssl_config, |
87 const SSLConfig& proxy_ssl_config, | 88 const SSLConfig& proxy_ssl_config, |
88 HttpStreamRequest::Delegate* delegate, | 89 HttpStreamRequest::Delegate* delegate, |
89 const BoundNetLog& net_log) { | 90 const BoundNetLog& net_log) { |
90 DCHECK(!for_websockets_); | 91 DCHECK(!for_websockets_); |
91 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme)); | 92 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme)); |
92 | 93 |
93 // TODO(xunjieli): Create QUIC's version of BidirectionalStreamJob. | 94 // TODO(xunjieli): Create QUIC's version of BidirectionalStreamJob. |
94 #if defined(ENABLE_BIDIRECTIONAL_STREAM) | 95 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
95 HostPortPair server = HostPortPair::FromURL(request_info.url); | 96 HostPortPair server = HostPortPair::FromURL(request_info.url); |
96 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); | 97 GURL origin_url = ApplyHostMappingRules(request_info.url, &server); |
97 Request* request = | 98 Request* request = |
98 new Request(request_info.url, this, delegate, nullptr, net_log, | 99 new Request(request_info.url, this, delegate, nullptr, net_log, |
99 Request::BIDIRECTIONAL_STREAM_SPDY_JOB); | 100 Request::BIDIRECTIONAL_STREAM_SPDY_JOB); |
100 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, | 101 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, |
101 proxy_ssl_config, server, origin_url, net_log.net_log()); | 102 proxy_ssl_config, server, origin_url, net_log.net_log()); |
102 request->AttachJob(job); | 103 request->AttachJob(job); |
103 | 104 |
104 job->Start(request); | 105 job->Start(request); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // that it matters here. | 331 // that it matters here. |
331 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) | 332 if (!ContainsKey(spdy_session_request_map_, spdy_session_key)) |
332 break; | 333 break; |
333 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); | 334 Request* request = *spdy_session_request_map_[spdy_session_key].begin(); |
334 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); | 335 request->Complete(was_npn_negotiated, protocol_negotiated, using_spdy); |
335 if (for_websockets_) { | 336 if (for_websockets_) { |
336 // TODO(ricea): Restore this code path when WebSocket over SPDY | 337 // TODO(ricea): Restore this code path when WebSocket over SPDY |
337 // implementation is ready. | 338 // implementation is ready. |
338 NOTREACHED(); | 339 NOTREACHED(); |
339 } else if (request->for_bidirectional()) { | 340 } else if (request->for_bidirectional()) { |
340 #if defined(ENABLE_BIDIRECTIONAL_STREAM) | 341 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM) |
341 request->OnBidirectionalStreamJobReady( | 342 request->OnBidirectionalStreamJobReady( |
342 nullptr, used_ssl_config, used_proxy_info, | 343 nullptr, used_ssl_config, used_proxy_info, |
343 new BidirectionalStreamSpdyJob(spdy_session)); | 344 new BidirectionalStreamSpdyJob(spdy_session)); |
344 #else | 345 #else |
345 DCHECK(false); | 346 DCHECK(false); |
346 #endif | 347 #endif |
347 } else { | 348 } else { |
348 bool use_relative_url = direct || request->url().SchemeIs("https"); | 349 bool use_relative_url = direct || request->url().SchemeIs("https"); |
349 request->OnStreamReady( | 350 request->OnStreamReady( |
350 nullptr, used_ssl_config, used_proxy_info, | 351 nullptr, used_ssl_config, used_proxy_info, |
351 new SpdyHttpStream(spdy_session, use_relative_url)); | 352 new SpdyHttpStream(spdy_session, use_relative_url)); |
352 } | 353 } |
353 } | 354 } |
354 // TODO(mbelshe): Alert other valid requests. | 355 // TODO(mbelshe): Alert other valid requests. |
355 } | 356 } |
356 | 357 |
357 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) { | 358 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) { |
358 orphaned_job_set_.erase(job); | 359 orphaned_job_set_.erase(job); |
359 delete job; | 360 delete job; |
360 } | 361 } |
361 | 362 |
362 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { | 363 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { |
363 preconnect_job_set_.erase(job); | 364 preconnect_job_set_.erase(job); |
364 delete job; | 365 delete job; |
365 OnPreconnectsCompleteInternal(); | 366 OnPreconnectsCompleteInternal(); |
366 } | 367 } |
367 | 368 |
368 } // namespace net | 369 } // namespace net |
OLD | NEW |