| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 647 |
| 648 int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) { | 648 int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) { |
| 649 if (result == OK) | 649 if (result == OK) |
| 650 next_state_ = STATE_CTRL_CONNECT; | 650 next_state_ = STATE_CTRL_CONNECT; |
| 651 return result; | 651 return result; |
| 652 } | 652 } |
| 653 | 653 |
| 654 int FtpNetworkTransaction::DoCtrlConnect() { | 654 int FtpNetworkTransaction::DoCtrlConnect() { |
| 655 next_state_ = STATE_CTRL_CONNECT_COMPLETE; | 655 next_state_ = STATE_CTRL_CONNECT_COMPLETE; |
| 656 ctrl_socket_ = socket_factory_->CreateTransportClientSocket( | 656 ctrl_socket_ = socket_factory_->CreateTransportClientSocket( |
| 657 addresses_, net_log_.net_log(), net_log_.source()); | 657 addresses_, NULL, net_log_.net_log(), net_log_.source()); |
| 658 net_log_.AddEvent( | 658 net_log_.AddEvent( |
| 659 NetLog::TYPE_FTP_CONTROL_CONNECTION, | 659 NetLog::TYPE_FTP_CONTROL_CONNECTION, |
| 660 ctrl_socket_->NetLog().source().ToEventParametersCallback()); | 660 ctrl_socket_->NetLog().source().ToEventParametersCallback()); |
| 661 return ctrl_socket_->Connect(io_callback_); | 661 return ctrl_socket_->Connect(io_callback_); |
| 662 } | 662 } |
| 663 | 663 |
| 664 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) { | 664 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) { |
| 665 if (result == OK) { | 665 if (result == OK) { |
| 666 // Put the peer's IP address and port into the response. | 666 // Put the peer's IP address and port into the response. |
| 667 IPEndPoint ip_endpoint; | 667 IPEndPoint ip_endpoint; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 IPEndPoint ip_endpoint; | 1224 IPEndPoint ip_endpoint; |
| 1225 AddressList data_address; | 1225 AddressList data_address; |
| 1226 // Connect to the same host as the control socket to prevent PASV port | 1226 // Connect to the same host as the control socket to prevent PASV port |
| 1227 // scanning attacks. | 1227 // scanning attacks. |
| 1228 int rv = ctrl_socket_->GetPeerAddress(&ip_endpoint); | 1228 int rv = ctrl_socket_->GetPeerAddress(&ip_endpoint); |
| 1229 if (rv != OK) | 1229 if (rv != OK) |
| 1230 return Stop(rv); | 1230 return Stop(rv); |
| 1231 data_address = AddressList::CreateFromIPAddress( | 1231 data_address = AddressList::CreateFromIPAddress( |
| 1232 ip_endpoint.address(), data_connection_port_); | 1232 ip_endpoint.address(), data_connection_port_); |
| 1233 data_socket_ = socket_factory_->CreateTransportClientSocket( | 1233 data_socket_ = socket_factory_->CreateTransportClientSocket( |
| 1234 data_address, net_log_.net_log(), net_log_.source()); | 1234 data_address, NULL, net_log_.net_log(), net_log_.source()); |
| 1235 net_log_.AddEvent( | 1235 net_log_.AddEvent( |
| 1236 NetLog::TYPE_FTP_DATA_CONNECTION, | 1236 NetLog::TYPE_FTP_DATA_CONNECTION, |
| 1237 data_socket_->NetLog().source().ToEventParametersCallback()); | 1237 data_socket_->NetLog().source().ToEventParametersCallback()); |
| 1238 return data_socket_->Connect(io_callback_); | 1238 return data_socket_->Connect(io_callback_); |
| 1239 } | 1239 } |
| 1240 | 1240 |
| 1241 int FtpNetworkTransaction::DoDataConnectComplete(int result) { | 1241 int FtpNetworkTransaction::DoDataConnectComplete(int result) { |
| 1242 if (result != OK && use_epsv_) { | 1242 if (result != OK && use_epsv_) { |
| 1243 // It's possible we hit a broken server, sadly. They can break in different | 1243 // It's possible we hit a broken server, sadly. They can break in different |
| 1244 // ways. Some time out, some reset a connection. Fall back to PASV. | 1244 // ways. Some time out, some reset a connection. Fall back to PASV. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 if (!had_error_type[type]) { | 1372 if (!had_error_type[type]) { |
| 1373 had_error_type[type] = true; | 1373 had_error_type[type] = true; |
| 1374 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", | 1374 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", |
| 1375 type, NUM_OF_NET_ERROR_TYPES); | 1375 type, NUM_OF_NET_ERROR_TYPES); |
| 1376 } | 1376 } |
| 1377 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", | 1377 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", |
| 1378 type, NUM_OF_NET_ERROR_TYPES); | 1378 type, NUM_OF_NET_ERROR_TYPES); |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 } // namespace net | 1381 } // namespace net |
| OLD | NEW |