OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/histogram.h" | 8 #include "base/histogram.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 int rv = ctrl_socket_->GetPeerAddress(&data_address); | 1180 int rv = ctrl_socket_->GetPeerAddress(&data_address); |
1181 if (rv != OK) | 1181 if (rv != OK) |
1182 return Stop(rv); | 1182 return Stop(rv); |
1183 data_address.SetPort(data_connection_port_); | 1183 data_address.SetPort(data_connection_port_); |
1184 data_socket_.reset(socket_factory_->CreateTCPClientSocket( | 1184 data_socket_.reset(socket_factory_->CreateTCPClientSocket( |
1185 data_address, net_log_.net_log())); | 1185 data_address, net_log_.net_log())); |
1186 return data_socket_->Connect(&io_callback_); | 1186 return data_socket_->Connect(&io_callback_); |
1187 } | 1187 } |
1188 | 1188 |
1189 int FtpNetworkTransaction::DoDataConnectComplete(int result) { | 1189 int FtpNetworkTransaction::DoDataConnectComplete(int result) { |
1190 if (result == ERR_CONNECTION_TIMED_OUT && use_epsv_) { | |
1191 // It's possible we hit a broken server, sadly. Fall back to PASV. | |
1192 // TODO(phajdan.jr): remember it for future transactions with this server. | |
1193 // TODO(phajdan.jr): write a test for this code path. | |
1194 use_epsv_ = false; | |
1195 next_state_ = STATE_CTRL_WRITE_PASV; | |
1196 return OK; | |
1197 } | |
1198 | |
1199 // Only record the connection error after we've applied all our fallbacks. | |
1200 // We want to capture the final error, one we're not going to recover from. | |
1201 RecordDataConnectionError(result); | 1190 RecordDataConnectionError(result); |
1202 | |
1203 if (result != OK) | |
1204 return Stop(result); | |
1205 | |
1206 next_state_ = STATE_CTRL_WRITE_SIZE; | 1191 next_state_ = STATE_CTRL_WRITE_SIZE; |
1207 return OK; | 1192 return OK; |
1208 } | 1193 } |
1209 | 1194 |
1210 int FtpNetworkTransaction::DoDataRead() { | 1195 int FtpNetworkTransaction::DoDataRead() { |
1211 DCHECK(read_data_buf_); | 1196 DCHECK(read_data_buf_); |
1212 DCHECK_GT(read_data_buf_len_, 0); | 1197 DCHECK_GT(read_data_buf_len_, 0); |
1213 | 1198 |
1214 if (data_socket_ == NULL || !data_socket_->IsConnected()) { | 1199 if (data_socket_ == NULL || !data_socket_->IsConnected()) { |
1215 // If we don't destroy the data socket completely, some servers will wait | 1200 // If we don't destroy the data socket completely, some servers will wait |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 if (!had_error_type[type]) { | 1303 if (!had_error_type[type]) { |
1319 had_error_type[type] = true; | 1304 had_error_type[type] = true; |
1320 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", | 1305 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", |
1321 type, NUM_OF_NET_ERROR_TYPES); | 1306 type, NUM_OF_NET_ERROR_TYPES); |
1322 } | 1307 } |
1323 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", | 1308 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", |
1324 type, NUM_OF_NET_ERROR_TYPES); | 1309 type, NUM_OF_NET_ERROR_TYPES); |
1325 } | 1310 } |
1326 | 1311 |
1327 } // namespace net | 1312 } // namespace net |
OLD | NEW |