| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_directory_listing_parser.h" | 5 #include "net/ftp/ftp_directory_listing_parser.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/i18n/icu_encoding_detection.h" | 9 #include "base/i18n/icu_encoding_detection.h" |
| 10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 // Use first encoding that can be used to decode the text. | 104 // Use first encoding that can be used to decode the text. |
| 105 for (size_t i = 0; i < encodings.size(); i++) { | 105 for (size_t i = 0; i < encodings.size(); i++) { |
| 106 base::string16 converted_text; | 106 base::string16 converted_text; |
| 107 if (base::CodepageToUTF16(text, | 107 if (base::CodepageToUTF16(text, |
| 108 encodings[i].c_str(), | 108 encodings[i].c_str(), |
| 109 base::OnStringConversionError::FAIL, | 109 base::OnStringConversionError::FAIL, |
| 110 &converted_text)) { | 110 &converted_text)) { |
| 111 for (size_t j = 0; j < arraysize(kNewlineSeparators); j++) { | 111 for (size_t j = 0; j < arraysize(kNewlineSeparators); j++) { |
| 112 int rv = ParseListing(converted_text, | 112 int rv = ParseListing(converted_text, |
| 113 ASCIIToUTF16(kNewlineSeparators[j]), | 113 base::ASCIIToUTF16(kNewlineSeparators[j]), |
| 114 encodings[i], | 114 encodings[i], |
| 115 current_time, | 115 current_time, |
| 116 entries, | 116 entries, |
| 117 server_type); | 117 server_type); |
| 118 if (rv == OK) | 118 if (rv == OK) |
| 119 return rv; | 119 return rv; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 136 int ParseFtpDirectoryListing(const std::string& text, | 136 int ParseFtpDirectoryListing(const std::string& text, |
| 137 const base::Time& current_time, | 137 const base::Time& current_time, |
| 138 std::vector<FtpDirectoryListingEntry>* entries) { | 138 std::vector<FtpDirectoryListingEntry>* entries) { |
| 139 FtpServerType server_type = SERVER_UNKNOWN; | 139 FtpServerType server_type = SERVER_UNKNOWN; |
| 140 int rv = DecodeAndParse(text, current_time, entries, &server_type); | 140 int rv = DecodeAndParse(text, current_time, entries, &server_type); |
| 141 UpdateFtpServerTypeHistograms(server_type); | 141 UpdateFtpServerTypeHistograms(server_type); |
| 142 return rv; | 142 return rv; |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace net | 145 } // namespace net |
| OLD | NEW |