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/bidirectional_stream_job.h" | 10 #include "net/http/bidirectional_stream_impl.h" |
11 #include "net/http/http_stream_factory_impl_job.h" | 11 #include "net/http/http_stream_factory_impl_job.h" |
12 #include "net/spdy/spdy_http_stream.h" | 12 #include "net/spdy/spdy_http_stream.h" |
13 #include "net/spdy/spdy_session.h" | 13 #include "net/spdy/spdy_session.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 HttpStreamFactoryImpl::Request::Request( | 17 HttpStreamFactoryImpl::Request::Request( |
18 const GURL& url, | 18 const GURL& url, |
19 HttpStreamFactoryImpl* factory, | 19 HttpStreamFactoryImpl* factory, |
20 HttpStreamRequest::Delegate* delegate, | 20 HttpStreamRequest::Delegate* delegate, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 HttpStream* stream) { | 81 HttpStream* stream) { |
82 DCHECK(!factory_->for_websockets_); | 82 DCHECK(!factory_->for_websockets_); |
83 DCHECK_EQ(HttpStreamRequest::HTTP_STREAM, stream_type_); | 83 DCHECK_EQ(HttpStreamRequest::HTTP_STREAM, stream_type_); |
84 DCHECK(stream); | 84 DCHECK(stream); |
85 DCHECK(completed_); | 85 DCHECK(completed_); |
86 | 86 |
87 OnJobSucceeded(job); | 87 OnJobSucceeded(job); |
88 delegate_->OnStreamReady(used_ssl_config, used_proxy_info, stream); | 88 delegate_->OnStreamReady(used_ssl_config, used_proxy_info, stream); |
89 } | 89 } |
90 | 90 |
91 void HttpStreamFactoryImpl::Request::OnBidirectionalStreamJobReady( | 91 void HttpStreamFactoryImpl::Request::OnBidirectionalStreamImplReady( |
92 Job* job, | 92 Job* job, |
93 const SSLConfig& used_ssl_config, | 93 const SSLConfig& used_ssl_config, |
94 const ProxyInfo& used_proxy_info, | 94 const ProxyInfo& used_proxy_info, |
95 BidirectionalStreamJob* stream_job) { | 95 BidirectionalStreamImpl* stream_job) { |
96 DCHECK(!factory_->for_websockets_); | 96 DCHECK(!factory_->for_websockets_); |
97 DCHECK_EQ(HttpStreamRequest::BIDIRECTIONAL_STREAM, stream_type_); | 97 DCHECK_EQ(HttpStreamRequest::BIDIRECTIONAL_STREAM, stream_type_); |
98 DCHECK(stream_job); | 98 DCHECK(stream_job); |
99 DCHECK(completed_); | 99 DCHECK(completed_); |
100 | 100 |
101 OnJobSucceeded(job); | 101 OnJobSucceeded(job); |
102 delegate_->OnBidirectionalStreamJobReady(used_ssl_config, used_proxy_info, | 102 delegate_->OnBidirectionalStreamImplReady(used_ssl_config, used_proxy_info, |
103 stream_job); | 103 stream_job); |
104 } | 104 } |
105 | 105 |
106 void HttpStreamFactoryImpl::Request::OnWebSocketHandshakeStreamReady( | 106 void HttpStreamFactoryImpl::Request::OnWebSocketHandshakeStreamReady( |
107 Job* job, | 107 Job* job, |
108 const SSLConfig& used_ssl_config, | 108 const SSLConfig& used_ssl_config, |
109 const ProxyInfo& used_proxy_info, | 109 const ProxyInfo& used_proxy_info, |
110 WebSocketHandshakeStreamBase* stream) { | 110 WebSocketHandshakeStreamBase* stream) { |
111 DCHECK(factory_->for_websockets_); | 111 DCHECK(factory_->for_websockets_); |
112 DCHECK_EQ(HttpStreamRequest::HTTP_STREAM, stream_type_); | 112 DCHECK_EQ(HttpStreamRequest::HTTP_STREAM, stream_type_); |
113 DCHECK(stream); | 113 DCHECK(stream); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 // TODO(jgraettinger): Currently, HttpStreamFactoryImpl::Job notifies a | 265 // TODO(jgraettinger): Currently, HttpStreamFactoryImpl::Job notifies a |
266 // Request that the session is ready, which in turn notifies it's delegate, | 266 // Request that the session is ready, which in turn notifies it's delegate, |
267 // and then it notifies HttpStreamFactoryImpl so that /other/ requests may | 267 // and then it notifies HttpStreamFactoryImpl so that /other/ requests may |
268 // be woken, but only if the spdy_session is still okay. This is tough to grok. | 268 // be woken, but only if the spdy_session is still okay. This is tough to grok. |
269 // Instead, see if Job can notify HttpStreamFactoryImpl only, and have one | 269 // Instead, see if Job can notify HttpStreamFactoryImpl only, and have one |
270 // path for notifying any requests waiting for the session (including the | 270 // path for notifying any requests waiting for the session (including the |
271 // request which spawned it). | 271 // request which spawned it). |
272 void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( | 272 void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( |
273 Job* job, | 273 Job* job, |
274 scoped_ptr<HttpStream> stream, | 274 scoped_ptr<HttpStream> stream, |
275 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_job, | 275 scoped_ptr<BidirectionalStreamImpl> bidirectional_stream_impl, |
276 const base::WeakPtr<SpdySession>& spdy_session, | 276 const base::WeakPtr<SpdySession>& spdy_session, |
277 bool direct) { | 277 bool direct) { |
278 DCHECK(job); | 278 DCHECK(job); |
279 DCHECK(job->using_spdy()); | 279 DCHECK(job->using_spdy()); |
280 | 280 |
281 // Note: |spdy_session| may be NULL. In that case, |delegate_| should still | 281 // Note: |spdy_session| may be NULL. In that case, |delegate_| should still |
282 // receive |stream| so the error propagates up correctly, however there is no | 282 // receive |stream| so the error propagates up correctly, however there is no |
283 // point in broadcasting |spdy_session| to other requests. | 283 // point in broadcasting |spdy_session| to other requests. |
284 | 284 |
285 // The first case is the usual case. | 285 // The first case is the usual case. |
(...skipping 15 matching lines...) Expand all Loading... |
301 | 301 |
302 Complete(was_npn_negotiated, protocol_negotiated, using_spdy); | 302 Complete(was_npn_negotiated, protocol_negotiated, using_spdy); |
303 | 303 |
304 // Cache this so we can still use it if the request is deleted. | 304 // Cache this so we can still use it if the request is deleted. |
305 HttpStreamFactoryImpl* factory = factory_; | 305 HttpStreamFactoryImpl* factory = factory_; |
306 if (factory->for_websockets_) { | 306 if (factory->for_websockets_) { |
307 // TODO(ricea): Re-instate this code when WebSockets over SPDY is | 307 // TODO(ricea): Re-instate this code when WebSockets over SPDY is |
308 // implemented. | 308 // implemented. |
309 NOTREACHED(); | 309 NOTREACHED(); |
310 } else if (stream_type_ == HttpStreamRequest::BIDIRECTIONAL_STREAM) { | 310 } else if (stream_type_ == HttpStreamRequest::BIDIRECTIONAL_STREAM) { |
311 DCHECK(bidirectional_stream_job); | 311 DCHECK(bidirectional_stream_impl); |
312 DCHECK(!stream); | 312 DCHECK(!stream); |
313 delegate_->OnBidirectionalStreamJobReady( | 313 delegate_->OnBidirectionalStreamImplReady( |
314 job->server_ssl_config(), job->proxy_info(), | 314 job->server_ssl_config(), job->proxy_info(), |
315 bidirectional_stream_job.release()); | 315 bidirectional_stream_impl.release()); |
316 } else { | 316 } else { |
317 DCHECK(!bidirectional_stream_job); | 317 DCHECK(!bidirectional_stream_impl); |
318 DCHECK(stream); | 318 DCHECK(stream); |
319 delegate_->OnStreamReady(job->server_ssl_config(), job->proxy_info(), | 319 delegate_->OnStreamReady(job->server_ssl_config(), job->proxy_info(), |
320 stream.release()); | 320 stream.release()); |
321 } | 321 } |
322 // |this| may be deleted after this point. | 322 // |this| may be deleted after this point. |
323 if (spdy_session && spdy_session->IsAvailable()) { | 323 if (spdy_session && spdy_session->IsAvailable()) { |
324 factory->OnNewSpdySessionReady(spdy_session, | 324 factory->OnNewSpdySessionReady(spdy_session, |
325 direct, | 325 direct, |
326 used_ssl_config, | 326 used_ssl_config, |
327 used_proxy_info, | 327 used_proxy_info, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 404 } |
405 // We may have other jobs in |jobs_|. For example, if we start multiple jobs | 405 // We may have other jobs in |jobs_|. For example, if we start multiple jobs |
406 // for Alternate-Protocol. | 406 // for Alternate-Protocol. |
407 BindJob(job); | 407 BindJob(job); |
408 return; | 408 return; |
409 } | 409 } |
410 DCHECK(jobs_.empty()); | 410 DCHECK(jobs_.empty()); |
411 } | 411 } |
412 | 412 |
413 } // namespace net | 413 } // namespace net |
OLD | NEW |