diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 17:35:37 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 17:35:37 +0000 |
commit | c19c715aaa359f0d99fa788051989ce2e1d4f89a (patch) | |
tree | 30d7fca8bac962eb0c4b7405a19deb7fd8293bf2 /net/ftp | |
parent | 434171fd3e3d28404c66416a4c98d492ea975b3f (diff) | |
download | chromium_src-c19c715aaa359f0d99fa788051989ce2e1d4f89a.zip chromium_src-c19c715aaa359f0d99fa788051989ce2e1d4f89a.tar.gz chromium_src-c19c715aaa359f0d99fa788051989ce2e1d4f89a.tar.bz2 |
A couple new io buffers that encapsulate more data and are therefore easier to use and easier to reason about. Inspired by RequestHeaders and ResponseHeaders in http_network_transaction.h Separated out of the refactoring of HttpNetworkTransaction to support pipelining. (http://codereview.chromium.org/249031)
BUG=13289
TEST=none
Review URL: http://codereview.chromium.org/264025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28978 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp')
-rw-r--r-- | net/ftp/ftp_network_transaction.cc | 17 | ||||
-rw-r--r-- | net/ftp/ftp_network_transaction.h | 6 |
2 files changed, 8 insertions, 15 deletions
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index 79ad77e..d4820b1 100644 --- a/net/ftp/ftp_network_transaction.cc +++ b/net/ftp/ftp_network_transaction.cc @@ -59,7 +59,6 @@ FtpNetworkTransaction::FtpNetworkTransaction( ctrl_response_buffer_(new FtpCtrlResponseBuffer()), read_data_buf_len_(0), file_data_len_(0), - write_command_buf_written_(0), last_error_(OK), system_type_(SYSTEM_TYPE_UNKNOWN), retr_failed_(false), @@ -188,8 +187,8 @@ int FtpNetworkTransaction::SendFtpCommand(const std::string& command, command_sent_ = cmd; write_command_buf_ = new IOBufferWithSize(command.length() + 2); - write_buf_ = new ReusedIOBuffer(write_command_buf_, - write_command_buf_->size()); + write_buf_ = new DrainableIOBuffer(write_command_buf_, + write_command_buf_->size()); memcpy(write_command_buf_->data(), command.data(), command.length()); memcpy(write_command_buf_->data() + command.length(), kCRLF, 2); @@ -300,7 +299,8 @@ void FtpNetworkTransaction::ResetStateForRestart() { read_data_buf_ = NULL; read_data_buf_len_ = 0; file_data_len_ = 0; - write_command_buf_written_ = 0; + if (write_buf_) + write_buf_->SetOffset(0); last_error_ = OK; retr_failed_ = false; data_connection_port_ = 0; @@ -539,10 +539,8 @@ int FtpNetworkTransaction::DoCtrlReadComplete(int result) { int FtpNetworkTransaction::DoCtrlWrite() { next_state_ = STATE_CTRL_WRITE_COMPLETE; - write_buf_->SetOffset(write_command_buf_written_); - int bytes_to_write = write_command_buf_->size() - write_command_buf_written_; return ctrl_socket_->Write(write_buf_, - bytes_to_write, + write_buf_->BytesRemaining(), &io_callback_); } @@ -550,12 +548,11 @@ int FtpNetworkTransaction::DoCtrlWriteComplete(int result) { if (result < 0) return result; - write_command_buf_written_ += result; - if (write_command_buf_written_ == write_command_buf_->size()) { + write_buf_->DidConsume(result); + if (write_buf_->BytesRemaining() == 0) { // Clear the write buffer. write_buf_ = NULL; write_command_buf_ = NULL; - write_command_buf_written_ = 0; next_state_ = STATE_CTRL_READ; } else { diff --git a/net/ftp/ftp_network_transaction.h b/net/ftp/ftp_network_transaction.h index e621a9b..7a3c3cc 100644 --- a/net/ftp/ftp_network_transaction.h +++ b/net/ftp/ftp_network_transaction.h @@ -192,11 +192,7 @@ class FtpNetworkTransaction : public FtpTransaction { // Buffer passed to the Write method of control socket. It actually writes // to the write_command_buf_ at correct offset. - scoped_refptr<ReusedIOBuffer> write_buf_; - - // Number of bytes from write_command_buf_ that we've already sent to the - // server. - int write_command_buf_written_; + scoped_refptr<DrainableIOBuffer> write_buf_; int last_error_; |