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/host_cache.h" | 5 #include "net/dns/host_cache.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 auto addresses_value = base::MakeUnique<base::ListValue>(); | 335 auto addresses_value = base::MakeUnique<base::ListValue>(); |
336 for (size_t i = 0; i < addresses.size(); ++i) | 336 for (size_t i = 0; i < addresses.size(); ++i) |
337 addresses_value->AppendString(addresses[i].ToStringWithoutPort()); | 337 addresses_value->AppendString(addresses[i].ToStringWithoutPort()); |
338 entry_dict->SetList(kAddressesKey, std::move(addresses_value)); | 338 entry_dict->SetList(kAddressesKey, std::move(addresses_value)); |
339 } | 339 } |
340 | 340 |
341 entry_list->Append(std::move(entry_dict)); | 341 entry_list->Append(std::move(entry_dict)); |
342 } | 342 } |
343 } | 343 } |
344 | 344 |
345 // TODO(mgersh): Add histograms to track failures. | |
346 bool HostCache::RestoreFromListValue(const base::ListValue& old_cache) { | 345 bool HostCache::RestoreFromListValue(const base::ListValue& old_cache) { |
347 for (auto it = old_cache.begin(); it != old_cache.end(); it++) { | 346 for (auto it = old_cache.begin(); it != old_cache.end(); it++) { |
348 const base::DictionaryValue* entry_dict; | 347 const base::DictionaryValue* entry_dict; |
349 if (!it->GetAsDictionary(&entry_dict)) | 348 if (!it->GetAsDictionary(&entry_dict)) |
350 return false; | 349 return false; |
351 | 350 |
352 std::string hostname; | 351 std::string hostname; |
353 int address_family; | 352 int address_family; |
354 HostResolverFlags flags; | 353 HostResolverFlags flags; |
355 int error = OK; | 354 int error = OK; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 CACHE_HISTOGRAM_TIME("EraseValid.ValidFor", -stale.expired_by); | 535 CACHE_HISTOGRAM_TIME("EraseValid.ValidFor", -stale.expired_by); |
537 } | 536 } |
538 } | 537 } |
539 | 538 |
540 void HostCache::RecordEraseAll(EraseReason reason, base::TimeTicks now) { | 539 void HostCache::RecordEraseAll(EraseReason reason, base::TimeTicks now) { |
541 for (const auto& it : entries_) | 540 for (const auto& it : entries_) |
542 RecordErase(reason, now, it.second); | 541 RecordErase(reason, now, it.second); |
543 } | 542 } |
544 | 543 |
545 } // namespace net | 544 } // namespace net |
OLD | NEW |