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_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 int64 HttpNetworkTransaction::GetTotalReceivedBytes() const { | 388 int64 HttpNetworkTransaction::GetTotalReceivedBytes() const { |
389 int64 total_received_bytes = total_received_bytes_; | 389 int64 total_received_bytes = total_received_bytes_; |
390 if (stream_) | 390 if (stream_) |
391 total_received_bytes += stream_->GetTotalReceivedBytes(); | 391 total_received_bytes += stream_->GetTotalReceivedBytes(); |
392 return total_received_bytes; | 392 return total_received_bytes; |
393 } | 393 } |
394 | 394 |
395 void HttpNetworkTransaction::DoneReading() {} | 395 void HttpNetworkTransaction::DoneReading() {} |
396 | 396 |
397 const HttpResponseInfo* HttpNetworkTransaction::GetResponseInfo() const { | 397 const HttpResponseInfo* HttpNetworkTransaction::GetResponseInfo() const { |
398 return ((headers_valid_ && response_.headers.get()) || | 398 return &response_; |
399 response_.ssl_info.cert.get() || response_.cert_request_info.get()) | |
400 ? &response_ | |
401 : NULL; | |
402 } | 399 } |
403 | 400 |
404 LoadState HttpNetworkTransaction::GetLoadState() const { | 401 LoadState HttpNetworkTransaction::GetLoadState() const { |
405 // TODO(wtc): Define a new LoadState value for the | 402 // TODO(wtc): Define a new LoadState value for the |
406 // STATE_INIT_CONNECTION_COMPLETE state, which delays the HTTP request. | 403 // STATE_INIT_CONNECTION_COMPLETE state, which delays the HTTP request. |
407 switch (next_state_) { | 404 switch (next_state_) { |
408 case STATE_CREATE_STREAM: | 405 case STATE_CREATE_STREAM: |
409 return LOAD_STATE_WAITING_FOR_DELEGATE; | 406 return LOAD_STATE_WAITING_FOR_DELEGATE; |
410 case STATE_CREATE_STREAM_COMPLETE: | 407 case STATE_CREATE_STREAM_COMPLETE: |
411 return stream_request_->GetLoadState(); | 408 return stream_request_->GetLoadState(); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 return OK; | 726 return OK; |
730 return ERR_IO_PENDING; | 727 return ERR_IO_PENDING; |
731 } | 728 } |
732 | 729 |
733 int HttpNetworkTransaction::DoCreateStream() { | 730 int HttpNetworkTransaction::DoCreateStream() { |
734 // TODO(mmenke): Remove ScopedTracker below once crbug.com/424359 is fixed. | 731 // TODO(mmenke): Remove ScopedTracker below once crbug.com/424359 is fixed. |
735 tracked_objects::ScopedTracker tracking_profile( | 732 tracked_objects::ScopedTracker tracking_profile( |
736 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 733 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
737 "424359 HttpNetworkTransaction::DoCreateStream")); | 734 "424359 HttpNetworkTransaction::DoCreateStream")); |
738 | 735 |
| 736 response_.network_accessed = true; |
| 737 |
739 next_state_ = STATE_CREATE_STREAM_COMPLETE; | 738 next_state_ = STATE_CREATE_STREAM_COMPLETE; |
740 if (ForWebSocketHandshake()) { | 739 if (ForWebSocketHandshake()) { |
741 stream_request_.reset( | 740 stream_request_.reset( |
742 session_->http_stream_factory_for_websocket() | 741 session_->http_stream_factory_for_websocket() |
743 ->RequestWebSocketHandshakeStream( | 742 ->RequestWebSocketHandshakeStream( |
744 *request_, | 743 *request_, |
745 priority_, | 744 priority_, |
746 server_ssl_config_, | 745 server_ssl_config_, |
747 proxy_ssl_config_, | 746 proxy_ssl_config_, |
748 this, | 747 this, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 send_start_time_ = base::TimeTicks::Now(); | 966 send_start_time_ = base::TimeTicks::Now(); |
968 next_state_ = STATE_SEND_REQUEST_COMPLETE; | 967 next_state_ = STATE_SEND_REQUEST_COMPLETE; |
969 | 968 |
970 return stream_->SendRequest(request_headers_, &response_, io_callback_); | 969 return stream_->SendRequest(request_headers_, &response_, io_callback_); |
971 } | 970 } |
972 | 971 |
973 int HttpNetworkTransaction::DoSendRequestComplete(int result) { | 972 int HttpNetworkTransaction::DoSendRequestComplete(int result) { |
974 send_end_time_ = base::TimeTicks::Now(); | 973 send_end_time_ = base::TimeTicks::Now(); |
975 if (result < 0) | 974 if (result < 0) |
976 return HandleIOError(result); | 975 return HandleIOError(result); |
977 response_.network_accessed = true; | |
978 next_state_ = STATE_READ_HEADERS; | 976 next_state_ = STATE_READ_HEADERS; |
979 return OK; | 977 return OK; |
980 } | 978 } |
981 | 979 |
982 int HttpNetworkTransaction::DoReadHeaders() { | 980 int HttpNetworkTransaction::DoReadHeaders() { |
983 next_state_ = STATE_READ_HEADERS_COMPLETE; | 981 next_state_ = STATE_READ_HEADERS_COMPLETE; |
984 return stream_->ReadResponseHeaders(io_callback_); | 982 return stream_->ReadResponseHeaders(io_callback_); |
985 } | 983 } |
986 | 984 |
987 int HttpNetworkTransaction::DoReadHeadersComplete(int result) { | 985 int HttpNetworkTransaction::DoReadHeadersComplete(int result) { |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 DCHECK(stream_request_); | 1617 DCHECK(stream_request_); |
1620 | 1618 |
1621 // Since the transaction can restart with auth credentials, it may create a | 1619 // Since the transaction can restart with auth credentials, it may create a |
1622 // stream more than once. Accumulate all of the connection attempts across | 1620 // stream more than once. Accumulate all of the connection attempts across |
1623 // those streams by appending them to the vector: | 1621 // those streams by appending them to the vector: |
1624 for (const auto& attempt : stream_request_->connection_attempts()) | 1622 for (const auto& attempt : stream_request_->connection_attempts()) |
1625 connection_attempts_.push_back(attempt); | 1623 connection_attempts_.push_back(attempt); |
1626 } | 1624 } |
1627 | 1625 |
1628 } // namespace net | 1626 } // namespace net |
OLD | NEW |