diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-31 17:29:25 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-31 17:29:25 +0000 |
commit | e83326f8400791e92875546b2fd1885a3a17d1b1 (patch) | |
tree | edbe773208b1a9f6965b45b55da10afd210ea7bb /net/ftp | |
parent | 8e0a03bf3b1aacaa7a2bc2561d8eb1b83eb9c2e5 (diff) | |
download | chromium_src-e83326f8400791e92875546b2fd1885a3a17d1b1.zip chromium_src-e83326f8400791e92875546b2fd1885a3a17d1b1.tar.gz chromium_src-e83326f8400791e92875546b2fd1885a3a17d1b1.tar.bz2 |
Convert more callers of the integer/string functions to using
string_number_conversions.h
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/3013046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54454 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp')
-rw-r--r-- | net/ftp/ftp_ctrl_response_buffer.cc | 5 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_buffer_unittest.cc | 15 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_ls.cc | 7 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_mlsd.cc | 13 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_netware.cc | 3 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_vms.cc | 19 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_windows.cc | 13 | ||||
-rw-r--r-- | net/ftp/ftp_network_transaction.cc | 3 | ||||
-rw-r--r-- | net/ftp/ftp_util.cc | 9 |
9 files changed, 49 insertions, 38 deletions
diff --git a/net/ftp/ftp_ctrl_response_buffer.cc b/net/ftp/ftp_ctrl_response_buffer.cc index 8ea58cc..c9ee5dd 100644 --- a/net/ftp/ftp_ctrl_response_buffer.cc +++ b/net/ftp/ftp_ctrl_response_buffer.cc @@ -5,7 +5,8 @@ #include "net/ftp/ftp_ctrl_response_buffer.h" #include "base/logging.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" +//#include "base/string_util.h" #include "net/base/net_errors.h" namespace net { @@ -69,7 +70,7 @@ FtpCtrlResponseBuffer::ParsedLine FtpCtrlResponseBuffer::ParseLine( ParsedLine result; if (line.length() >= 3) { - if (StringToInt(line.substr(0, 3), &result.status_code)) + if (base::StringToInt(line.substr(0, 3), &result.status_code)) result.has_status_code = (100 <= result.status_code && result.status_code <= 599); if (result.has_status_code && line.length() >= 4 && line[3] == ' ') { diff --git a/net/ftp/ftp_directory_listing_buffer_unittest.cc b/net/ftp/ftp_directory_listing_buffer_unittest.cc index c3c55d0..f07f535 100644 --- a/net/ftp/ftp_directory_listing_buffer_unittest.cc +++ b/net/ftp/ftp_directory_listing_buffer_unittest.cc @@ -7,6 +7,7 @@ #include "base/file_util.h" #include "base/format_macros.h" #include "base/path_service.h" +#include "base/string_number_conversions.h" #include "base/string_tokenizer.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -86,15 +87,17 @@ TEST(FtpDirectoryListingBufferTest, Parse) { for (size_t i = 0; i < lines.size() / 8; i++) { std::string type(lines[8 * i]); std::string name(lines[8 * i + 1]); - int64 size = StringToInt64(lines[8 * i + 2]); + int64 size; + base::StringToInt64(lines[8 * i + 2], &size); SCOPED_TRACE(StringPrintf("Filename: %s", name.c_str())); - int year = StringToInt(lines[8 * i + 3]); - int month = StringToInt(lines[8 * i + 4]); - int day_of_month = StringToInt(lines[8 * i + 5]); - int hour = StringToInt(lines[8 * i + 6]); - int minute = StringToInt(lines[8 * i + 7]); + int year, month, day_of_month, hour, minute; + base::StringToInt(lines[8 * i + 3], &year); + base::StringToInt(lines[8 * i + 4], &month); + base::StringToInt(lines[8 * i + 5], &day_of_month); + base::StringToInt(lines[8 * i + 6], &hour); + base::StringToInt(lines[8 * i + 7], &minute); ASSERT_TRUE(buffer.EntryAvailable()); net::FtpDirectoryListingEntry entry = buffer.PopEntry(); diff --git a/net/ftp/ftp_directory_listing_parser_ls.cc b/net/ftp/ftp_directory_listing_parser_ls.cc index 55f7844..969d26a 100644 --- a/net/ftp/ftp_directory_listing_parser_ls.cc +++ b/net/ftp/ftp_directory_listing_parser_ls.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this +// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this // source code is governed by a BSD-style license that can be found in the // LICENSE file. @@ -6,6 +6,7 @@ #include <vector> +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "net/ftp/ftp_util.h" @@ -107,7 +108,7 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) { received_total_line_ = true; int total_number; - if (!StringToInt(columns[1], &total_number)) + if (!base::StringToInt(columns[1], &total_number)) return false; if (total_number < 0) return false; @@ -137,7 +138,7 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) { entry.type = FtpDirectoryListingEntry::FILE; } - if (!StringToInt64(columns[2 + column_offset], &entry.size)) + if (!base::StringToInt64(columns[2 + column_offset], &entry.size)) return false; if (entry.size < 0) return false; diff --git a/net/ftp/ftp_directory_listing_parser_mlsd.cc b/net/ftp/ftp_directory_listing_parser_mlsd.cc index 7715dd3..656ae73 100644 --- a/net/ftp/ftp_directory_listing_parser_mlsd.cc +++ b/net/ftp/ftp_directory_listing_parser_mlsd.cc @@ -8,6 +8,7 @@ #include <vector> #include "base/stl_util-inl.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -26,15 +27,15 @@ bool MlsdDateListingToTime(const string16& text, base::Time* time) { if (text.length() < 14) return false; - if (!StringToInt(text.substr(0, 4), &time_exploded.year)) + if (!base::StringToInt(text.substr(0, 4), &time_exploded.year)) return false; - if (!StringToInt(text.substr(4, 2), &time_exploded.month)) + if (!base::StringToInt(text.substr(4, 2), &time_exploded.month)) return false; - if (!StringToInt(text.substr(6, 2), &time_exploded.day_of_month)) + if (!base::StringToInt(text.substr(6, 2), &time_exploded.day_of_month)) return false; - if (!StringToInt(text.substr(8, 2), &time_exploded.hour)) + if (!base::StringToInt(text.substr(8, 2), &time_exploded.hour)) return false; - if (!StringToInt(text.substr(10, 2), &time_exploded.minute)) + if (!base::StringToInt(text.substr(10, 2), &time_exploded.minute)) return false; // We don't know the time zone of the server, so just use local time. @@ -95,7 +96,7 @@ bool FtpDirectoryListingParserMlsd::ConsumeLine(const string16& line) { entry.type = FtpDirectoryListingEntry::FILE; if (!ContainsKey(facts, "size")) return false; - if (!StringToInt64(facts["size"], &entry.size)) + if (!base::StringToInt64(facts["size"], &entry.size)) return false; } else { // Ignore other types of entries. They are either not interesting for us diff --git a/net/ftp/ftp_directory_listing_parser_netware.cc b/net/ftp/ftp_directory_listing_parser_netware.cc index 60c6c6a..eb6518c 100644 --- a/net/ftp/ftp_directory_listing_parser_netware.cc +++ b/net/ftp/ftp_directory_listing_parser_netware.cc @@ -6,6 +6,7 @@ #include <vector> +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "net/ftp/ftp_util.h" @@ -68,7 +69,7 @@ bool FtpDirectoryListingParserNetware::ConsumeLine(const string16& line) { if (!LooksLikeNetwarePermissionsListing(columns[1])) return false; - if (!StringToInt64(columns[3], &entry.size)) + if (!base::StringToInt64(columns[3], &entry.size)) return false; if (entry.size < 0) return false; diff --git a/net/ftp/ftp_directory_listing_parser_vms.cc b/net/ftp/ftp_directory_listing_parser_vms.cc index f8d3fbb..90fd466 100644 --- a/net/ftp/ftp_directory_listing_parser_vms.cc +++ b/net/ftp/ftp_directory_listing_parser_vms.cc @@ -6,8 +6,9 @@ #include <vector> -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" +#include "base/string_util.h" #include "net/ftp/ftp_util.h" namespace { @@ -23,7 +24,7 @@ bool ParseVmsFilename(const string16& raw_filename, string16* parsed_filename, if (listing_parts.size() != 2) return false; int version_number; - if (!StringToInt(listing_parts[1], &version_number)) + if (!base::StringToInt(listing_parts[1], &version_number)) return false; if (version_number < 0) return false; @@ -52,7 +53,7 @@ bool ParseVmsFilesize(const string16& input, int64* size) { // best information we have. const int kBlockSize = 512; - if (StringToInt64(input, size)) { + if (base::StringToInt64(input, size)) { *size *= kBlockSize; return true; } @@ -63,9 +64,9 @@ bool ParseVmsFilesize(const string16& input, int64* size) { return false; int64 blocks_used, blocks_allocated; - if (!StringToInt64(parts[0], &blocks_used)) + if (!base::StringToInt64(parts[0], &blocks_used)) return false; - if (!StringToInt64(parts[1], &blocks_allocated)) + if (!base::StringToInt64(parts[1], &blocks_allocated)) return false; if (blocks_used > blocks_allocated) return false; @@ -126,12 +127,12 @@ bool VmsDateListingToTime(const std::vector<string16>& columns, SplitString(columns[1], '-', &date_parts); if (date_parts.size() != 3) return false; - if (!StringToInt(date_parts[0], &time_exploded.day_of_month)) + if (!base::StringToInt(date_parts[0], &time_exploded.day_of_month)) return false; if (!net::FtpUtil::ThreeLetterMonthToNumber(date_parts[1], &time_exploded.month)) return false; - if (!StringToInt(date_parts[2], &time_exploded.year)) + if (!base::StringToInt(date_parts[2], &time_exploded.year)) return false; // Time can be in format HH:MM, HH:MM:SS, or HH:MM:SS.mm. Try to recognize the @@ -147,9 +148,9 @@ bool VmsDateListingToTime(const std::vector<string16>& columns, SplitString(time_column, ':', &time_parts); if (time_parts.size() != 2) return false; - if (!StringToInt(time_parts[0], &time_exploded.hour)) + if (!base::StringToInt(time_parts[0], &time_exploded.hour)) return false; - if (!StringToInt(time_parts[1], &time_exploded.minute)) + if (!base::StringToInt(time_parts[1], &time_exploded.minute)) return false; // We don't know the time zone of the server, so just use local time. diff --git a/net/ftp/ftp_directory_listing_parser_windows.cc b/net/ftp/ftp_directory_listing_parser_windows.cc index 890ffc5..08131539 100644 --- a/net/ftp/ftp_directory_listing_parser_windows.cc +++ b/net/ftp/ftp_directory_listing_parser_windows.cc @@ -6,6 +6,7 @@ #include <vector> +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "net/ftp/ftp_util.h" @@ -22,11 +23,11 @@ bool WindowsDateListingToTime(const std::vector<string16>& columns, SplitString(columns[0], '-', &date_parts); if (date_parts.size() != 3) return false; - if (!StringToInt(date_parts[0], &time_exploded.month)) + if (!base::StringToInt(date_parts[0], &time_exploded.month)) return false; - if (!StringToInt(date_parts[1], &time_exploded.day_of_month)) + if (!base::StringToInt(date_parts[1], &time_exploded.day_of_month)) return false; - if (!StringToInt(date_parts[2], &time_exploded.year)) + if (!base::StringToInt(date_parts[2], &time_exploded.year)) return false; if (time_exploded.year < 0) return false; @@ -44,9 +45,9 @@ bool WindowsDateListingToTime(const std::vector<string16>& columns, SplitString(columns[1].substr(0, 5), ':', &time_parts); if (time_parts.size() != 2) return false; - if (!StringToInt(time_parts[0], &time_exploded.hour)) + if (!base::StringToInt(time_parts[0], &time_exploded.hour)) return false; - if (!StringToInt(time_parts[1], &time_exploded.minute)) + if (!base::StringToInt(time_parts[1], &time_exploded.minute)) return false; if (!time_exploded.HasValidValues()) return false; @@ -91,7 +92,7 @@ bool FtpDirectoryListingParserWindows::ConsumeLine(const string16& line) { entry.size = -1; } else { entry.type = FtpDirectoryListingEntry::FILE; - if (!StringToInt64(columns[2], &entry.size)) + if (!base::StringToInt64(columns[2], &entry.size)) return false; if (entry.size < 0) return false; diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index 85cac4b..f4de8ab 100644 --- a/net/ftp/ftp_network_transaction.cc +++ b/net/ftp/ftp_network_transaction.cc @@ -6,6 +6,7 @@ #include "base/compiler_specific.h" #include "base/histogram.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "net/base/connection_type_histograms.h" @@ -978,7 +979,7 @@ int FtpNetworkTransaction::ProcessResponseSIZE( if (response.lines.size() != 1) return Stop(ERR_INVALID_RESPONSE); int64 size; - if (!StringToInt64(response.lines[0], &size)) + if (!base::StringToInt64(response.lines[0], &size)) return Stop(ERR_INVALID_RESPONSE); if (size < 0) return Stop(ERR_INVALID_RESPONSE); diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc index 79e6b71..269a063 100644 --- a/net/ftp/ftp_util.cc +++ b/net/ftp/ftp_util.cc @@ -7,6 +7,7 @@ #include <vector> #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_tokenizer.h" #include "base/string_util.h" #include "base/time.h" @@ -155,18 +156,18 @@ bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day, if (!ThreeLetterMonthToNumber(month, &time_exploded.month)) return false; - if (!StringToInt(day, &time_exploded.day_of_month)) + if (!base::StringToInt(day, &time_exploded.day_of_month)) return false; - if (!StringToInt(rest, &time_exploded.year)) { + if (!base::StringToInt(rest, &time_exploded.year)) { // Maybe it's time. Does it look like time (MM:HH)? if (rest.length() != 5 || rest[2] != ':') return false; - if (!StringToInt(rest.substr(0, 2), &time_exploded.hour)) + if (!base::StringToInt(rest.substr(0, 2), &time_exploded.hour)) return false; - if (!StringToInt(rest.substr(3, 2), &time_exploded.minute)) + if (!base::StringToInt(rest.substr(3, 2), &time_exploded.minute)) return false; // Guess the year. |