| 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_request.h" | 5 #include "net/http/http_stream_factory_impl_request.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "net/http/http_stream_factory_impl_job.h" | 9 #include "net/http/http_stream_factory_impl_job.h" |
| 10 #include "net/spdy/spdy_http_stream.h" | 10 #include "net/spdy/spdy_http_stream.h" |
| 11 #include "net/spdy/spdy_session.h" | 11 #include "net/spdy/spdy_session.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 HttpStreamFactoryImpl::Request::Request(const GURL& url, | 15 HttpStreamFactoryImpl::Request::Request(const GURL& url, |
| 16 HttpStreamFactoryImpl* factory, | 16 HttpStreamFactoryImpl* factory, |
| 17 HttpStreamRequest::Delegate* delegate, | 17 HttpStreamRequest::Delegate* delegate, |
| 18 const BoundNetLog& net_log) | 18 const BoundNetLog& net_log) |
| 19 : url_(url), | 19 : url_(url), |
| 20 factory_(factory), | 20 factory_(factory), |
| 21 delegate_(delegate), | 21 delegate_(delegate), |
| 22 net_log_(net_log), | 22 net_log_(net_log), |
| 23 completed_(false), | 23 completed_(false), |
| 24 was_npn_negotiated_(false), | 24 was_npn_negotiated_(false), |
| 25 protocol_negotiated_(SSLClientSocket::kProtoUnknown), | 25 protocol_negotiated_(kProtoUnknown), |
| 26 using_spdy_(false) { | 26 using_spdy_(false) { |
| 27 DCHECK(factory_); | 27 DCHECK(factory_); |
| 28 DCHECK(delegate_); | 28 DCHECK(delegate_); |
| 29 | 29 |
| 30 net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL); | 30 net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL); |
| 31 } | 31 } |
| 32 | 32 |
| 33 HttpStreamFactoryImpl::Request::~Request() { | 33 HttpStreamFactoryImpl::Request::~Request() { |
| 34 if (bound_job_.get()) | 34 if (bound_job_.get()) |
| 35 DCHECK(jobs_.empty()); | 35 DCHECK(jobs_.empty()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) { | 72 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) { |
| 73 DCHECK(job); | 73 DCHECK(job); |
| 74 jobs_.insert(job); | 74 jobs_.insert(job); |
| 75 factory_->request_map_[job] = this; | 75 factory_->request_map_[job] = this; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void HttpStreamFactoryImpl::Request::Complete( | 78 void HttpStreamFactoryImpl::Request::Complete( |
| 79 bool was_npn_negotiated, | 79 bool was_npn_negotiated, |
| 80 SSLClientSocket::NextProto protocol_negotiated, | 80 NextProto protocol_negotiated, |
| 81 bool using_spdy, | 81 bool using_spdy, |
| 82 const BoundNetLog& job_net_log) { | 82 const BoundNetLog& job_net_log) { |
| 83 DCHECK(!completed_); | 83 DCHECK(!completed_); |
| 84 completed_ = true; | 84 completed_ = true; |
| 85 was_npn_negotiated_ = was_npn_negotiated; | 85 was_npn_negotiated_ = was_npn_negotiated; |
| 86 protocol_negotiated_ = protocol_negotiated; | 86 protocol_negotiated_ = protocol_negotiated; |
| 87 using_spdy_ = using_spdy; | 87 using_spdy_ = using_spdy; |
| 88 net_log_.AddEvent( | 88 net_log_.AddEvent( |
| 89 NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB, | 89 NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB, |
| 90 make_scoped_refptr(new NetLogSourceParameter( | 90 make_scoped_refptr(new NetLogSourceParameter( |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 // Just pick the first one. | 227 // Just pick the first one. |
| 228 return (*jobs_.begin())->GetLoadState(); | 228 return (*jobs_.begin())->GetLoadState(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool HttpStreamFactoryImpl::Request::was_npn_negotiated() const { | 231 bool HttpStreamFactoryImpl::Request::was_npn_negotiated() const { |
| 232 DCHECK(completed_); | 232 DCHECK(completed_); |
| 233 return was_npn_negotiated_; | 233 return was_npn_negotiated_; |
| 234 } | 234 } |
| 235 | 235 |
| 236 SSLClientSocket::NextProto HttpStreamFactoryImpl::Request::protocol_negotiated() | 236 NextProto HttpStreamFactoryImpl::Request::protocol_negotiated() |
| 237 const { | 237 const { |
| 238 DCHECK(completed_); | 238 DCHECK(completed_); |
| 239 return protocol_negotiated_; | 239 return protocol_negotiated_; |
| 240 } | 240 } |
| 241 | 241 |
| 242 bool HttpStreamFactoryImpl::Request::using_spdy() const { | 242 bool HttpStreamFactoryImpl::Request::using_spdy() const { |
| 243 DCHECK(completed_); | 243 DCHECK(completed_); |
| 244 return using_spdy_; | 244 return using_spdy_; |
| 245 } | 245 } |
| 246 | 246 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 OrphanJobsExcept(job); | 293 OrphanJobsExcept(job); |
| 294 } else { // This is the case for HTTPS proxy tunneling. | 294 } else { // This is the case for HTTPS proxy tunneling. |
| 295 DCHECK_EQ(bound_job_.get(), job); | 295 DCHECK_EQ(bound_job_.get(), job); |
| 296 DCHECK(jobs_.empty()); | 296 DCHECK(jobs_.empty()); |
| 297 } | 297 } |
| 298 | 298 |
| 299 // Cache these values in case the job gets deleted. | 299 // Cache these values in case the job gets deleted. |
| 300 const SSLConfig used_ssl_config = job->server_ssl_config(); | 300 const SSLConfig used_ssl_config = job->server_ssl_config(); |
| 301 const ProxyInfo used_proxy_info = job->proxy_info(); | 301 const ProxyInfo used_proxy_info = job->proxy_info(); |
| 302 const bool was_npn_negotiated = job->was_npn_negotiated(); | 302 const bool was_npn_negotiated = job->was_npn_negotiated(); |
| 303 const SSLClientSocket::NextProto protocol_negotiated = | 303 const NextProto protocol_negotiated = |
| 304 job->protocol_negotiated(); | 304 job->protocol_negotiated(); |
| 305 const bool using_spdy = job->using_spdy(); | 305 const bool using_spdy = job->using_spdy(); |
| 306 const BoundNetLog net_log = job->net_log(); | 306 const BoundNetLog net_log = job->net_log(); |
| 307 | 307 |
| 308 Complete(was_npn_negotiated, protocol_negotiated, using_spdy, net_log); | 308 Complete(was_npn_negotiated, protocol_negotiated, using_spdy, net_log); |
| 309 | 309 |
| 310 // Cache this so we can still use it if the request is deleted. | 310 // Cache this so we can still use it if the request is deleted. |
| 311 HttpStreamFactoryImpl* factory = factory_; | 311 HttpStreamFactoryImpl* factory = factory_; |
| 312 | 312 |
| 313 bool use_relative_url = direct || url().SchemeIs("https"); | 313 bool use_relative_url = direct || url().SchemeIs("https"); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 337 RemoveRequestFromHttpPipeliningRequestMap(); | 337 RemoveRequestFromHttpPipeliningRequestMap(); |
| 338 | 338 |
| 339 std::set<Job*> tmp; | 339 std::set<Job*> tmp; |
| 340 tmp.swap(jobs_); | 340 tmp.swap(jobs_); |
| 341 | 341 |
| 342 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it) | 342 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it) |
| 343 factory_->OrphanJob(*it, this); | 343 factory_->OrphanJob(*it, this); |
| 344 } | 344 } |
| 345 | 345 |
| 346 } // namespace net | 346 } // namespace net |
| OLD | NEW |