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

Unified Diff: net/dns/dns_config_service_win.cc

Issue 1215933004: New new versions of Starts/EndsWith and SplitString in net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@starts_with
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: net/dns/dns_config_service_win.cc
diff --git a/net/dns/dns_config_service_win.cc b/net/dns/dns_config_service_win.cc
index bef4b475f74ff4b72b4448525bed7df22445840f..23206d4d6f997294a5a0c6beb1445abf2227466c 100644
--- a/net/dns/dns_config_service_win.cc
+++ b/net/dns/dns_config_service_win.cc
@@ -134,14 +134,14 @@ scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> ReadIpHelper(ULONG flags) {
// Converts a base::string16 domain name to ASCII, possibly using punycode.
// Returns true if the conversion succeeds and output is not empty. In case of
// failure, |domain| might become dirty.
-bool ParseDomainASCII(const base::string16& widestr, std::string* domain) {
+bool ParseDomainASCII(base::StringPiece16 widestr, std::string* domain) {
DCHECK(domain);
if (widestr.empty())
return false;
// Check if already ASCII.
if (base::IsStringASCII(widestr)) {
- *domain = base::UTF16ToASCII(widestr);
+ domain->assign(widestr.begin(), widestr.end());
return true;
}
@@ -476,12 +476,10 @@ bool ParseSearchList(const base::string16& value,
// Although nslookup and network connection property tab ignore such
// fragments ("a,b,,c" becomes ["a", "b", "c"]), our reference is getaddrinfo
// (which sees ["a", "b"]). WMI queries also return a matching search list.
- std::vector<base::string16> woutput;
- base::SplitString(value, ',', &woutput);
- for (size_t i = 0; i < woutput.size(); ++i) {
+ for (const base::StringPiece16& t : base::SplitStringPiece(
+ value, L",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
Ryan Sleevi 2015/07/06 08:52:02 CONSISTENCY PEDANTRY NIT: Elsewhere, you use base:
brettw 2015/07/06 16:52:34 This is pretty common in Windows files, at least i
// Convert non-ASCII to punycode, although getaddrinfo does not properly
// handle such suffixes.
- const base::string16& t = woutput[i];
std::string parsed;
if (!ParseDomainASCII(t, &parsed))
break;

Powered by Google App Engine
This is Rietveld 408576698