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/callback.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
9 #include "net/http/http_stream_factory_impl_job.h" | 10 #include "net/http/http_stream_factory_impl_job.h" |
10 #include "net/spdy/spdy_http_stream.h" | 11 #include "net/spdy/spdy_http_stream.h" |
11 #include "net/spdy/spdy_session.h" | 12 #include "net/spdy/spdy_session.h" |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 | 15 |
15 HttpStreamFactoryImpl::Request::Request(const GURL& url, | 16 HttpStreamFactoryImpl::Request::Request(const GURL& url, |
16 HttpStreamFactoryImpl* factory, | 17 HttpStreamFactoryImpl* factory, |
17 HttpStreamRequest::Delegate* delegate, | 18 HttpStreamRequest::Delegate* delegate, |
18 const BoundNetLog& net_log) | 19 const BoundNetLog& net_log) |
19 : url_(url), | 20 : url_(url), |
20 factory_(factory), | 21 factory_(factory), |
21 delegate_(delegate), | 22 delegate_(delegate), |
22 net_log_(net_log), | 23 net_log_(net_log), |
23 completed_(false), | 24 completed_(false), |
24 was_npn_negotiated_(false), | 25 was_npn_negotiated_(false), |
25 protocol_negotiated_(kProtoUnknown), | 26 protocol_negotiated_(kProtoUnknown), |
26 using_spdy_(false) { | 27 using_spdy_(false) { |
27 DCHECK(factory_); | 28 DCHECK(factory_); |
28 DCHECK(delegate_); | 29 DCHECK(delegate_); |
29 | 30 |
30 net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL); | 31 net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_REQUEST); |
31 } | 32 } |
32 | 33 |
33 HttpStreamFactoryImpl::Request::~Request() { | 34 HttpStreamFactoryImpl::Request::~Request() { |
34 if (bound_job_.get()) | 35 if (bound_job_.get()) |
35 DCHECK(jobs_.empty()); | 36 DCHECK(jobs_.empty()); |
36 else | 37 else |
37 DCHECK(!jobs_.empty()); | 38 DCHECK(!jobs_.empty()); |
38 | 39 |
39 net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL); | 40 net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_REQUEST); |
40 | 41 |
41 for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it) | 42 for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it) |
42 factory_->request_map_.erase(*it); | 43 factory_->request_map_.erase(*it); |
43 | 44 |
44 RemoveRequestFromSpdySessionRequestMap(); | 45 RemoveRequestFromSpdySessionRequestMap(); |
45 RemoveRequestFromHttpPipeliningRequestMap(); | 46 RemoveRequestFromHttpPipeliningRequestMap(); |
46 | 47 |
47 STLDeleteElements(&jobs_); | 48 STLDeleteElements(&jobs_); |
48 } | 49 } |
49 | 50 |
(...skipping 30 matching lines...) Expand all Loading... |
80 NextProto protocol_negotiated, | 81 NextProto protocol_negotiated, |
81 bool using_spdy, | 82 bool using_spdy, |
82 const BoundNetLog& job_net_log) { | 83 const BoundNetLog& job_net_log) { |
83 DCHECK(!completed_); | 84 DCHECK(!completed_); |
84 completed_ = true; | 85 completed_ = true; |
85 was_npn_negotiated_ = was_npn_negotiated; | 86 was_npn_negotiated_ = was_npn_negotiated; |
86 protocol_negotiated_ = protocol_negotiated; | 87 protocol_negotiated_ = protocol_negotiated; |
87 using_spdy_ = using_spdy; | 88 using_spdy_ = using_spdy; |
88 net_log_.AddEvent( | 89 net_log_.AddEvent( |
89 NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB, | 90 NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB, |
90 make_scoped_refptr(new NetLogSourceParameter( | 91 job_net_log.source().ToEventParametersCallback()); |
91 "source_dependency", job_net_log.source()))); | |
92 job_net_log.AddEvent( | 92 job_net_log.AddEvent( |
93 NetLog::TYPE_HTTP_STREAM_JOB_BOUND_TO_REQUEST, | 93 NetLog::TYPE_HTTP_STREAM_JOB_BOUND_TO_REQUEST, |
94 make_scoped_refptr(new NetLogSourceParameter( | 94 net_log_.source().ToEventParametersCallback()); |
95 "source_dependency", net_log_.source()))); | |
96 } | 95 } |
97 | 96 |
98 void HttpStreamFactoryImpl::Request::OnStreamReady( | 97 void HttpStreamFactoryImpl::Request::OnStreamReady( |
99 Job* job, | 98 Job* job, |
100 const SSLConfig& used_ssl_config, | 99 const SSLConfig& used_ssl_config, |
101 const ProxyInfo& used_proxy_info, | 100 const ProxyInfo& used_proxy_info, |
102 HttpStream* stream) { | 101 HttpStream* stream) { |
103 DCHECK(stream); | 102 DCHECK(stream); |
104 DCHECK(completed_); | 103 DCHECK(completed_); |
105 | 104 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 RemoveRequestFromHttpPipeliningRequestMap(); | 336 RemoveRequestFromHttpPipeliningRequestMap(); |
338 | 337 |
339 std::set<Job*> tmp; | 338 std::set<Job*> tmp; |
340 tmp.swap(jobs_); | 339 tmp.swap(jobs_); |
341 | 340 |
342 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it) | 341 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it) |
343 factory_->OrphanJob(*it, this); | 342 factory_->OrphanJob(*it, this); |
344 } | 343 } |
345 | 344 |
346 } // namespace net | 345 } // namespace net |
OLD | NEW |