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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 break; | 971 break; |
972 case ERROR_CLASS_OK: | 972 case ERROR_CLASS_OK: |
973 if (response.lines.size() != 1) | 973 if (response.lines.size() != 1) |
974 return Stop(ERR_INVALID_RESPONSE); | 974 return Stop(ERR_INVALID_RESPONSE); |
975 int64 size; | 975 int64 size; |
976 if (!base::StringToInt64(response.lines[0], &size)) | 976 if (!base::StringToInt64(response.lines[0], &size)) |
977 return Stop(ERR_INVALID_RESPONSE); | 977 return Stop(ERR_INVALID_RESPONSE); |
978 if (size < 0) | 978 if (size < 0) |
979 return Stop(ERR_INVALID_RESPONSE); | 979 return Stop(ERR_INVALID_RESPONSE); |
980 | 980 |
981 // Some FTP servers respond with success to the SIZE command | 981 // A successful response to SIZE does not mean the resource is a file. |
982 // for directories, and return 0 size. Make sure we don't set | 982 // Some FTP servers (for example, the qnx one) send a SIZE even for |
983 // the resource type to file if that's the case. | 983 // directories. |
984 if (size > 0) { | 984 response_.expected_content_size = size; |
985 response_.expected_content_size = size; | |
986 resource_type_ = RESOURCE_TYPE_FILE; | |
987 } | |
988 break; | 985 break; |
989 case ERROR_CLASS_INFO_NEEDED: | 986 case ERROR_CLASS_INFO_NEEDED: |
990 break; | 987 break; |
991 case ERROR_CLASS_TRANSIENT_ERROR: | 988 case ERROR_CLASS_TRANSIENT_ERROR: |
992 break; | 989 break; |
993 case ERROR_CLASS_PERMANENT_ERROR: | 990 case ERROR_CLASS_PERMANENT_ERROR: |
994 // It's possible that SIZE failed because the path is a directory. | 991 // It's possible that SIZE failed because the path is a directory. |
995 if (resource_type_ == RESOURCE_TYPE_UNKNOWN && | 992 if (resource_type_ == RESOURCE_TYPE_UNKNOWN && |
996 response.status_code != 550) { | 993 response.status_code != 550) { |
997 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code)); | 994 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code)); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 if (!had_error_type[type]) { | 1336 if (!had_error_type[type]) { |
1340 had_error_type[type] = true; | 1337 had_error_type[type] = true; |
1341 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", | 1338 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", |
1342 type, NUM_OF_NET_ERROR_TYPES); | 1339 type, NUM_OF_NET_ERROR_TYPES); |
1343 } | 1340 } |
1344 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", | 1341 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", |
1345 type, NUM_OF_NET_ERROR_TYPES); | 1342 type, NUM_OF_NET_ERROR_TYPES); |
1346 } | 1343 } |
1347 | 1344 |
1348 } // namespace net | 1345 } // namespace net |
OLD | NEW |