| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/field_trial.h" | 9 #include "base/field_trial.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 return LOAD_STATE_RESOLVING_HOST; | 355 return LOAD_STATE_RESOLVING_HOST; |
| 356 case STATE_TCP_CONNECT_COMPLETE: | 356 case STATE_TCP_CONNECT_COMPLETE: |
| 357 return LOAD_STATE_CONNECTING; | 357 return LOAD_STATE_CONNECTING; |
| 358 case STATE_WRITE_HEADERS_COMPLETE: | 358 case STATE_WRITE_HEADERS_COMPLETE: |
| 359 case STATE_WRITE_BODY_COMPLETE: | 359 case STATE_WRITE_BODY_COMPLETE: |
| 360 return LOAD_STATE_SENDING_REQUEST; | 360 return LOAD_STATE_SENDING_REQUEST; |
| 361 case STATE_READ_HEADERS_COMPLETE: | 361 case STATE_READ_HEADERS_COMPLETE: |
| 362 return LOAD_STATE_WAITING_FOR_RESPONSE; | 362 return LOAD_STATE_WAITING_FOR_RESPONSE; |
| 363 case STATE_READ_BODY_COMPLETE: | 363 case STATE_READ_BODY_COMPLETE: |
| 364 return LOAD_STATE_READING_RESPONSE; | 364 return LOAD_STATE_READING_RESPONSE; |
| 365 case STATE_WAITING_FOR_USER_ACTION: |
| 366 return LOAD_STATE_WAITING_FOR_USER_ACTION; |
| 365 default: | 367 default: |
| 366 return LOAD_STATE_IDLE; | 368 return LOAD_STATE_IDLE; |
| 367 } | 369 } |
| 368 } | 370 } |
| 369 | 371 |
| 370 uint64 HttpNetworkTransaction::GetUploadProgress() const { | 372 uint64 HttpNetworkTransaction::GetUploadProgress() const { |
| 371 if (!request_body_stream_.get()) | 373 if (!request_body_stream_.get()) |
| 372 return 0; | 374 return 0; |
| 373 | 375 |
| 374 return request_body_stream_->position(); | 376 return request_body_stream_->position(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 DCHECK_EQ(OK, rv); | 495 DCHECK_EQ(OK, rv); |
| 494 TRACE_EVENT_BEGIN("http.drain_body_for_auth_restart", | 496 TRACE_EVENT_BEGIN("http.drain_body_for_auth_restart", |
| 495 request_, request_->url.spec()); | 497 request_, request_->url.spec()); |
| 496 rv = DoDrainBodyForAuthRestart(); | 498 rv = DoDrainBodyForAuthRestart(); |
| 497 break; | 499 break; |
| 498 case STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE: | 500 case STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE: |
| 499 rv = DoDrainBodyForAuthRestartComplete(rv); | 501 rv = DoDrainBodyForAuthRestartComplete(rv); |
| 500 TRACE_EVENT_END("http.drain_body_for_auth_restart", | 502 TRACE_EVENT_END("http.drain_body_for_auth_restart", |
| 501 request_, request_->url.spec()); | 503 request_, request_->url.spec()); |
| 502 break; | 504 break; |
| 505 case STATE_WAITING_FOR_USER_ACTION: |
| 506 // When this transcation is suspended for some error such as invalid SSL |
| 507 // certification, the state becomes STATE_WAITING_FOR_USER_ACTION. You |
| 508 // can check if this transaction is in this state by calling |
| 509 // GetLoadState() and compare with LOAD_STATE_WAITING_FOR_USER_ACTION. |
| 510 break; |
| 503 default: | 511 default: |
| 504 NOTREACHED() << "bad state"; | 512 NOTREACHED() << "bad state"; |
| 505 rv = ERR_FAILED; | 513 rv = ERR_FAILED; |
| 506 break; | 514 break; |
| 507 } | 515 } |
| 508 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); | 516 } while (rv != ERR_IO_PENDING && |
| 517 next_state_ != STATE_NONE && |
| 518 next_state_ != STATE_WAITING_FOR_USER_ACTION); |
| 509 | 519 |
| 510 return rv; | 520 return rv; |
| 511 } | 521 } |
| 512 | 522 |
| 513 int HttpNetworkTransaction::DoResolveProxy() { | 523 int HttpNetworkTransaction::DoResolveProxy() { |
| 514 DCHECK(!pac_request_); | 524 DCHECK(!pac_request_); |
| 515 | 525 |
| 516 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 526 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
| 517 | 527 |
| 518 if (request_->load_flags & LOAD_BYPASS_PROXY) { | 528 if (request_->load_flags & LOAD_BYPASS_PROXY) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 return connection_.socket()->Connect(&io_callback_); | 665 return connection_.socket()->Connect(&io_callback_); |
| 656 } | 666 } |
| 657 | 667 |
| 658 int HttpNetworkTransaction::DoSSLConnectComplete(int result) { | 668 int HttpNetworkTransaction::DoSSLConnectComplete(int result) { |
| 659 if (IsCertificateError(result)) | 669 if (IsCertificateError(result)) |
| 660 result = HandleCertificateError(result); | 670 result = HandleCertificateError(result); |
| 661 | 671 |
| 662 if (result == OK) { | 672 if (result == OK) { |
| 663 next_state_ = STATE_WRITE_HEADERS; | 673 next_state_ = STATE_WRITE_HEADERS; |
| 664 } else { | 674 } else { |
| 675 next_state_ = STATE_WAITING_FOR_USER_ACTION; |
| 665 result = HandleSSLHandshakeError(result); | 676 result = HandleSSLHandshakeError(result); |
| 666 } | 677 } |
| 667 return result; | 678 return result; |
| 668 } | 679 } |
| 669 | 680 |
| 670 int HttpNetworkTransaction::DoWriteHeaders() { | 681 int HttpNetworkTransaction::DoWriteHeaders() { |
| 671 next_state_ = STATE_WRITE_HEADERS_COMPLETE; | 682 next_state_ = STATE_WRITE_HEADERS_COMPLETE; |
| 672 | 683 |
| 673 // This is constructed lazily (instead of within our Start method), so that | 684 // This is constructed lazily (instead of within our Start method), so that |
| 674 // we have proxy info available. | 685 // we have proxy info available. |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 host_and_port = proxy_info_.proxy_server().host_and_port(); | 1690 host_and_port = proxy_info_.proxy_server().host_and_port(); |
| 1680 } else { | 1691 } else { |
| 1681 DCHECK(target == HttpAuth::AUTH_SERVER); | 1692 DCHECK(target == HttpAuth::AUTH_SERVER); |
| 1682 host_and_port = GetHostAndPort(request_->url); | 1693 host_and_port = GetHostAndPort(request_->url); |
| 1683 } | 1694 } |
| 1684 auth_info->host_and_port = ASCIIToWide(host_and_port); | 1695 auth_info->host_and_port = ASCIIToWide(host_and_port); |
| 1685 response_.auth_challenge = auth_info; | 1696 response_.auth_challenge = auth_info; |
| 1686 } | 1697 } |
| 1687 | 1698 |
| 1688 } // namespace net | 1699 } // namespace net |
| OLD | NEW |