Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 512 rv = DoGenerateServerAuthToken(); | 512 rv = DoGenerateServerAuthToken(); |
| 513 break; | 513 break; |
| 514 case STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE: | 514 case STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE: |
| 515 rv = DoGenerateServerAuthTokenComplete(rv); | 515 rv = DoGenerateServerAuthTokenComplete(rv); |
| 516 break; | 516 break; |
| 517 case STATE_SEND_REQUEST: | 517 case STATE_SEND_REQUEST: |
| 518 DCHECK_EQ(OK, rv); | 518 DCHECK_EQ(OK, rv); |
| 519 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, NULL); | 519 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, NULL); |
| 520 rv = DoSendRequest(); | 520 rv = DoSendRequest(); |
| 521 break; | 521 break; |
| 522 case STATE_SEND_REQUEST_INTERCEPT_COMPLETE: | |
| 523 rv = DoSendRequestInterceptComplete(rv); | |
| 524 break; | |
| 522 case STATE_SEND_REQUEST_COMPLETE: | 525 case STATE_SEND_REQUEST_COMPLETE: |
| 523 rv = DoSendRequestComplete(rv); | 526 rv = DoSendRequestComplete(rv); |
| 524 net_log_.EndEventWithNetErrorCode( | 527 net_log_.EndEventWithNetErrorCode( |
| 525 NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, rv); | 528 NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, rv); |
| 526 break; | 529 break; |
| 527 case STATE_READ_HEADERS: | 530 case STATE_READ_HEADERS: |
| 528 DCHECK_EQ(OK, rv); | 531 DCHECK_EQ(OK, rv); |
| 529 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, NULL); | 532 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, NULL); |
| 530 rv = DoReadHeaders(); | 533 rv = DoReadHeaders(); |
| 531 break; | 534 break; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 659 } | 662 } |
| 660 | 663 |
| 661 int HttpNetworkTransaction::DoGenerateServerAuthTokenComplete(int rv) { | 664 int HttpNetworkTransaction::DoGenerateServerAuthTokenComplete(int rv) { |
| 662 DCHECK_NE(ERR_IO_PENDING, rv); | 665 DCHECK_NE(ERR_IO_PENDING, rv); |
| 663 if (rv == OK) | 666 if (rv == OK) |
| 664 next_state_ = STATE_SEND_REQUEST; | 667 next_state_ = STATE_SEND_REQUEST; |
| 665 return rv; | 668 return rv; |
| 666 } | 669 } |
| 667 | 670 |
| 668 int HttpNetworkTransaction::DoSendRequest() { | 671 int HttpNetworkTransaction::DoSendRequest() { |
| 669 next_state_ = STATE_SEND_REQUEST_COMPLETE; | 672 next_state_ = STATE_SEND_REQUEST_INTERCEPT_COMPLETE; |
| 670 | 673 |
| 671 UploadDataStream* request_body = NULL; | 674 request_body_.reset(NULL); |
| 672 if (request_->upload_data) { | 675 if (request_->upload_data) { |
| 673 int error_code; | 676 int error_code; |
| 674 request_body = UploadDataStream::Create(request_->upload_data, &error_code); | 677 request_body_.reset( |
| 675 if (!request_body) | 678 UploadDataStream::Create(request_->upload_data, &error_code)); |
| 679 if (!request_body_.get()) | |
| 676 return error_code; | 680 return error_code; |
| 677 } | 681 } |
| 678 | 682 |
| 683 headers_valid_ = false; | |
| 684 | |
| 679 // This is constructed lazily (instead of within our Start method), so that | 685 // This is constructed lazily (instead of within our Start method), so that |
| 680 // we have proxy info available. | 686 // we have proxy info available. |
| 681 if (request_headers_.IsEmpty()) { | 687 if (request_headers_.IsEmpty()) { |
| 682 bool using_proxy = (proxy_info_.is_http()|| proxy_info_.is_https()) && | 688 bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && |
| 683 !is_https_request(); | 689 !is_https_request(); |
| 684 HttpUtil::BuildRequestHeaders(request_, request_body, auth_controllers_, | 690 HttpUtil::BuildRequestHeaders(request_, request_body_.get(), |
| 691 auth_controllers_, | |
| 685 ShouldApplyServerAuth(), | 692 ShouldApplyServerAuth(), |
| 686 ShouldApplyProxyAuth(), using_proxy, | 693 ShouldApplyProxyAuth(), using_proxy, |
| 687 &request_headers_); | 694 &request_headers_); |
| 688 | |
| 689 if (session_->network_delegate()) | |
| 690 session_->network_delegate()->NotifySendHttpRequest(&request_headers_); | |
| 691 } | 695 } |
| 692 | 696 |
| 693 headers_valid_ = false; | 697 if (session_->network_delegate()) { |
| 694 return stream_->SendRequest(request_headers_, request_body, &response_, | 698 if (session_->network_delegate()->NotifyBeforeHttpRequest( |
|
rvargas (doing something else)
2011/03/17 19:40:20
For every cached request that ends up re-validated
Matt Perry
2011/03/17 19:52:18
Oh, I thought once HttpCache::Transaction::DoCache
| |
| 695 &io_callback_); | 699 request_->request_id, &request_headers_, &io_callback_)) |
|
willchan no longer on Chromium
2011/03/17 15:55:54
Isn't the use of io_callback here a bug? You don't
Matt Perry
2011/03/22 21:11:43
Done.
| |
| 700 return ERR_IO_PENDING; | |
| 701 } | |
| 702 | |
| 703 return OK; | |
| 704 } | |
| 705 | |
| 706 int HttpNetworkTransaction::DoSendRequestInterceptComplete(int result) { | |
| 707 next_state_ = STATE_SEND_REQUEST_COMPLETE; | |
| 708 if (result == net::OK) { | |
| 709 return stream_->SendRequest( | |
| 710 request_headers_, request_body_.release(), &response_, &io_callback_); | |
| 711 } | |
| 712 return result; | |
| 696 } | 713 } |
| 697 | 714 |
| 698 int HttpNetworkTransaction::DoSendRequestComplete(int result) { | 715 int HttpNetworkTransaction::DoSendRequestComplete(int result) { |
| 699 if (result < 0) | 716 if (result < 0) |
| 700 return HandleIOError(result); | 717 return HandleIOError(result); |
| 701 next_state_ = STATE_READ_HEADERS; | 718 next_state_ = STATE_READ_HEADERS; |
| 702 return OK; | 719 return OK; |
| 703 } | 720 } |
| 704 | 721 |
| 705 int HttpNetworkTransaction::DoReadHeaders() { | 722 int HttpNetworkTransaction::DoReadHeaders() { |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1232 case s: \ | 1249 case s: \ |
| 1233 description = base::StringPrintf("%s (0x%08X)", #s, s); \ | 1250 description = base::StringPrintf("%s (0x%08X)", #s, s); \ |
| 1234 break | 1251 break |
| 1235 | 1252 |
| 1236 std::string HttpNetworkTransaction::DescribeState(State state) { | 1253 std::string HttpNetworkTransaction::DescribeState(State state) { |
| 1237 std::string description; | 1254 std::string description; |
| 1238 switch (state) { | 1255 switch (state) { |
| 1239 STATE_CASE(STATE_CREATE_STREAM); | 1256 STATE_CASE(STATE_CREATE_STREAM); |
| 1240 STATE_CASE(STATE_CREATE_STREAM_COMPLETE); | 1257 STATE_CASE(STATE_CREATE_STREAM_COMPLETE); |
| 1241 STATE_CASE(STATE_SEND_REQUEST); | 1258 STATE_CASE(STATE_SEND_REQUEST); |
| 1259 STATE_CASE(STATE_SEND_REQUEST_INTERCEPT_COMPLETE); | |
| 1242 STATE_CASE(STATE_SEND_REQUEST_COMPLETE); | 1260 STATE_CASE(STATE_SEND_REQUEST_COMPLETE); |
| 1243 STATE_CASE(STATE_READ_HEADERS); | 1261 STATE_CASE(STATE_READ_HEADERS); |
| 1244 STATE_CASE(STATE_READ_HEADERS_COMPLETE); | 1262 STATE_CASE(STATE_READ_HEADERS_COMPLETE); |
| 1245 STATE_CASE(STATE_READ_BODY); | 1263 STATE_CASE(STATE_READ_BODY); |
| 1246 STATE_CASE(STATE_READ_BODY_COMPLETE); | 1264 STATE_CASE(STATE_READ_BODY_COMPLETE); |
| 1247 STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART); | 1265 STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART); |
| 1248 STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE); | 1266 STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE); |
| 1249 STATE_CASE(STATE_NONE); | 1267 STATE_CASE(STATE_NONE); |
| 1250 default: | 1268 default: |
| 1251 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, | 1269 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, |
| 1252 state); | 1270 state); |
| 1253 break; | 1271 break; |
| 1254 } | 1272 } |
| 1255 return description; | 1273 return description; |
| 1256 } | 1274 } |
| 1257 | 1275 |
| 1258 #undef STATE_CASE | 1276 #undef STATE_CASE |
| 1259 | 1277 |
| 1260 } // namespace net | 1278 } // namespace net |
| OLD | NEW |