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/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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 284 } |
285 } | 285 } |
286 if (request_vector.empty()) | 286 if (request_vector.empty()) |
287 http_pipelining_request_map.erase(*http_pipelining_key_); | 287 http_pipelining_request_map.erase(*http_pipelining_key_); |
288 http_pipelining_key_.reset(); | 288 http_pipelining_key_.reset(); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( | 292 void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( |
293 Job* job, | 293 Job* job, |
294 scoped_ptr<HttpStream> stream, | |
295 const base::WeakPtr<SpdySession>& spdy_session, | 294 const base::WeakPtr<SpdySession>& spdy_session, |
296 bool direct) { | 295 bool direct) { |
297 DCHECK(job); | 296 DCHECK(job); |
298 DCHECK(job->using_spdy()); | 297 DCHECK(job->using_spdy()); |
299 | 298 |
300 // Note: |spdy_session| may be NULL. In that case, |delegate_| should still | |
301 // receive |stream| so the error propogates up correctly, however there is no | |
302 // point in broadcasting |spdy_session| to other requests. | |
303 | |
304 // The first case is the usual case. | 299 // The first case is the usual case. |
305 if (!bound_job_.get()) { | 300 if (!bound_job_.get()) { |
306 OrphanJobsExcept(job); | 301 OrphanJobsExcept(job); |
307 } else { // This is the case for HTTPS proxy tunneling. | 302 } else { // This is the case for HTTPS proxy tunneling. |
308 DCHECK_EQ(bound_job_.get(), job); | 303 DCHECK_EQ(bound_job_.get(), job); |
309 DCHECK(jobs_.empty()); | 304 DCHECK(jobs_.empty()); |
310 } | 305 } |
311 | 306 |
312 // Cache these values in case the job gets deleted. | 307 // Cache these values in case the job gets deleted. |
313 const SSLConfig used_ssl_config = job->server_ssl_config(); | 308 const SSLConfig used_ssl_config = job->server_ssl_config(); |
314 const ProxyInfo used_proxy_info = job->proxy_info(); | 309 const ProxyInfo used_proxy_info = job->proxy_info(); |
315 const bool was_npn_negotiated = job->was_npn_negotiated(); | 310 const bool was_npn_negotiated = job->was_npn_negotiated(); |
316 const NextProto protocol_negotiated = | 311 const NextProto protocol_negotiated = |
317 job->protocol_negotiated(); | 312 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 bool use_relative_url = direct || url().SchemeIs("https"); |
331 stream.release()); | 326 delegate_->OnStreamReady( |
| 327 job->server_ssl_config(), |
| 328 job->proxy_info(), |
| 329 new SpdyHttpStream(spdy_session, use_relative_url)); |
332 } | 330 } |
333 // |this| may be deleted after this point. | 331 // |this| may be deleted after this point. |
334 if (spdy_session) { | 332 factory->OnNewSpdySessionReady(spdy_session, |
335 factory->OnNewSpdySessionReady(spdy_session, | 333 direct, |
336 direct, | 334 used_ssl_config, |
337 used_ssl_config, | 335 used_proxy_info, |
338 used_proxy_info, | 336 was_npn_negotiated, |
339 was_npn_negotiated, | 337 protocol_negotiated, |
340 protocol_negotiated, | 338 using_spdy, |
341 using_spdy, | 339 net_log); |
342 net_log); | |
343 } | |
344 } | 340 } |
345 | 341 |
346 void HttpStreamFactoryImpl::Request::OrphanJobsExcept(Job* job) { | 342 void HttpStreamFactoryImpl::Request::OrphanJobsExcept(Job* job) { |
347 DCHECK(job); | 343 DCHECK(job); |
348 DCHECK(!bound_job_.get()); | 344 DCHECK(!bound_job_.get()); |
349 DCHECK(ContainsKey(jobs_, job)); | 345 DCHECK(ContainsKey(jobs_, job)); |
350 bound_job_.reset(job); | 346 bound_job_.reset(job); |
351 jobs_.erase(job); | 347 jobs_.erase(job); |
352 factory_->request_map_.erase(job); | 348 factory_->request_map_.erase(job); |
353 | 349 |
(...skipping 29 matching lines...) Expand all Loading... |
383 } else if (!bound_job_.get()) { | 379 } else if (!bound_job_.get()) { |
384 // We may have other jobs in |jobs_|. For example, if we start multiple jobs | 380 // We may have other jobs in |jobs_|. For example, if we start multiple jobs |
385 // for Alternate-Protocol. | 381 // for Alternate-Protocol. |
386 OrphanJobsExcept(job); | 382 OrphanJobsExcept(job); |
387 } else { | 383 } else { |
388 DCHECK(jobs_.empty()); | 384 DCHECK(jobs_.empty()); |
389 } | 385 } |
390 } | 386 } |
391 | 387 |
392 } // namespace net | 388 } // namespace net |
OLD | NEW |