| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "net/base/net_log.h" | 10 #include "net/base/net_log.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_pipelined_connection.h" |
| 14 #include "net/http/http_pipelined_host.h" |
| 15 #include "net/http/http_pipelined_stream.h" |
| 13 #include "net/http/http_server_properties.h" | 16 #include "net/http/http_server_properties.h" |
| 14 #include "net/http/http_stream_factory_impl_job.h" | 17 #include "net/http/http_stream_factory_impl_job.h" |
| 15 #include "net/http/http_stream_factory_impl_request.h" | 18 #include "net/http/http_stream_factory_impl_request.h" |
| 16 #include "net/spdy/spdy_http_stream.h" | 19 #include "net/spdy/spdy_http_stream.h" |
| 17 | 20 |
| 18 namespace net { | 21 namespace net { |
| 19 | 22 |
| 20 namespace { | 23 namespace { |
| 21 | 24 |
| 22 GURL UpgradeUrlToHttps(const GURL& original_url, int port) { | 25 GURL UpgradeUrlToHttps(const GURL& original_url, int port) { |
| 23 GURL::Replacements replacements; | 26 GURL::Replacements replacements; |
| 24 // new_sheme and new_port need to be in scope here because GURL::Replacements | 27 // new_sheme and new_port need to be in scope here because GURL::Replacements |
| 25 // references the memory contained by them directly. | 28 // references the memory contained by them directly. |
| 26 const std::string new_scheme = "https"; | 29 const std::string new_scheme = "https"; |
| 27 const std::string new_port = base::IntToString(port); | 30 const std::string new_port = base::IntToString(port); |
| 28 replacements.SetSchemeStr(new_scheme); | 31 replacements.SetSchemeStr(new_scheme); |
| 29 replacements.SetPortStr(new_port); | 32 replacements.SetPortStr(new_port); |
| 30 return original_url.ReplaceComponents(replacements); | 33 return original_url.ReplaceComponents(replacements); |
| 31 } | 34 } |
| 32 | 35 |
| 33 } // namespace | 36 } // namespace |
| 34 | 37 |
| 35 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session) | 38 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session) |
| 36 : session_(session) {} | 39 : session_(session), |
| 40 http_pipelined_host_pool_(this) {} |
| 37 | 41 |
| 38 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { | 42 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { |
| 39 DCHECK(request_map_.empty()); | 43 DCHECK(request_map_.empty()); |
| 40 DCHECK(spdy_session_request_map_.empty()); | 44 DCHECK(spdy_session_request_map_.empty()); |
| 41 | 45 |
| 42 std::set<const Job*> tmp_job_set; | 46 std::set<const Job*> tmp_job_set; |
| 43 tmp_job_set.swap(orphaned_job_set_); | 47 tmp_job_set.swap(orphaned_job_set_); |
| 44 STLDeleteContainerPointers(tmp_job_set.begin(), tmp_job_set.end()); | 48 STLDeleteContainerPointers(tmp_job_set.begin(), tmp_job_set.end()); |
| 45 DCHECK(orphaned_job_set_.empty()); | 49 DCHECK(orphaned_job_set_.empty()); |
| 46 | 50 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 orphaned_job_set_.erase(job); | 218 orphaned_job_set_.erase(job); |
| 215 delete job; | 219 delete job; |
| 216 } | 220 } |
| 217 | 221 |
| 218 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { | 222 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { |
| 219 preconnect_job_set_.erase(job); | 223 preconnect_job_set_.erase(job); |
| 220 delete job; | 224 delete job; |
| 221 OnPreconnectsCompleteInternal(); | 225 OnPreconnectsCompleteInternal(); |
| 222 } | 226 } |
| 223 | 227 |
| 228 void HttpStreamFactoryImpl::OnHttpPipelinedHostHasAdditionalCapacity( |
| 229 const HostPortPair& origin) { |
| 230 HttpPipelinedStream* stream; |
| 231 while (ContainsKey(http_pipelining_request_map_, origin) && |
| 232 (stream = http_pipelined_host_pool_.CreateStreamOnExistingPipeline( |
| 233 origin))) { |
| 234 Request* request = *http_pipelining_request_map_[origin].begin(); |
| 235 request->Complete(stream->was_npn_negotiated(), |
| 236 false, // not using_spdy |
| 237 stream->source()); |
| 238 request->OnStreamReady(NULL, |
| 239 stream->used_ssl_config(), |
| 240 stream->used_proxy_info(), |
| 241 stream); |
| 242 } |
| 243 } |
| 244 |
| 224 } // namespace net | 245 } // namespace net |
| OLD | NEW |