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

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

Issue 118459: Fix FTP binary file download issue.... (Closed) Base URL: svn://chrome-svn/chrome/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:
708 if (retr_failed_)
709 return Stop(ERR_FAILED);
709 retr_failed_ = true; 710 retr_failed_ = true;
710 next_state_ = STATE_CTRL_WRITE_PASV; 711 next_state_ = STATE_CTRL_WRITE_PASV;
711 break; 712 break;
712 default: 713 default:
713 return Stop(ERR_FAILED); 714 return Stop(ERR_FAILED);
714 } 715 }
715 return OK; 716 return OK;
716 } 717 }
717 718
718 // MDMT command 719 // MDMT command
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 } 819 }
819 820
820 int FtpNetworkTransaction::ProcessResponseQUIT(int response_code) { 821 int FtpNetworkTransaction::ProcessResponseQUIT(int response_code) {
821 ctrl_socket_->Disconnect(); 822 ctrl_socket_->Disconnect();
822 return last_error_; 823 return last_error_;
823 } 824 }
824 825
825 // Data Connection 826 // Data Connection
826 827
827 int FtpNetworkTransaction::DoDataResolveHost() { 828 int FtpNetworkTransaction::DoDataResolveHost() {
829 if (data_socket_ != NULL && data_socket_->IsConnected())
830 data_socket_->Disconnect();
831
828 next_state_ = STATE_DATA_RESOLVE_HOST_COMPLETE; 832 next_state_ = STATE_DATA_RESOLVE_HOST_COMPLETE;
829 833
830 DidStartDnsResolution(data_connection_ip_, this); 834 DidStartDnsResolution(data_connection_ip_, this);
831 return resolver_.Resolve(data_connection_ip_, data_connection_port_, 835 return resolver_.Resolve(data_connection_ip_, data_connection_port_,
832 &addresses_, &io_callback_); 836 &addresses_, &io_callback_);
833 } 837 }
834 838
835 int FtpNetworkTransaction::DoDataResolveHostComplete(int result) { 839 int FtpNetworkTransaction::DoDataResolveHostComplete(int result) {
836 bool ok = (result == OK); 840 bool ok = (result == OK);
837 DidFinishDnsResolutionWithStatus(ok, GURL(), this); 841 DidFinishDnsResolutionWithStatus(ok, GURL(), this);
838 if (ok) { 842 if (ok) {
839 next_state_ = STATE_DATA_CONNECT; 843 next_state_ = STATE_DATA_CONNECT;
840 return result; 844 return result;
841 } 845 }
842 return ERR_FAILED; 846 return ERR_FAILED;
843 } 847 }
844 848
845 int FtpNetworkTransaction::DoDataConnect() { 849 int FtpNetworkTransaction::DoDataConnect() {
846 if (data_socket_ != NULL && data_socket_->IsConnected())
847 data_socket_->Disconnect();
848
849 next_state_ = STATE_DATA_CONNECT_COMPLETE; 850 next_state_ = STATE_DATA_CONNECT_COMPLETE;
850 data_socket_.reset(socket_factory_->CreateTCPClientSocket(addresses_)); 851 data_socket_.reset(socket_factory_->CreateTCPClientSocket(addresses_));
851 return data_socket_->Connect(&io_callback_); 852 return data_socket_->Connect(&io_callback_);
852 } 853 }
853 854
854 int FtpNetworkTransaction::DoDataConnectComplete(int result) { 855 int FtpNetworkTransaction::DoDataConnectComplete(int result) {
855 if (retr_failed_) { 856 if (retr_failed_) {
856 next_state_ = STATE_CTRL_WRITE_CWD; 857 next_state_ = STATE_CTRL_WRITE_CWD;
857 } else { 858 } else {
858 next_state_ = STATE_CTRL_WRITE_SIZE; 859 next_state_ = STATE_CTRL_WRITE_SIZE;
(...skipping 11 matching lines...) Expand all
870 &io_callback_); 871 &io_callback_);
871 } 872 }
872 873
873 int FtpNetworkTransaction::DoDataReadComplete(int result) { 874 int FtpNetworkTransaction::DoDataReadComplete(int result) {
874 DLOG(INFO) << read_data_buf_->data(); // The read_data_buf_ is NULL 875 DLOG(INFO) << read_data_buf_->data(); // The read_data_buf_ is NULL
875 // terminated string. 876 // terminated string.
876 return result; 877 return result;
877 } 878 }
878 879
879 } // namespace net 880 } // 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