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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 if (IsOrphaned()) | 392 if (IsOrphaned()) |
393 stream_factory_->OnOrphanedJobComplete(this); | 393 stream_factory_->OnOrphanedJobComplete(this); |
394 else | 394 else |
395 request_->OnHttpsProxyTunnelResponse( | 395 request_->OnHttpsProxyTunnelResponse( |
396 this, response_info, server_ssl_config_, proxy_info_, stream); | 396 this, response_info, server_ssl_config_, proxy_info_, stream); |
397 // |this| may be deleted after this call. | 397 // |this| may be deleted after this call. |
398 } | 398 } |
399 | 399 |
400 void HttpStreamFactoryImpl::Job::OnPreconnectsComplete() { | 400 void HttpStreamFactoryImpl::Job::OnPreconnectsComplete() { |
401 DCHECK(!request_); | 401 DCHECK(!request_); |
402 if (new_spdy_session_) { | 402 if (new_spdy_session_.get()) { |
403 stream_factory_->OnNewSpdySessionReady( | 403 stream_factory_->OnNewSpdySessionReady(new_spdy_session_, |
404 new_spdy_session_, spdy_session_direct_, server_ssl_config_, | 404 spdy_session_direct_, |
405 proxy_info_, was_npn_negotiated(), protocol_negotiated(), using_spdy(), | 405 server_ssl_config_, |
406 net_log_); | 406 proxy_info_, |
| 407 was_npn_negotiated(), |
| 408 protocol_negotiated(), |
| 409 using_spdy(), |
| 410 net_log_); |
407 } | 411 } |
408 stream_factory_->OnPreconnectsComplete(this); | 412 stream_factory_->OnPreconnectsComplete(this); |
409 // |this| may be deleted after this call. | 413 // |this| may be deleted after this call. |
410 } | 414 } |
411 | 415 |
412 // static | 416 // static |
413 int HttpStreamFactoryImpl::Job::OnHostResolution( | 417 int HttpStreamFactoryImpl::Job::OnHostResolution( |
414 SpdySessionPool* spdy_session_pool, | 418 SpdySessionPool* spdy_session_pool, |
415 const SpdySessionKey& spdy_session_key, | 419 const SpdySessionKey& spdy_session_key, |
416 const AddressList& addresses, | 420 const AddressList& addresses, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 base::Bind( | 509 base::Bind( |
506 &Job::OnHttpsProxyTunnelResponseCallback, | 510 &Job::OnHttpsProxyTunnelResponseCallback, |
507 ptr_factory_.GetWeakPtr(), | 511 ptr_factory_.GetWeakPtr(), |
508 *proxy_socket->GetConnectResponseInfo(), | 512 *proxy_socket->GetConnectResponseInfo(), |
509 proxy_socket->CreateConnectResponseStream())); | 513 proxy_socket->CreateConnectResponseStream())); |
510 return ERR_IO_PENDING; | 514 return ERR_IO_PENDING; |
511 } | 515 } |
512 | 516 |
513 case OK: | 517 case OK: |
514 next_state_ = STATE_DONE; | 518 next_state_ = STATE_DONE; |
515 if (new_spdy_session_) { | 519 if (new_spdy_session_.get()) { |
516 base::MessageLoop::current()->PostTask( | 520 base::MessageLoop::current()->PostTask( |
517 FROM_HERE, | 521 FROM_HERE, |
518 base::Bind( | 522 base::Bind(&Job::OnNewSpdySessionReadyCallback, |
519 &Job::OnNewSpdySessionReadyCallback, | 523 ptr_factory_.GetWeakPtr())); |
520 ptr_factory_.GetWeakPtr())); | |
521 } else if (stream_factory_->for_websockets_) { | 524 } else if (stream_factory_->for_websockets_) { |
522 DCHECK(websocket_stream_); | 525 DCHECK(websocket_stream_); |
523 base::MessageLoop::current()->PostTask( | 526 base::MessageLoop::current()->PostTask( |
524 FROM_HERE, | 527 FROM_HERE, |
525 base::Bind( | 528 base::Bind( |
526 &Job::OnWebSocketStreamReadyCallback, | 529 &Job::OnWebSocketStreamReadyCallback, |
527 ptr_factory_.GetWeakPtr())); | 530 ptr_factory_.GetWeakPtr())); |
528 } else { | 531 } else { |
529 DCHECK(stream_.get()); | 532 DCHECK(stream_.get()); |
530 base::MessageLoop::current()->PostTask( | 533 base::MessageLoop::current()->PostTask( |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 // TODO(willchan): Delete this code, because eventually, the | 1122 // TODO(willchan): Delete this code, because eventually, the |
1120 // HttpStreamFactoryImpl will be creating all the SpdyHttpStreams, since it | 1123 // HttpStreamFactoryImpl will be creating all the SpdyHttpStreams, since it |
1121 // will know when SpdySessions become available. | 1124 // will know when SpdySessions become available. |
1122 | 1125 |
1123 if (stream_factory_->for_websockets_) { | 1126 if (stream_factory_->for_websockets_) { |
1124 DCHECK(request_); | 1127 DCHECK(request_); |
1125 DCHECK(request_->websocket_stream_factory()); | 1128 DCHECK(request_->websocket_stream_factory()); |
1126 bool use_relative_url = direct || request_info_.url.SchemeIs("wss"); | 1129 bool use_relative_url = direct || request_info_.url.SchemeIs("wss"); |
1127 websocket_stream_.reset( | 1130 websocket_stream_.reset( |
1128 request_->websocket_stream_factory()->CreateSpdyStream( | 1131 request_->websocket_stream_factory()->CreateSpdyStream( |
1129 spdy_session, use_relative_url)); | 1132 spdy_session.get(), use_relative_url)); |
1130 } else { | 1133 } else { |
1131 bool use_relative_url = direct || request_info_.url.SchemeIs("https"); | 1134 bool use_relative_url = direct || request_info_.url.SchemeIs("https"); |
1132 stream_.reset(new SpdyHttpStream(spdy_session, use_relative_url)); | 1135 stream_.reset(new SpdyHttpStream(spdy_session.get(), use_relative_url)); |
1133 } | 1136 } |
1134 return OK; | 1137 return OK; |
1135 } | 1138 } |
1136 | 1139 |
1137 int HttpStreamFactoryImpl::Job::DoCreateStreamComplete(int result) { | 1140 int HttpStreamFactoryImpl::Job::DoCreateStreamComplete(int result) { |
1138 if (result < 0) | 1141 if (result < 0) |
1139 return result; | 1142 return result; |
1140 | 1143 |
1141 session_->proxy_service()->ReportSuccess(proxy_info_); | 1144 session_->proxy_service()->ReportSuccess(proxy_info_); |
1142 next_state_ = STATE_NONE; | 1145 next_state_ = STATE_NONE; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 (net::LOAD_MAIN_FRAME | net::LOAD_SUB_FRAME | net::LOAD_PREFETCH | | 1453 (net::LOAD_MAIN_FRAME | net::LOAD_SUB_FRAME | net::LOAD_PREFETCH | |
1451 net::LOAD_IS_DOWNLOAD)) { | 1454 net::LOAD_IS_DOWNLOAD)) { |
1452 // Avoid pipelining resources that may be streamed for a long time. | 1455 // Avoid pipelining resources that may be streamed for a long time. |
1453 return false; | 1456 return false; |
1454 } | 1457 } |
1455 return stream_factory_->http_pipelined_host_pool_.IsKeyEligibleForPipelining( | 1458 return stream_factory_->http_pipelined_host_pool_.IsKeyEligibleForPipelining( |
1456 *http_pipelining_key_.get()); | 1459 *http_pipelining_key_.get()); |
1457 } | 1460 } |
1458 | 1461 |
1459 } // namespace net | 1462 } // namespace net |
OLD | NEW |