Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: net/ftp/ftp_network_transaction.cc

Issue 118455: Binary File download issue (FTP) (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/ftp/ftp_network_transaction.h" 5 #include "net/ftp/ftp_network_transaction.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/client_socket.h" 9 #include "net/base/client_socket.h"
10 #include "net/base/client_socket_factory.h" 10 #include "net/base/client_socket_factory.h"
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 } else { 686 } else {
687 command.append(" /"); 687 command.append(" /");
688 } 688 }
689 next_state_ = STATE_CTRL_READ; 689 next_state_ = STATE_CTRL_READ;
690 return SendFtpCommand(command, COMMAND_RETR); 690 return SendFtpCommand(command, COMMAND_RETR);
691 } 691 }
692 692
693 int FtpNetworkTransaction::ProcessResponseRETR(int response_code) { 693 int FtpNetworkTransaction::ProcessResponseRETR(int response_code) {
694 switch (GetErrorClass(response_code)) { 694 switch (GetErrorClass(response_code)) {
695 case ERROR_CLASS_INITIATED: 695 case ERROR_CLASS_INITIATED:
696 next_state_ = STATE_CTRL_WRITE_QUIT;
697 break; 696 break;
698 case ERROR_CLASS_OK: 697 case ERROR_CLASS_OK:
699 next_state_ = STATE_DATA_RESOLVE_HOST; 698 next_state_ = STATE_CTRL_WRITE_QUIT;
700 break; 699 break;
701 case ERROR_CLASS_PENDING: 700 case ERROR_CLASS_PENDING:
702 next_state_ = STATE_CTRL_WRITE_PASV; 701 next_state_ = STATE_CTRL_WRITE_PASV;
703 break; 702 break;
704 case ERROR_CLASS_ERROR_RETRY: 703 case ERROR_CLASS_ERROR_RETRY:
705 if (response_code == 421 || response_code == 425 || response_code == 426) 704 if (response_code == 421 || response_code == 425 || response_code == 426)
706 return Stop(ERR_FAILED); 705 return Stop(ERR_FAILED);
707 return ERR_FAILED; // TODO(ibrar): Retry here. 706 return ERR_FAILED; // TODO(ibrar): Retry here.
708 case ERROR_CLASS_ERROR: 707 case ERROR_CLASS_ERROR:
wtc 2009/06/09 21:36:32 Our convention is to not use 'else' after 'return'
709 retr_failed_ = true; 708 if (retr_failed_) {
709 return Stop(ERR_FAILED);
710 } else {
711 retr_failed_ = true;
712 }
710 next_state_ = STATE_CTRL_WRITE_PASV; 713 next_state_ = STATE_CTRL_WRITE_PASV;
711 break; 714 break;
712 default: 715 default:
713 return Stop(ERR_FAILED); 716 return Stop(ERR_FAILED);
714 } 717 }
715 return OK; 718 return OK;
716 } 719 }
717 720
718 // MDMT command 721 // MDMT command
719 int FtpNetworkTransaction::DoCtrlWriteMDTM() { 722 int FtpNetworkTransaction::DoCtrlWriteMDTM() {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 } 821 }
819 822
820 int FtpNetworkTransaction::ProcessResponseQUIT(int response_code) { 823 int FtpNetworkTransaction::ProcessResponseQUIT(int response_code) {
821 ctrl_socket_->Disconnect(); 824 ctrl_socket_->Disconnect();
822 return last_error_; 825 return last_error_;
823 } 826 }
824 827
825 // Data Connection 828 // Data Connection
826 829
827 int FtpNetworkTransaction::DoDataResolveHost() { 830 int FtpNetworkTransaction::DoDataResolveHost() {
831 if (data_socket_ != NULL && data_socket_->IsConnected())
832 data_socket_->Disconnect();
833
828 next_state_ = STATE_DATA_RESOLVE_HOST_COMPLETE; 834 next_state_ = STATE_DATA_RESOLVE_HOST_COMPLETE;
829 835
830 DidStartDnsResolution(data_connection_ip_, this); 836 DidStartDnsResolution(data_connection_ip_, this);
831 return resolver_.Resolve(data_connection_ip_, data_connection_port_, 837 return resolver_.Resolve(data_connection_ip_, data_connection_port_,
832 &addresses_, &io_callback_); 838 &addresses_, &io_callback_);
833 } 839 }
834 840
835 int FtpNetworkTransaction::DoDataResolveHostComplete(int result) { 841 int FtpNetworkTransaction::DoDataResolveHostComplete(int result) {
836 bool ok = (result == OK); 842 bool ok = (result == OK);
837 DidFinishDnsResolutionWithStatus(ok, GURL(), this); 843 DidFinishDnsResolutionWithStatus(ok, GURL(), this);
838 if (ok) { 844 if (ok) {
839 next_state_ = STATE_DATA_CONNECT; 845 next_state_ = STATE_DATA_CONNECT;
840 return result; 846 return result;
841 } 847 }
842 return ERR_FAILED; 848 return ERR_FAILED;
843 } 849 }
844 850
845 int FtpNetworkTransaction::DoDataConnect() { 851 int FtpNetworkTransaction::DoDataConnect() {
846 if (data_socket_ != NULL && data_socket_->IsConnected())
847 data_socket_->Disconnect();
848
849 next_state_ = STATE_DATA_CONNECT_COMPLETE; 852 next_state_ = STATE_DATA_CONNECT_COMPLETE;
850 data_socket_.reset(socket_factory_->CreateTCPClientSocket(addresses_)); 853 data_socket_.reset(socket_factory_->CreateTCPClientSocket(addresses_));
851 return data_socket_->Connect(&io_callback_); 854 return data_socket_->Connect(&io_callback_);
852 } 855 }
853 856
854 int FtpNetworkTransaction::DoDataConnectComplete(int result) { 857 int FtpNetworkTransaction::DoDataConnectComplete(int result) {
855 if (retr_failed_) { 858 if (retr_failed_) {
856 next_state_ = STATE_CTRL_WRITE_CWD; 859 next_state_ = STATE_CTRL_WRITE_CWD;
857 } else { 860 } else {
858 next_state_ = STATE_CTRL_WRITE_SIZE; 861 next_state_ = STATE_CTRL_WRITE_SIZE;
(...skipping 11 matching lines...) Expand all
870 &io_callback_); 873 &io_callback_);
871 } 874 }
872 875
873 int FtpNetworkTransaction::DoDataReadComplete(int result) { 876 int FtpNetworkTransaction::DoDataReadComplete(int result) {
874 DLOG(INFO) << read_data_buf_->data(); // The read_data_buf_ is NULL 877 DLOG(INFO) << read_data_buf_->data(); // The read_data_buf_ is NULL
875 // terminated string. 878 // terminated string.
876 return result; 879 return result;
877 } 880 }
878 881
879 } // namespace net 882 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698