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_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // working. | 290 // working. |
291 return request_info_.url.SchemeIs("https") || | 291 return request_info_.url.SchemeIs("https") || |
292 proxy_info_.proxy_server().is_https() || | 292 proxy_info_.proxy_server().is_https() || |
293 session_->params().force_spdy_always; | 293 session_->params().force_spdy_always; |
294 } | 294 } |
295 | 295 |
296 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { | 296 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { |
297 DCHECK(stream_.get()); | 297 DCHECK(stream_.get()); |
298 DCHECK(!IsPreconnecting()); | 298 DCHECK(!IsPreconnecting()); |
299 DCHECK(!stream_factory_->for_websockets_); | 299 DCHECK(!stream_factory_->for_websockets_); |
| 300 |
| 301 MaybeAddConnectionAttempts(); |
| 302 |
300 if (IsOrphaned()) { | 303 if (IsOrphaned()) { |
301 stream_factory_->OnOrphanedJobComplete(this); | 304 stream_factory_->OnOrphanedJobComplete(this); |
302 } else { | 305 } else { |
303 request_->Complete(was_npn_negotiated(), | 306 request_->Complete(was_npn_negotiated(), |
304 protocol_negotiated(), | 307 protocol_negotiated(), |
305 using_spdy(), | 308 using_spdy(), |
306 net_log_); | 309 net_log_); |
307 request_->OnStreamReady(this, server_ssl_config_, proxy_info_, | 310 request_->OnStreamReady(this, server_ssl_config_, proxy_info_, |
308 stream_.release()); | 311 stream_.release()); |
309 } | 312 } |
310 // |this| may be deleted after this call. | 313 // |this| may be deleted after this call. |
311 } | 314 } |
312 | 315 |
313 void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() { | 316 void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() { |
314 DCHECK(websocket_stream_); | 317 DCHECK(websocket_stream_); |
315 DCHECK(!IsPreconnecting()); | 318 DCHECK(!IsPreconnecting()); |
316 DCHECK(stream_factory_->for_websockets_); | 319 DCHECK(stream_factory_->for_websockets_); |
317 // An orphaned WebSocket job will be closed immediately and | 320 // An orphaned WebSocket job will be closed immediately and |
318 // never be ready. | 321 // never be ready. |
319 DCHECK(!IsOrphaned()); | 322 DCHECK(!IsOrphaned()); |
| 323 |
| 324 MaybeAddConnectionAttempts(); |
| 325 |
320 request_->Complete(was_npn_negotiated(), | 326 request_->Complete(was_npn_negotiated(), |
321 protocol_negotiated(), | 327 protocol_negotiated(), |
322 using_spdy(), | 328 using_spdy(), |
323 net_log_); | 329 net_log_); |
324 request_->OnWebSocketHandshakeStreamReady(this, | 330 request_->OnWebSocketHandshakeStreamReady(this, |
325 server_ssl_config_, | 331 server_ssl_config_, |
326 proxy_info_, | 332 proxy_info_, |
327 websocket_stream_.release()); | 333 websocket_stream_.release()); |
328 // |this| may be deleted after this call. | 334 // |this| may be deleted after this call. |
329 } | 335 } |
330 | 336 |
331 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { | 337 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { |
332 DCHECK(stream_.get()); | 338 DCHECK(stream_.get()); |
333 DCHECK(!IsPreconnecting()); | 339 DCHECK(!IsPreconnecting()); |
334 DCHECK(using_spdy()); | 340 DCHECK(using_spdy()); |
335 // Note: an event loop iteration has passed, so |new_spdy_session_| may be | 341 // Note: an event loop iteration has passed, so |new_spdy_session_| may be |
336 // NULL at this point if the SpdySession closed immediately after creation. | 342 // NULL at this point if the SpdySession closed immediately after creation. |
337 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_; | 343 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_; |
338 new_spdy_session_.reset(); | 344 new_spdy_session_.reset(); |
339 | 345 |
| 346 MaybeAddConnectionAttempts(); |
| 347 |
340 // TODO(jgraettinger): Notify the factory, and let that notify |request_|, | 348 // TODO(jgraettinger): Notify the factory, and let that notify |request_|, |
341 // rather than notifying |request_| directly. | 349 // rather than notifying |request_| directly. |
342 if (IsOrphaned()) { | 350 if (IsOrphaned()) { |
343 if (spdy_session) { | 351 if (spdy_session) { |
344 stream_factory_->OnNewSpdySessionReady( | 352 stream_factory_->OnNewSpdySessionReady( |
345 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_, | 353 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_, |
346 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); | 354 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); |
347 } | 355 } |
348 stream_factory_->OnOrphanedJobComplete(this); | 356 stream_factory_->OnOrphanedJobComplete(this); |
349 } else { | 357 } else { |
350 request_->OnNewSpdySessionReady( | 358 request_->OnNewSpdySessionReady( |
351 this, stream_.Pass(), spdy_session, spdy_session_direct_); | 359 this, stream_.Pass(), spdy_session, spdy_session_direct_); |
352 } | 360 } |
353 // |this| may be deleted after this call. | 361 // |this| may be deleted after this call. |
354 } | 362 } |
355 | 363 |
356 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { | 364 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { |
357 DCHECK(!IsPreconnecting()); | 365 DCHECK(!IsPreconnecting()); |
| 366 |
| 367 MaybeAddConnectionAttempts(); |
| 368 |
358 if (IsOrphaned()) | 369 if (IsOrphaned()) |
359 stream_factory_->OnOrphanedJobComplete(this); | 370 stream_factory_->OnOrphanedJobComplete(this); |
360 else | 371 else |
361 request_->OnStreamFailed(this, result, server_ssl_config_); | 372 request_->OnStreamFailed(this, result, server_ssl_config_); |
362 // |this| may be deleted after this call. | 373 // |this| may be deleted after this call. |
363 } | 374 } |
364 | 375 |
365 void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback( | 376 void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback( |
366 int result, const SSLInfo& ssl_info) { | 377 int result, const SSLInfo& ssl_info) { |
367 DCHECK(!IsPreconnecting()); | 378 DCHECK(!IsPreconnecting()); |
| 379 |
| 380 MaybeAddConnectionAttempts(); |
| 381 |
368 if (IsOrphaned()) | 382 if (IsOrphaned()) |
369 stream_factory_->OnOrphanedJobComplete(this); | 383 stream_factory_->OnOrphanedJobComplete(this); |
370 else | 384 else |
371 request_->OnCertificateError(this, result, server_ssl_config_, ssl_info); | 385 request_->OnCertificateError(this, result, server_ssl_config_, ssl_info); |
372 // |this| may be deleted after this call. | 386 // |this| may be deleted after this call. |
373 } | 387 } |
374 | 388 |
375 void HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback( | 389 void HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback( |
376 const HttpResponseInfo& response, | 390 const HttpResponseInfo& response, |
377 HttpAuthController* auth_controller) { | 391 HttpAuthController* auth_controller) { |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 } | 1515 } |
1502 | 1516 |
1503 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { | 1517 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { |
1504 HistogramBrokenAlternateProtocolLocation( | 1518 HistogramBrokenAlternateProtocolLocation( |
1505 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); | 1519 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); |
1506 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1520 session_->http_server_properties()->SetBrokenAlternateProtocol( |
1507 HostPortPair::FromURL(request_info_.url)); | 1521 HostPortPair::FromURL(request_info_.url)); |
1508 } | 1522 } |
1509 } | 1523 } |
1510 | 1524 |
| 1525 void HttpStreamFactoryImpl::Job::MaybeAddConnectionAttempts() { |
| 1526 if (IsOrphaned() || !connection_) |
| 1527 return; |
| 1528 |
| 1529 request_->AddConnectionAttempts(connection_->connection_attempts()); |
| 1530 } |
| 1531 |
1511 } // namespace net | 1532 } // namespace net |
OLD | NEW |