| OLD | NEW |
| 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_hosts.h" | 5 #include "net/dns/dns_hosts.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return false; | 151 return false; |
| 152 | 152 |
| 153 UMA_HISTOGRAM_COUNTS("AsyncDNS.HostsSize", size); | 153 UMA_HISTOGRAM_COUNTS("AsyncDNS.HostsSize", size); |
| 154 | 154 |
| 155 // Reject HOSTS files larger than |kMaxHostsSize| bytes. | 155 // Reject HOSTS files larger than |kMaxHostsSize| bytes. |
| 156 const int64 kMaxHostsSize = 1 << 25; // 32MB | 156 const int64 kMaxHostsSize = 1 << 25; // 32MB |
| 157 if (size > kMaxHostsSize) | 157 if (size > kMaxHostsSize) |
| 158 return false; | 158 return false; |
| 159 | 159 |
| 160 std::string contents; | 160 std::string contents; |
| 161 if (!file_util::ReadFileToString(path, &contents)) | 161 if (!base::ReadFileToString(path, &contents)) |
| 162 return false; | 162 return false; |
| 163 | 163 |
| 164 ParseHosts(contents, dns_hosts); | 164 ParseHosts(contents, dns_hosts); |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace net | 168 } // namespace net |
| 169 | 169 |
| OLD | NEW |