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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 | 648 |
649 int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) { | 649 int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) { |
650 if (result == OK) | 650 if (result == OK) |
651 next_state_ = STATE_CTRL_CONNECT; | 651 next_state_ = STATE_CTRL_CONNECT; |
652 return result; | 652 return result; |
653 } | 653 } |
654 | 654 |
655 int FtpNetworkTransaction::DoCtrlConnect() { | 655 int FtpNetworkTransaction::DoCtrlConnect() { |
656 next_state_ = STATE_CTRL_CONNECT_COMPLETE; | 656 next_state_ = STATE_CTRL_CONNECT_COMPLETE; |
657 ctrl_socket_ = socket_factory_->CreateTransportClientSocket( | 657 ctrl_socket_ = socket_factory_->CreateTransportClientSocket( |
658 addresses_, net_log_.net_log(), net_log_.source()); | 658 addresses_, NULL, net_log_.net_log(), net_log_.source()); |
659 net_log_.AddEvent( | 659 net_log_.AddEvent( |
660 NetLog::TYPE_FTP_CONTROL_CONNECTION, | 660 NetLog::TYPE_FTP_CONTROL_CONNECTION, |
661 ctrl_socket_->NetLog().source().ToEventParametersCallback()); | 661 ctrl_socket_->NetLog().source().ToEventParametersCallback()); |
662 return ctrl_socket_->Connect(io_callback_); | 662 return ctrl_socket_->Connect(io_callback_); |
663 } | 663 } |
664 | 664 |
665 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) { | 665 int FtpNetworkTransaction::DoCtrlConnectComplete(int result) { |
666 if (result == OK) { | 666 if (result == OK) { |
667 // Put the peer's IP address and port into the response. | 667 // Put the peer's IP address and port into the response. |
668 IPEndPoint ip_endpoint; | 668 IPEndPoint ip_endpoint; |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 IPEndPoint ip_endpoint; | 1225 IPEndPoint ip_endpoint; |
1226 AddressList data_address; | 1226 AddressList data_address; |
1227 // Connect to the same host as the control socket to prevent PASV port | 1227 // Connect to the same host as the control socket to prevent PASV port |
1228 // scanning attacks. | 1228 // scanning attacks. |
1229 int rv = ctrl_socket_->GetPeerAddress(&ip_endpoint); | 1229 int rv = ctrl_socket_->GetPeerAddress(&ip_endpoint); |
1230 if (rv != OK) | 1230 if (rv != OK) |
1231 return Stop(rv); | 1231 return Stop(rv); |
1232 data_address = AddressList::CreateFromIPAddress( | 1232 data_address = AddressList::CreateFromIPAddress( |
1233 ip_endpoint.address(), data_connection_port_); | 1233 ip_endpoint.address(), data_connection_port_); |
1234 data_socket_ = socket_factory_->CreateTransportClientSocket( | 1234 data_socket_ = socket_factory_->CreateTransportClientSocket( |
1235 data_address, net_log_.net_log(), net_log_.source()); | 1235 data_address, NULL, net_log_.net_log(), net_log_.source()); |
1236 net_log_.AddEvent( | 1236 net_log_.AddEvent( |
1237 NetLog::TYPE_FTP_DATA_CONNECTION, | 1237 NetLog::TYPE_FTP_DATA_CONNECTION, |
1238 data_socket_->NetLog().source().ToEventParametersCallback()); | 1238 data_socket_->NetLog().source().ToEventParametersCallback()); |
1239 return data_socket_->Connect(io_callback_); | 1239 return data_socket_->Connect(io_callback_); |
1240 } | 1240 } |
1241 | 1241 |
1242 int FtpNetworkTransaction::DoDataConnectComplete(int result) { | 1242 int FtpNetworkTransaction::DoDataConnectComplete(int result) { |
1243 if (result != OK && use_epsv_) { | 1243 if (result != OK && use_epsv_) { |
1244 // It's possible we hit a broken server, sadly. They can break in different | 1244 // It's possible we hit a broken server, sadly. They can break in different |
1245 // ways. Some time out, some reset a connection. Fall back to PASV. | 1245 // 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... |
1373 if (!had_error_type[type]) { | 1373 if (!had_error_type[type]) { |
1374 had_error_type[type] = true; | 1374 had_error_type[type] = true; |
1375 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", | 1375 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", |
1376 type, NUM_OF_NET_ERROR_TYPES); | 1376 type, NUM_OF_NET_ERROR_TYPES); |
1377 } | 1377 } |
1378 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", | 1378 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", |
1379 type, NUM_OF_NET_ERROR_TYPES); | 1379 type, NUM_OF_NET_ERROR_TYPES); |
1380 } | 1380 } |
1381 | 1381 |
1382 } // namespace net | 1382 } // namespace net |
OLD | NEW |