| OLD | NEW |
| 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/connection_type_histograms.h" | 9 #include "net/base/connection_type_histograms.h" |
| 10 #include "net/base/load_log.h" |
| 10 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 11 #include "net/ftp/ftp_network_session.h" | 12 #include "net/ftp/ftp_network_session.h" |
| 12 #include "net/ftp/ftp_request_info.h" | 13 #include "net/ftp/ftp_request_info.h" |
| 13 #include "net/socket/client_socket.h" | 14 #include "net/socket/client_socket.h" |
| 14 #include "net/socket/client_socket_factory.h" | 15 #include "net/socket/client_socket_factory.h" |
| 15 | 16 |
| 16 // TODO(ibrar): Try to avoid sscanf. | 17 // TODO(ibrar): Try to avoid sscanf. |
| 17 #if !defined(COMPILER_MSVC) | 18 #if !defined(COMPILER_MSVC) |
| 18 #define sscanf_s sscanf | 19 #define sscanf_s sscanf |
| 19 #endif | 20 #endif |
| (...skipping 22 matching lines...) Expand all Loading... |
| 42 is_anonymous_(false), | 43 is_anonymous_(false), |
| 43 retr_failed_(false), | 44 retr_failed_(false), |
| 44 data_connection_port_(0), | 45 data_connection_port_(0), |
| 45 socket_factory_(socket_factory), | 46 socket_factory_(socket_factory), |
| 46 next_state_(STATE_NONE) { | 47 next_state_(STATE_NONE) { |
| 47 } | 48 } |
| 48 | 49 |
| 49 FtpNetworkTransaction::~FtpNetworkTransaction() { | 50 FtpNetworkTransaction::~FtpNetworkTransaction() { |
| 50 } | 51 } |
| 51 | 52 |
| 52 int FtpNetworkTransaction::Start(const FtpRequestInfo* request_info, | 53 int FtpNetworkTransaction::Start(LoadLog* load_log, |
| 54 const FtpRequestInfo* request_info, |
| 53 CompletionCallback* callback) { | 55 CompletionCallback* callback) { |
| 56 load_log_ = load_log; |
| 54 request_ = request_info; | 57 request_ = request_info; |
| 55 | 58 |
| 56 next_state_ = STATE_CTRL_INIT; | 59 next_state_ = STATE_CTRL_INIT; |
| 57 int rv = DoLoop(OK); | 60 int rv = DoLoop(OK); |
| 58 if (rv == ERR_IO_PENDING) | 61 if (rv == ERR_IO_PENDING) |
| 59 user_callback_ = callback; | 62 user_callback_ = callback; |
| 60 return rv; | 63 return rv; |
| 61 } | 64 } |
| 62 | 65 |
| 63 int FtpNetworkTransaction::Stop(int error) { | 66 int FtpNetworkTransaction::Stop(int error) { |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 next_state_ = STATE_CTRL_RESOLVE_HOST_COMPLETE; | 386 next_state_ = STATE_CTRL_RESOLVE_HOST_COMPLETE; |
| 384 | 387 |
| 385 std::string host; | 388 std::string host; |
| 386 int port; | 389 int port; |
| 387 | 390 |
| 388 host = request_->url.host(); | 391 host = request_->url.host(); |
| 389 port = request_->url.EffectiveIntPort(); | 392 port = request_->url.EffectiveIntPort(); |
| 390 | 393 |
| 391 HostResolver::RequestInfo info(host, port); | 394 HostResolver::RequestInfo info(host, port); |
| 392 // No known referrer. | 395 // No known referrer. |
| 393 return resolver_.Resolve(info, &addresses_, &io_callback_); | 396 return resolver_.Resolve(load_log_, info, &addresses_, &io_callback_); |
| 394 } | 397 } |
| 395 | 398 |
| 396 int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) { | 399 int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) { |
| 397 if (result == OK) | 400 if (result == OK) |
| 398 next_state_ = STATE_CTRL_CONNECT; | 401 next_state_ = STATE_CTRL_CONNECT; |
| 399 return result; | 402 return result; |
| 400 } | 403 } |
| 401 | 404 |
| 402 int FtpNetworkTransaction::DoCtrlConnect() { | 405 int FtpNetworkTransaction::DoCtrlConnect() { |
| 403 next_state_ = STATE_CTRL_CONNECT_COMPLETE; | 406 next_state_ = STATE_CTRL_CONNECT_COMPLETE; |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 | 911 |
| 909 int FtpNetworkTransaction::DoDataResolveHost() { | 912 int FtpNetworkTransaction::DoDataResolveHost() { |
| 910 if (data_socket_ != NULL && data_socket_->IsConnected()) | 913 if (data_socket_ != NULL && data_socket_->IsConnected()) |
| 911 data_socket_->Disconnect(); | 914 data_socket_->Disconnect(); |
| 912 | 915 |
| 913 next_state_ = STATE_DATA_RESOLVE_HOST_COMPLETE; | 916 next_state_ = STATE_DATA_RESOLVE_HOST_COMPLETE; |
| 914 | 917 |
| 915 HostResolver::RequestInfo info(data_connection_ip_, | 918 HostResolver::RequestInfo info(data_connection_ip_, |
| 916 data_connection_port_); | 919 data_connection_port_); |
| 917 // No known referrer. | 920 // No known referrer. |
| 918 return resolver_.Resolve(info, &addresses_, &io_callback_); | 921 return resolver_.Resolve(load_log_, info, &addresses_, &io_callback_); |
| 919 } | 922 } |
| 920 | 923 |
| 921 int FtpNetworkTransaction::DoDataResolveHostComplete(int result) { | 924 int FtpNetworkTransaction::DoDataResolveHostComplete(int result) { |
| 922 if (result == OK) | 925 if (result == OK) |
| 923 next_state_ = STATE_DATA_CONNECT; | 926 next_state_ = STATE_DATA_CONNECT; |
| 924 return result; | 927 return result; |
| 925 } | 928 } |
| 926 | 929 |
| 927 int FtpNetworkTransaction::DoDataConnect() { | 930 int FtpNetworkTransaction::DoDataConnect() { |
| 928 next_state_ = STATE_DATA_CONNECT_COMPLETE; | 931 next_state_ = STATE_DATA_CONNECT_COMPLETE; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 952 read_data_buf_->data()[0] = 0; | 955 read_data_buf_->data()[0] = 0; |
| 953 return data_socket_->Read(read_data_buf_, read_data_buf_len_, | 956 return data_socket_->Read(read_data_buf_, read_data_buf_len_, |
| 954 &io_callback_); | 957 &io_callback_); |
| 955 } | 958 } |
| 956 | 959 |
| 957 int FtpNetworkTransaction::DoDataReadComplete(int result) { | 960 int FtpNetworkTransaction::DoDataReadComplete(int result) { |
| 958 return result; | 961 return result; |
| 959 } | 962 } |
| 960 | 963 |
| 961 } // namespace net | 964 } // namespace net |
| OLD | NEW |