summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorerikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-22 16:05:47 +0000
committererikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-22 16:05:47 +0000
commitc2750c67ca3a672018bac2dfb07628d079aafc8d (patch)
tree8bbff1c4c3aeb363e06734e91e172653e34737cc /net
parent213b99ad9d66e3c039bbb90c19d78603975c1be9 (diff)
downloadchromium_src-c2750c67ca3a672018bac2dfb07628d079aafc8d.zip
chromium_src-c2750c67ca3a672018bac2dfb07628d079aafc8d.tar.gz
chromium_src-c2750c67ca3a672018bac2dfb07628d079aafc8d.tar.bz2
Update code that previously constructed strings from string iterators only to use StringToInt. These usages now pass the iterators directly to the new StringToInt overloads.
BUG=None TEST=All Review URL: http://codereview.chromium.org/3968001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63515 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/net_util.cc7
-rw-r--r--net/base/transport_security_state.cc4
-rw-r--r--net/base/x509_certificate_openssl.cc18
-rw-r--r--net/ftp/ftp_ctrl_response_buffer.cc2
-rw-r--r--net/ftp/ftp_directory_listing_parser_mlsd.cc18
-rw-r--r--net/ftp/ftp_util.cc16
-rw-r--r--net/http/http_chunked_decoder.cc2
-rw-r--r--net/http/http_response_headers.cc24
-rw-r--r--net/proxy/proxy_bypass_rules.cc2
9 files changed, 60 insertions, 33 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 45dc60c..8f6b2af 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -1676,10 +1676,11 @@ void SetExplicitlyAllowedPorts(const std::string& allowed_ports) {
(allowed_ports[i] != kComma))
return;
if (i == size || allowed_ports[i] == kComma) {
- size_t length = i - last;
- if (length > 0) {
+ if (i > last) {
int port;
- base::StringToInt(allowed_ports.substr(last, length), &port);
+ base::StringToInt(allowed_ports.begin() + last,
+ allowed_ports.begin() + i,
+ &port);
ports.insert(port);
}
last = i + 1;
diff --git a/net/base/transport_security_state.cc b/net/base/transport_security_state.cc
index a0d2794..dc87c10 100644
--- a/net/base/transport_security_state.cc
+++ b/net/base/transport_security_state.cc
@@ -142,7 +142,9 @@ bool TransportSecurityState::ParseHeader(const std::string& value,
case AFTER_MAX_AGE_EQUALS:
if (IsAsciiWhitespace(*tokenizer.token_begin()))
continue;
- if (!base::StringToInt(tokenizer.token(), &max_age_candidate))
+ if (!base::StringToInt(tokenizer.token_begin(),
+ tokenizer.token_end(),
+ &max_age_candidate))
return false;
if (max_age_candidate < 0)
return false;
diff --git a/net/base/x509_certificate_openssl.cc b/net/base/x509_certificate_openssl.cc
index 52d1b31..444b5d4 100644
--- a/net/base/x509_certificate_openssl.cc
+++ b/net/base/x509_certificate_openssl.cc
@@ -128,20 +128,26 @@ void ParseDate(ASN1_TIME* x509_time, base::Time* time) {
return;
base::Time::Exploded exploded = {0};
- bool valid = base::StringToInt(str_date.substr(0, year_length),
+ bool valid = base::StringToInt(str_date.begin(),
+ str_date.begin() + year_length,
&exploded.year);
if (valid && year_length == 2)
exploded.year += exploded.year < 50 ? 2000 : 1900;
- valid &= base::StringToInt(str_date.substr(2 + fields_offset, 2),
+ valid &= base::StringToInt(str_date.begin() + fields_offset + 2,
+ str_date.begin() + fields_offset + 4,
&exploded.month);
- valid &= base::StringToInt(str_date.substr(4 + fields_offset, 2),
+ valid &= base::StringToInt(str_date.begin() + fields_offset + 4,
+ str_date.begin() + fields_offset + 6),
&exploded.day_of_month);
- valid &= base::StringToInt(str_date.substr(6 + fields_offset, 2),
+ valid &= base::StringToInt(str_date.begin() + fields_offset + 6,
+ str_date.begin() + fields_offset + 8),
&exploded.hour);
- valid &= base::StringToInt(str_date.substr(8 + fields_offset, 2),
+ valid &= base::StringToInt(str_date.begin() + fields_offset + 8,
+ str_date.begin() + fields_offset + 10),
&exploded.minute);
- valid &= base::StringToInt(str_date.substr(10 + fields_offset, 2),
+ valid &= base::StringToInt(str_date.begin() + fields_offset + 10,
+ str_date.begin() + fields_offset + 12,
&exploded.second);
DCHECK(valid);
diff --git a/net/ftp/ftp_ctrl_response_buffer.cc b/net/ftp/ftp_ctrl_response_buffer.cc
index 950e1e0..4aeef1f 100644
--- a/net/ftp/ftp_ctrl_response_buffer.cc
+++ b/net/ftp/ftp_ctrl_response_buffer.cc
@@ -91,7 +91,7 @@ FtpCtrlResponseBuffer::ParsedLine FtpCtrlResponseBuffer::ParseLine(
ParsedLine result;
if (line.length() >= 3) {
- if (base::StringToInt(line.substr(0, 3), &result.status_code))
+ if (base::StringToInt(line.begin(), line.begin() + 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_parser_mlsd.cc b/net/ftp/ftp_directory_listing_parser_mlsd.cc
index fa9a44e..d8ae618 100644
--- a/net/ftp/ftp_directory_listing_parser_mlsd.cc
+++ b/net/ftp/ftp_directory_listing_parser_mlsd.cc
@@ -28,15 +28,23 @@ bool MlsdDateListingToTime(const string16& text, base::Time* time) {
if (text.length() < 14)
return false;
- if (!base::StringToInt(text.substr(0, 4), &time_exploded.year))
+ if (!base::StringToInt(text.begin(), text.begin() + 4, &time_exploded.year))
return false;
- if (!base::StringToInt(text.substr(4, 2), &time_exploded.month))
+ if (!base::StringToInt(text.begin() + 4,
+ text.begin() + 6,
+ &time_exploded.month))
return false;
- if (!base::StringToInt(text.substr(6, 2), &time_exploded.day_of_month))
+ if (!base::StringToInt(text.begin() + 6,
+ text.begin() + 8,
+ &time_exploded.day_of_month))
return false;
- if (!base::StringToInt(text.substr(8, 2), &time_exploded.hour))
+ if (!base::StringToInt(text.begin() + 8,
+ text.begin() + 10,
+ &time_exploded.hour))
return false;
- if (!base::StringToInt(text.substr(10, 2), &time_exploded.minute))
+ if (!base::StringToInt(text.begin() + 10,
+ text.begin() + 12,
+ &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_util.cc b/net/ftp/ftp_util.cc
index aeb2355..2633e9d 100644
--- a/net/ftp/ftp_util.cc
+++ b/net/ftp/ftp_util.cc
@@ -162,17 +162,25 @@ bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day,
if (!base::StringToInt(rest, &time_exploded.year)) {
// Maybe it's time. Does it look like time (HH:MM)?
if (rest.length() == 5 && rest[2] == ':') {
- if (!base::StringToInt(rest.substr(0, 2), &time_exploded.hour))
+ if (!base::StringToInt(rest.begin(),
+ rest.begin() + 2,
+ &time_exploded.hour))
return false;
- if (!base::StringToInt(rest.substr(3, 2), &time_exploded.minute))
+ if (!base::StringToInt(rest.begin() + 3,
+ rest.begin() + 5,
+ &time_exploded.minute))
return false;
} else if (rest.length() == 4 && rest[1] == ':') {
// Sometimes it's just H:MM.
- if (!base::StringToInt(rest.substr(0, 1), &time_exploded.hour))
+ if (!base::StringToInt(rest.begin(),
+ rest.begin() + 1,
+ &time_exploded.hour))
return false;
- if (!base::StringToInt(rest.substr(2, 2), &time_exploded.minute))
+ if (!base::StringToInt(rest.begin() + 2,
+ rest.begin() + 4,
+ &time_exploded.minute))
return false;
} else {
return false;
diff --git a/net/http/http_chunked_decoder.cc b/net/http/http_chunked_decoder.cc
index 455c9ed..d5b16dd 100644
--- a/net/http/http_chunked_decoder.cc
+++ b/net/http/http_chunked_decoder.cc
@@ -192,7 +192,7 @@ bool HttpChunkedDecoder::ParseChunkSize(const char* start, int len, int* out) {
return false;
int parsed_number;
- bool ok = base::HexStringToInt(std::string(start, len), &parsed_number);
+ bool ok = base::HexStringToInt(start, start + len, &parsed_number);
if (ok && parsed_number >= 0) {
*out = parsed_number;
return true;
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc
index 99c5404..7376fa0 100644
--- a/net/http/http_response_headers.cc
+++ b/net/http/http_response_headers.cc
@@ -598,7 +598,7 @@ void HttpResponseHeaders::ParseStatusLine(
raw_headers_.push_back(' ');
raw_headers_.append(code, p);
raw_headers_.push_back(' ');
- base::StringToInt(std::string(code, p), &response_code_);
+ base::StringToInt(code, p, &response_code_);
// Skip whitespace.
while (*p == ' ')
@@ -973,7 +973,9 @@ bool HttpResponseHeaders::GetMaxAgeValue(TimeDelta* result) const {
value.begin() + kMaxAgePrefixLen,
kMaxAgePrefix)) {
int64 seconds;
- base::StringToInt64(value.substr(kMaxAgePrefixLen), &seconds);
+ base::StringToInt64(value.begin() + kMaxAgePrefixLen,
+ value.end(),
+ &seconds);
*result = TimeDelta::FromSeconds(seconds);
return true;
}
@@ -1148,9 +1150,9 @@ bool HttpResponseHeaders::GetContentRange(int64* first_byte_position,
byte_range_resp_spec.begin() + minus_position;
HttpUtil::TrimLWS(&first_byte_pos_begin, &first_byte_pos_end);
- bool ok = base::StringToInt64(
- std::string(first_byte_pos_begin, first_byte_pos_end),
- first_byte_position);
+ bool ok = base::StringToInt64(first_byte_pos_begin,
+ first_byte_pos_end,
+ first_byte_position);
// Obtain last-byte-pos.
std::string::const_iterator last_byte_pos_begin =
@@ -1159,9 +1161,9 @@ bool HttpResponseHeaders::GetContentRange(int64* first_byte_position,
byte_range_resp_spec.end();
HttpUtil::TrimLWS(&last_byte_pos_begin, &last_byte_pos_end);
- ok &= base::StringToInt64(
- std::string(last_byte_pos_begin, last_byte_pos_end),
- last_byte_position);
+ ok &= base::StringToInt64(last_byte_pos_begin,
+ last_byte_pos_end,
+ last_byte_position);
if (!ok) {
*first_byte_position = *last_byte_position = -1;
return false;
@@ -1184,9 +1186,9 @@ bool HttpResponseHeaders::GetContentRange(int64* first_byte_position,
if (LowerCaseEqualsASCII(instance_length_begin, instance_length_end, "*")) {
return false;
- } else if (!base::StringToInt64(
- std::string(instance_length_begin, instance_length_end),
- instance_length)) {
+ } else if (!base::StringToInt64(instance_length_begin,
+ instance_length_end,
+ instance_length)) {
*instance_length = -1;
return false;
}
diff --git a/net/proxy/proxy_bypass_rules.cc b/net/proxy/proxy_bypass_rules.cc
index 757d817..67b147a 100644
--- a/net/proxy/proxy_bypass_rules.cc
+++ b/net/proxy/proxy_bypass_rules.cc
@@ -264,7 +264,7 @@ bool ProxyBypassRules::AddRuleFromStringInternal(
host = raw;
port = -1;
if (pos_colon != std::string::npos) {
- if (!base::StringToInt(raw.substr(pos_colon + 1), &port) ||
+ if (!base::StringToInt(raw.begin() + pos_colon + 1, raw.end(), &port) ||
(port < 0 || port > 0xFFFF)) {
return false; // Port was invalid.
}