diff options
-rw-r--r-- | net/ftp/ftp_network_transaction.cc | 17 | ||||
-rw-r--r-- | net/ftp/ftp_network_transaction_unittest.cc | 5 | ||||
-rw-r--r-- | net/url_request/url_request_new_ftp_job.cc | 5 | ||||
-rw-r--r-- | net/url_request/url_request_new_ftp_job.h | 1 |
4 files changed, 28 insertions, 0 deletions
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index a90ea50..ee373be 100644 --- a/net/ftp/ftp_network_transaction.cc +++ b/net/ftp/ftp_network_transaction.cc @@ -104,6 +104,23 @@ const FtpResponseInfo* FtpNetworkTransaction::GetResponseInfo() const { } LoadState FtpNetworkTransaction::GetLoadState() const { + if (next_state_ == STATE_CTRL_RESOLVE_HOST_COMPLETE || + next_state_ == STATE_DATA_RESOLVE_HOST_COMPLETE) + return LOAD_STATE_RESOLVING_HOST; + + if (next_state_ == STATE_CTRL_CONNECT_COMPLETE || + next_state_ == STATE_DATA_CONNECT_COMPLETE) + return LOAD_STATE_CONNECTING; + + if (next_state_ == STATE_DATA_READ_COMPLETE) + return LOAD_STATE_READING_RESPONSE; + + if (command_sent_ == COMMAND_QUIT) + return LOAD_STATE_IDLE; + + if (command_sent_ != COMMAND_NONE) + return LOAD_STATE_SENDING_REQUEST; + return LOAD_STATE_IDLE; } diff --git a/net/ftp/ftp_network_transaction_unittest.cc b/net/ftp/ftp_network_transaction_unittest.cc index 10c77a3..9ee5d50 100644 --- a/net/ftp/ftp_network_transaction_unittest.cc +++ b/net/ftp/ftp_network_transaction_unittest.cc @@ -309,8 +309,10 @@ class FtpNetworkTransactionTest : public PlatformTest { mock_socket_factory_.AddMockSocket(&data_socket1); mock_socket_factory_.AddMockSocket(&data_socket2); FtpRequestInfo request_info = GetRequestInfo(request); + EXPECT_EQ(LOAD_STATE_IDLE, transaction_.GetLoadState()); ASSERT_EQ(ERR_IO_PENDING, transaction_.Start(NULL, &request_info, &callback_)); + EXPECT_NE(LOAD_STATE_IDLE, transaction_.GetLoadState()); EXPECT_EQ(expected_result, callback_.WaitForResult()); EXPECT_EQ(FtpMockControlSocket::QUIT, ctrl_socket->state()); if (expected_result == OK) { @@ -322,6 +324,7 @@ class FtpNetworkTransactionTest : public PlatformTest { callback_.WaitForResult()); EXPECT_EQ(mock_data, std::string(io_buffer->data(), mock_data.length())); } + EXPECT_EQ(LOAD_STATE_IDLE, transaction_.GetLoadState()); } void TransactionFailHelper(FtpMockControlSocket* ctrl_socket, @@ -344,9 +347,11 @@ class FtpNetworkTransactionTest : public PlatformTest { TEST_F(FtpNetworkTransactionTest, FailedLookup) { FtpRequestInfo request_info = GetRequestInfo("ftp://badhost"); host_resolver_->rules()->AddSimulatedFailure("badhost"); + EXPECT_EQ(LOAD_STATE_IDLE, transaction_.GetLoadState()); ASSERT_EQ(ERR_IO_PENDING, transaction_.Start(NULL, &request_info, &callback_)); EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); + EXPECT_EQ(LOAD_STATE_IDLE, transaction_.GetLoadState()); } TEST_F(FtpNetworkTransactionTest, DirectoryTransaction) { diff --git a/net/url_request/url_request_new_ftp_job.cc b/net/url_request/url_request_new_ftp_job.cc index 5b16e7a..0de6c78 100644 --- a/net/url_request/url_request_new_ftp_job.cc +++ b/net/url_request/url_request_new_ftp_job.cc @@ -101,6 +101,11 @@ void URLRequestNewFtpJob::Kill() { URLRequestJob::Kill(); } +net::LoadState URLRequestNewFtpJob::GetLoadState() const { + return transaction_.get() ? + transaction_->GetLoadState() : net::LOAD_STATE_IDLE; +} + bool URLRequestNewFtpJob::ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read) { diff --git a/net/url_request/url_request_new_ftp_job.h b/net/url_request/url_request_new_ftp_job.h index 4cca9a0..ebdb0e4 100644 --- a/net/url_request/url_request_new_ftp_job.h +++ b/net/url_request/url_request_new_ftp_job.h @@ -30,6 +30,7 @@ class URLRequestNewFtpJob : public URLRequestJob { // URLRequestJob methods: virtual void Start(); virtual void Kill(); + virtual net::LoadState GetLoadState() const; // TODO(ibrar): Yet to give another look at this function. virtual uint64 GetUploadProgress() const { return 0; } |