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

Unified Diff: net/dns/dns_hosts.cc

Issue 9721002: [net/dns] Removes locking from DnsConfigServiceWin and adds local computer name. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move lowercasing to ServeFromHosts, add test. Reorganize OnHostsRead. Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/dns_hosts.h ('k') | net/dns/dns_hosts_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_hosts.cc
diff --git a/net/dns/dns_hosts.cc b/net/dns/dns_hosts.cc
index bd469121762c9e4bbab76f4b1cc014e71ddf6c6c..bfd216cc5b15291f1c4cb783407ed50d5238d532 100644
--- a/net/dns/dns_hosts.cc
+++ b/net/dns/dns_hosts.cc
@@ -7,6 +7,7 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/string_tokenizer.h"
+#include "base/string_util.h"
namespace net {
@@ -34,7 +35,9 @@ void ParseHosts(const std::string& contents, DnsHosts* dns_hosts) {
AddressFamily fam = (ip.size() == 4) ? ADDRESS_FAMILY_IPV4 :
ADDRESS_FAMILY_IPV6;
while (tokens.GetNext()) {
- IPAddressNumber& mapped_ip = hosts[DnsHostsKey(tokens.token(), fam)];
+ DnsHostsKey key(tokens.token(), fam);
+ StringToLowerASCII(&(key.first));
+ IPAddressNumber& mapped_ip = hosts[key];
if (mapped_ip.empty())
mapped_ip = ip;
// else ignore this entry (first hit counts)
@@ -52,6 +55,11 @@ DnsHostsReader::DnsHostsReader(const FilePath& path,
DCHECK(!callback.is_null());
}
+DnsHostsReader::DnsHostsReader(const FilePath& path)
+ : path_(path),
+ success_(false) {
+}
+
// Reads the contents of the file at |path| into |str| if the total length is
// less than |max_size|.
static bool ReadFile(const FilePath& path, int64 max_size, std::string* str) {
« no previous file with comments | « net/dns/dns_hosts.h ('k') | net/dns/dns_hosts_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698