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

Side by Side Diff: net/dns/dns_config_service_win.cc

Issue 196793010: Move IsStringASCII/UTF8 to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/base/net_util_win.cc ('k') | net/ftp/ftp_network_transaction.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/dns/dns_config_service_win.h" 5 #include "net/dns/dns_config_service_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 // Converts a base::string16 domain name to ASCII, possibly using punycode. 133 // Converts a base::string16 domain name to ASCII, possibly using punycode.
134 // Returns true if the conversion succeeds and output is not empty. In case of 134 // Returns true if the conversion succeeds and output is not empty. In case of
135 // failure, |domain| might become dirty. 135 // failure, |domain| might become dirty.
136 bool ParseDomainASCII(const base::string16& widestr, std::string* domain) { 136 bool ParseDomainASCII(const base::string16& widestr, std::string* domain) {
137 DCHECK(domain); 137 DCHECK(domain);
138 if (widestr.empty()) 138 if (widestr.empty())
139 return false; 139 return false;
140 140
141 // Check if already ASCII. 141 // Check if already ASCII.
142 if (IsStringASCII(widestr)) { 142 if (base::IsStringASCII(widestr)) {
143 *domain = base::UTF16ToASCII(widestr); 143 *domain = base::UTF16ToASCII(widestr);
144 return true; 144 return true;
145 } 145 }
146 146
147 // Otherwise try to convert it from IDN to punycode. 147 // Otherwise try to convert it from IDN to punycode.
148 const int kInitialBufferSize = 256; 148 const int kInitialBufferSize = 256;
149 url_canon::RawCanonOutputT<base::char16, kInitialBufferSize> punycode; 149 url_canon::RawCanonOutputT<base::char16, kInitialBufferSize> punycode;
150 if (!url_canon::IDNToASCII(widestr.data(), widestr.length(), &punycode)) 150 if (!url_canon::IDNToASCII(widestr.data(), widestr.length(), &punycode))
151 return false; 151 return false;
152 152
153 // |punycode_output| should now be ASCII; convert it to a std::string. 153 // |punycode_output| should now be ASCII; convert it to a std::string.
154 // (We could use UTF16ToASCII() instead, but that requires an extra string 154 // (We could use UTF16ToASCII() instead, but that requires an extra string
155 // copy. Since ASCII is a subset of UTF8 the following is equivalent). 155 // copy. Since ASCII is a subset of UTF8 the following is equivalent).
156 bool success = base::UTF16ToUTF8(punycode.data(), punycode.length(), domain); 156 bool success = base::UTF16ToUTF8(punycode.data(), punycode.length(), domain);
157 DCHECK(success); 157 DCHECK(success);
158 DCHECK(IsStringASCII(*domain)); 158 DCHECK(base::IsStringASCII(*domain));
159 return success && !domain->empty(); 159 return success && !domain->empty();
160 } 160 }
161 161
162 bool ReadDevolutionSetting(const RegistryReader& reader, 162 bool ReadDevolutionSetting(const RegistryReader& reader,
163 DnsSystemSettings::DevolutionSetting* setting) { 163 DnsSystemSettings::DevolutionSetting* setting) {
164 return reader.ReadDword(L"UseDomainNameDevolution", &setting->enabled) && 164 return reader.ReadDword(L"UseDomainNameDevolution", &setting->enabled) &&
165 reader.ReadDword(L"DomainNameDevolutionLevel", &setting->level); 165 reader.ReadDword(L"DomainNameDevolutionLevel", &setting->level);
166 } 166 }
167 167
168 // Reads DnsSystemSettings from IpHelper and registry. 168 // Reads DnsSystemSettings from IpHelper and registry.
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 } 758 }
759 759
760 } // namespace internal 760 } // namespace internal
761 761
762 // static 762 // static
763 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { 763 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() {
764 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServiceWin()); 764 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServiceWin());
765 } 765 }
766 766
767 } // namespace net 767 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util_win.cc ('k') | net/ftp/ftp_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698