Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: net/http/http_stream_factory_impl_request.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/http/http_stream_factory_impl_job.h" 10 #include "net/http/http_stream_factory_impl_job.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 RequestSet& request_set = 60 RequestSet& request_set =
61 factory_->spdy_session_request_map_[spdy_session_key]; 61 factory_->spdy_session_request_map_[spdy_session_key];
62 DCHECK(!ContainsKey(request_set, this)); 62 DCHECK(!ContainsKey(request_set, this));
63 request_set.insert(this); 63 request_set.insert(this);
64 } 64 }
65 65
66 bool HttpStreamFactoryImpl::Request::SetHttpPipeliningKey( 66 bool HttpStreamFactoryImpl::Request::SetHttpPipeliningKey(
67 const HttpPipelinedHost::Key& http_pipelining_key) { 67 const HttpPipelinedHost::Key& http_pipelining_key) {
68 CHECK(!http_pipelining_key_.get()); 68 CHECK(!http_pipelining_key_.get());
69 http_pipelining_key_.reset(new HttpPipelinedHost::Key(http_pipelining_key)); 69 http_pipelining_key_.reset(new HttpPipelinedHost::Key(http_pipelining_key));
70 bool was_new_key = !ContainsKey(factory_->http_pipelining_request_map_, 70 bool was_new_key =
71 http_pipelining_key); 71 !ContainsKey(factory_->http_pipelining_request_map_, http_pipelining_key);
72 RequestVector& request_vector = 72 RequestVector& request_vector =
73 factory_->http_pipelining_request_map_[http_pipelining_key]; 73 factory_->http_pipelining_request_map_[http_pipelining_key];
74 request_vector.push_back(this); 74 request_vector.push_back(this);
75 return was_new_key; 75 return was_new_key;
76 } 76 }
77 77
78 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) { 78 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) {
79 DCHECK(job); 79 DCHECK(job);
80 jobs_.insert(job); 80 jobs_.insert(job);
81 factory_->request_map_[job] = this; 81 factory_->request_map_[job] = this;
82 } 82 }
83 83
84 void HttpStreamFactoryImpl::Request::Complete( 84 void HttpStreamFactoryImpl::Request::Complete(bool was_npn_negotiated,
85 bool was_npn_negotiated, 85 NextProto protocol_negotiated,
86 NextProto protocol_negotiated, 86 bool using_spdy,
87 bool using_spdy, 87 const BoundNetLog& job_net_log) {
88 const BoundNetLog& job_net_log) {
89 DCHECK(!completed_); 88 DCHECK(!completed_);
90 completed_ = true; 89 completed_ = true;
91 was_npn_negotiated_ = was_npn_negotiated; 90 was_npn_negotiated_ = was_npn_negotiated;
92 protocol_negotiated_ = protocol_negotiated; 91 protocol_negotiated_ = protocol_negotiated;
93 using_spdy_ = using_spdy; 92 using_spdy_ = using_spdy;
94 net_log_.AddEvent( 93 net_log_.AddEvent(NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB,
95 NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB, 94 job_net_log.source().ToEventParametersCallback());
96 job_net_log.source().ToEventParametersCallback()); 95 job_net_log.AddEvent(NetLog::TYPE_HTTP_STREAM_JOB_BOUND_TO_REQUEST,
97 job_net_log.AddEvent( 96 net_log_.source().ToEventParametersCallback());
98 NetLog::TYPE_HTTP_STREAM_JOB_BOUND_TO_REQUEST,
99 net_log_.source().ToEventParametersCallback());
100 } 97 }
101 98
102 void HttpStreamFactoryImpl::Request::OnStreamReady( 99 void HttpStreamFactoryImpl::Request::OnStreamReady(
103 Job* job, 100 Job* job,
104 const SSLConfig& used_ssl_config, 101 const SSLConfig& used_ssl_config,
105 const ProxyInfo& used_proxy_info, 102 const ProxyInfo& used_proxy_info,
106 HttpStreamBase* stream) { 103 HttpStreamBase* stream) {
107 DCHECK(!factory_->for_websockets_); 104 DCHECK(!factory_->for_websockets_);
108 DCHECK(stream); 105 DCHECK(stream);
109 DCHECK(completed_); 106 DCHECK(completed_);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 const SSLConfig& used_ssl_config, 189 const SSLConfig& used_ssl_config,
193 SSLCertRequestInfo* cert_info) { 190 SSLCertRequestInfo* cert_info) {
194 if (!bound_job_.get()) 191 if (!bound_job_.get())
195 OrphanJobsExcept(job); 192 OrphanJobsExcept(job);
196 else 193 else
197 DCHECK(jobs_.empty()); 194 DCHECK(jobs_.empty());
198 delegate_->OnNeedsClientAuth(used_ssl_config, cert_info); 195 delegate_->OnNeedsClientAuth(used_ssl_config, cert_info);
199 } 196 }
200 197
201 void HttpStreamFactoryImpl::Request::OnHttpsProxyTunnelResponse( 198 void HttpStreamFactoryImpl::Request::OnHttpsProxyTunnelResponse(
202 Job *job, 199 Job* job,
203 const HttpResponseInfo& response_info, 200 const HttpResponseInfo& response_info,
204 const SSLConfig& used_ssl_config, 201 const SSLConfig& used_ssl_config,
205 const ProxyInfo& used_proxy_info, 202 const ProxyInfo& used_proxy_info,
206 HttpStreamBase* stream) { 203 HttpStreamBase* stream) {
207 if (!bound_job_.get()) 204 if (!bound_job_.get())
208 OrphanJobsExcept(job); 205 OrphanJobsExcept(job);
209 else 206 else
210 DCHECK(jobs_.empty()); 207 DCHECK(jobs_.empty());
211 delegate_->OnHttpsProxyTunnelResponse( 208 delegate_->OnHttpsProxyTunnelResponse(
212 response_info, used_ssl_config, used_proxy_info, stream); 209 response_info, used_ssl_config, used_proxy_info, stream);
213 } 210 }
214 211
215 int HttpStreamFactoryImpl::Request::RestartTunnelWithProxyAuth( 212 int HttpStreamFactoryImpl::Request::RestartTunnelWithProxyAuth(
216 const AuthCredentials& credentials) { 213 const AuthCredentials& credentials) {
217 DCHECK(bound_job_.get()); 214 DCHECK(bound_job_.get());
218 return bound_job_->RestartTunnelWithProxyAuth(credentials); 215 return bound_job_->RestartTunnelWithProxyAuth(credentials);
219 } 216 }
220 217
221 void HttpStreamFactoryImpl::Request::SetPriority(RequestPriority priority) { 218 void HttpStreamFactoryImpl::Request::SetPriority(RequestPriority priority) {
222 for (std::set<HttpStreamFactoryImpl::Job*>::const_iterator it = jobs_.begin(); 219 for (std::set<HttpStreamFactoryImpl::Job*>::const_iterator it = jobs_.begin();
223 it != jobs_.end(); ++it) { 220 it != jobs_.end();
221 ++it) {
224 (*it)->SetPriority(priority); 222 (*it)->SetPriority(priority);
225 } 223 }
226 if (bound_job_) 224 if (bound_job_)
227 bound_job_->SetPriority(priority); 225 bound_job_->SetPriority(priority);
228 } 226 }
229 227
230 LoadState HttpStreamFactoryImpl::Request::GetLoadState() const { 228 LoadState HttpStreamFactoryImpl::Request::GetLoadState() const {
231 if (bound_job_.get()) 229 if (bound_job_.get())
232 return bound_job_->GetLoadState(); 230 return bound_job_->GetLoadState();
233 DCHECK(!jobs_.empty()); 231 DCHECK(!jobs_.empty());
234 232
235 // Just pick the first one. 233 // Just pick the first one.
236 return (*jobs_.begin())->GetLoadState(); 234 return (*jobs_.begin())->GetLoadState();
237 } 235 }
238 236
239 bool HttpStreamFactoryImpl::Request::was_npn_negotiated() const { 237 bool HttpStreamFactoryImpl::Request::was_npn_negotiated() const {
240 DCHECK(completed_); 238 DCHECK(completed_);
241 return was_npn_negotiated_; 239 return was_npn_negotiated_;
242 } 240 }
243 241
244 NextProto HttpStreamFactoryImpl::Request::protocol_negotiated() 242 NextProto HttpStreamFactoryImpl::Request::protocol_negotiated() const {
245 const {
246 DCHECK(completed_); 243 DCHECK(completed_);
247 return protocol_negotiated_; 244 return protocol_negotiated_;
248 } 245 }
249 246
250 bool HttpStreamFactoryImpl::Request::using_spdy() const { 247 bool HttpStreamFactoryImpl::Request::using_spdy() const {
251 DCHECK(completed_); 248 DCHECK(completed_);
252 return using_spdy_; 249 return using_spdy_;
253 } 250 }
254 251
255 void 252 void HttpStreamFactoryImpl::Request::RemoveRequestFromSpdySessionRequestMap() {
256 HttpStreamFactoryImpl::Request::RemoveRequestFromSpdySessionRequestMap() {
257 if (spdy_session_key_.get()) { 253 if (spdy_session_key_.get()) {
258 SpdySessionRequestMap& spdy_session_request_map = 254 SpdySessionRequestMap& spdy_session_request_map =
259 factory_->spdy_session_request_map_; 255 factory_->spdy_session_request_map_;
260 DCHECK(ContainsKey(spdy_session_request_map, *spdy_session_key_)); 256 DCHECK(ContainsKey(spdy_session_request_map, *spdy_session_key_));
261 RequestSet& request_set = 257 RequestSet& request_set = spdy_session_request_map[*spdy_session_key_];
262 spdy_session_request_map[*spdy_session_key_];
263 DCHECK(ContainsKey(request_set, this)); 258 DCHECK(ContainsKey(request_set, this));
264 request_set.erase(this); 259 request_set.erase(this);
265 if (request_set.empty()) 260 if (request_set.empty())
266 spdy_session_request_map.erase(*spdy_session_key_); 261 spdy_session_request_map.erase(*spdy_session_key_);
267 spdy_session_key_.reset(); 262 spdy_session_key_.reset();
268 } 263 }
269 } 264 }
270 265
271 void 266 void
272 HttpStreamFactoryImpl::Request::RemoveRequestFromHttpPipeliningRequestMap() { 267 HttpStreamFactoryImpl::Request::RemoveRequestFromHttpPipeliningRequestMap() {
273 if (http_pipelining_key_.get()) { 268 if (http_pipelining_key_.get()) {
274 HttpPipeliningRequestMap& http_pipelining_request_map = 269 HttpPipeliningRequestMap& http_pipelining_request_map =
275 factory_->http_pipelining_request_map_; 270 factory_->http_pipelining_request_map_;
276 DCHECK(ContainsKey(http_pipelining_request_map, *http_pipelining_key_)); 271 DCHECK(ContainsKey(http_pipelining_request_map, *http_pipelining_key_));
277 RequestVector& request_vector = 272 RequestVector& request_vector =
278 http_pipelining_request_map[*http_pipelining_key_]; 273 http_pipelining_request_map[*http_pipelining_key_];
279 for (RequestVector::iterator it = request_vector.begin(); 274 for (RequestVector::iterator it = request_vector.begin();
280 it != request_vector.end(); ++it) { 275 it != request_vector.end();
276 ++it) {
281 if (*it == this) { 277 if (*it == this) {
282 request_vector.erase(it); 278 request_vector.erase(it);
283 break; 279 break;
284 } 280 }
285 } 281 }
286 if (request_vector.empty()) 282 if (request_vector.empty())
287 http_pipelining_request_map.erase(*http_pipelining_key_); 283 http_pipelining_request_map.erase(*http_pipelining_key_);
288 http_pipelining_key_.reset(); 284 http_pipelining_key_.reset();
289 } 285 }
290 } 286 }
(...skipping 15 matching lines...) Expand all
306 OrphanJobsExcept(job); 302 OrphanJobsExcept(job);
307 } else { // This is the case for HTTPS proxy tunneling. 303 } else { // This is the case for HTTPS proxy tunneling.
308 DCHECK_EQ(bound_job_.get(), job); 304 DCHECK_EQ(bound_job_.get(), job);
309 DCHECK(jobs_.empty()); 305 DCHECK(jobs_.empty());
310 } 306 }
311 307
312 // Cache these values in case the job gets deleted. 308 // Cache these values in case the job gets deleted.
313 const SSLConfig used_ssl_config = job->server_ssl_config(); 309 const SSLConfig used_ssl_config = job->server_ssl_config();
314 const ProxyInfo used_proxy_info = job->proxy_info(); 310 const ProxyInfo used_proxy_info = job->proxy_info();
315 const bool was_npn_negotiated = job->was_npn_negotiated(); 311 const bool was_npn_negotiated = job->was_npn_negotiated();
316 const NextProto protocol_negotiated = 312 const NextProto protocol_negotiated = job->protocol_negotiated();
317 job->protocol_negotiated();
318 const bool using_spdy = job->using_spdy(); 313 const bool using_spdy = job->using_spdy();
319 const BoundNetLog net_log = job->net_log(); 314 const BoundNetLog net_log = job->net_log();
320 315
321 Complete(was_npn_negotiated, protocol_negotiated, using_spdy, net_log); 316 Complete(was_npn_negotiated, protocol_negotiated, using_spdy, net_log);
322 317
323 // Cache this so we can still use it if the request is deleted. 318 // Cache this so we can still use it if the request is deleted.
324 HttpStreamFactoryImpl* factory = factory_; 319 HttpStreamFactoryImpl* factory = factory_;
325 if (factory->for_websockets_) { 320 if (factory->for_websockets_) {
326 // TODO(ricea): Re-instate this code when WebSockets over SPDY is 321 // TODO(ricea): Re-instate this code when WebSockets over SPDY is
327 // implemented. 322 // implemented.
328 NOTREACHED(); 323 NOTREACHED();
329 } else { 324 } else {
330 delegate_->OnStreamReady(job->server_ssl_config(), job->proxy_info(), 325 delegate_->OnStreamReady(
331 stream.release()); 326 job->server_ssl_config(), job->proxy_info(), stream.release());
332 } 327 }
333 // |this| may be deleted after this point. 328 // |this| may be deleted after this point.
334 if (spdy_session) { 329 if (spdy_session) {
335 factory->OnNewSpdySessionReady(spdy_session, 330 factory->OnNewSpdySessionReady(spdy_session,
336 direct, 331 direct,
337 used_ssl_config, 332 used_ssl_config,
338 used_proxy_info, 333 used_proxy_info,
339 was_npn_negotiated, 334 was_npn_negotiated,
340 protocol_negotiated, 335 protocol_negotiated,
341 using_spdy, 336 using_spdy,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 job->ReportJobSuccededForRequest(); 382 job->ReportJobSuccededForRequest();
388 // We may have other jobs in |jobs_|. For example, if we start multiple jobs 383 // We may have other jobs in |jobs_|. For example, if we start multiple jobs
389 // for Alternate-Protocol. 384 // for Alternate-Protocol.
390 OrphanJobsExcept(job); 385 OrphanJobsExcept(job);
391 return; 386 return;
392 } 387 }
393 DCHECK(jobs_.empty()); 388 DCHECK(jobs_.empty());
394 } 389 }
395 390
396 } // namespace net 391 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698