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

Side by Side Diff: net/base/net_util.cc

Issue 3054042: De-wstringify some browser startup code. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: net fix Created 10 years, 4 months 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
« no previous file with comments | « net/base/net_util.h ('k') | net/base/net_util_unittest.cc » ('j') | 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) 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/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <unicode/regex.h> 9 #include <unicode/regex.h>
10 #include <unicode/ucnv.h> 10 #include <unicode/ucnv.h>
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 DCHECK(url.is_valid()); 1631 DCHECK(url.is_valid());
1632 GURL::Replacements replacements; 1632 GURL::Replacements replacements;
1633 replacements.ClearUsername(); 1633 replacements.ClearUsername();
1634 replacements.ClearPassword(); 1634 replacements.ClearPassword();
1635 replacements.ClearRef(); 1635 replacements.ClearRef();
1636 return url.ReplaceComponents(replacements); 1636 return url.ReplaceComponents(replacements);
1637 } 1637 }
1638 1638
1639 // Specifies a comma separated list of port numbers that should be accepted 1639 // Specifies a comma separated list of port numbers that should be accepted
1640 // despite bans. If the string is invalid no allowed ports are stored. 1640 // despite bans. If the string is invalid no allowed ports are stored.
1641 void SetExplicitlyAllowedPorts(const std::wstring& allowed_ports) { 1641 void SetExplicitlyAllowedPorts(const std::string& allowed_ports) {
1642 if (allowed_ports.empty()) 1642 if (allowed_ports.empty())
1643 return; 1643 return;
1644 1644
1645 std::set<int> ports; 1645 std::set<int> ports;
1646 size_t last = 0; 1646 size_t last = 0;
1647 size_t size = allowed_ports.size(); 1647 size_t size = allowed_ports.size();
1648 // The comma delimiter. 1648 // The comma delimiter.
1649 const std::wstring::value_type kComma = L','; 1649 const std::string::value_type kComma = ',';
1650 1650
1651 // Overflow is still possible for evil user inputs. 1651 // Overflow is still possible for evil user inputs.
1652 for (size_t i = 0; i <= size; ++i) { 1652 for (size_t i = 0; i <= size; ++i) {
1653 // The string should be composed of only digits and commas. 1653 // The string should be composed of only digits and commas.
1654 if (i != size && !IsAsciiDigit(allowed_ports[i]) && 1654 if (i != size && !IsAsciiDigit(allowed_ports[i]) &&
1655 (allowed_ports[i] != kComma)) 1655 (allowed_ports[i] != kComma))
1656 return; 1656 return;
1657 if (i == size || allowed_ports[i] == kComma) { 1657 if (i == size || allowed_ports[i] == kComma) {
1658 size_t length = i - last; 1658 size_t length = i - last;
1659 if (length > 0) { 1659 if (length > 0) {
1660 int port; 1660 int port;
1661 base::StringToInt(WideToUTF8(allowed_ports.substr(last, length)), 1661 base::StringToInt(allowed_ports.substr(last, length), &port);
1662 &port);
1663 ports.insert(port); 1662 ports.insert(port);
1664 } 1663 }
1665 last = i + 1; 1664 last = i + 1;
1666 } 1665 }
1667 } 1666 }
1668 explicitly_allowed_ports = ports; 1667 explicitly_allowed_ports = ports;
1669 } 1668 }
1670 1669
1671 enum IPv6SupportStatus { 1670 enum IPv6SupportStatus {
1672 IPV6_CANNOT_CREATE_SOCKETS, 1671 IPV6_CANNOT_CREATE_SOCKETS,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 } 1960 }
1962 1961
1963 int GetPortFromAddrinfo(const struct addrinfo* info) { 1962 int GetPortFromAddrinfo(const struct addrinfo* info) {
1964 uint16* port_field = GetPortFieldFromAddrinfo(info); 1963 uint16* port_field = GetPortFieldFromAddrinfo(info);
1965 if (!port_field) 1964 if (!port_field)
1966 return -1; 1965 return -1;
1967 return ntohs(*port_field); 1966 return ntohs(*port_field);
1968 } 1967 }
1969 1968
1970 } // namespace net 1969 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698