Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: net/proxy/proxy_bypass_rules.cc

Issue 8984007: Revert 114929 - Standardize StringToInt{,64} interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_response_headers.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/proxy/proxy_bypass_rules.h" 5 #include "net/proxy/proxy_bypass_rules.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_piece.h"
11 #include "base/string_tokenizer.h" 10 #include "base/string_tokenizer.h"
12 #include "base/string_util.h" 11 #include "base/string_util.h"
13 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
14 13
15 namespace net { 14 namespace net {
16 15
17 namespace { 16 namespace {
18 17
19 class HostnamePatternRule : public ProxyBypassRules::Rule { 18 class HostnamePatternRule : public ProxyBypassRules::Rule {
20 public: 19 public:
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 GURL tmp_url("http://" + host); 308 GURL tmp_url("http://" + host);
310 return AddRuleForHostname(scheme, tmp_url.host(), port); 309 return AddRuleForHostname(scheme, tmp_url.host(), port);
311 } 310 }
312 } 311 }
313 312
314 // Otherwise assume we have <hostname-pattern>[:port]. 313 // Otherwise assume we have <hostname-pattern>[:port].
315 std::string::size_type pos_colon = raw.rfind(':'); 314 std::string::size_type pos_colon = raw.rfind(':');
316 host = raw; 315 host = raw;
317 port = -1; 316 port = -1;
318 if (pos_colon != std::string::npos) { 317 if (pos_colon != std::string::npos) {
319 if (!base::StringToInt(base::StringPiece(raw.begin() + pos_colon + 1, 318 if (!base::StringToInt(raw.begin() + pos_colon + 1, raw.end(), &port) ||
320 raw.end()),
321 &port) ||
322 (port < 0 || port > 0xFFFF)) { 319 (port < 0 || port > 0xFFFF)) {
323 return false; // Port was invalid. 320 return false; // Port was invalid.
324 } 321 }
325 raw = raw.substr(0, pos_colon); 322 raw = raw.substr(0, pos_colon);
326 } 323 }
327 324
328 // Special-case hostnames that begin with a period. 325 // Special-case hostnames that begin with a period.
329 // For example, we remap ".google.com" --> "*.google.com". 326 // For example, we remap ".google.com" --> "*.google.com".
330 if (StartsWithASCII(raw, ".", false)) 327 if (StartsWithASCII(raw, ".", false))
331 raw = "*" + raw; 328 raw = "*" + raw;
332 329
333 // If suffix matching was asked for, make sure the pattern starts with a 330 // If suffix matching was asked for, make sure the pattern starts with a
334 // wildcard. 331 // wildcard.
335 if (use_hostname_suffix_matching && !StartsWithASCII(raw, "*", false)) 332 if (use_hostname_suffix_matching && !StartsWithASCII(raw, "*", false))
336 raw = "*" + raw; 333 raw = "*" + raw;
337 334
338 return AddRuleForHostname(scheme, raw, port); 335 return AddRuleForHostname(scheme, raw, port);
339 } 336 }
340 337
341 bool ProxyBypassRules::AddRuleFromStringInternalWithLogging( 338 bool ProxyBypassRules::AddRuleFromStringInternalWithLogging(
342 const std::string& raw, 339 const std::string& raw,
343 bool use_hostname_suffix_matching) { 340 bool use_hostname_suffix_matching) {
344 return AddRuleFromStringInternal(raw, use_hostname_suffix_matching); 341 return AddRuleFromStringInternal(raw, use_hostname_suffix_matching);
345 } 342 }
346 343
347 } // namespace net 344 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_response_headers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698