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

Unified Diff: net/dns/dns_util.cc

Issue 1908543002: DNS: Retain stale entries in HostCache and return when requested (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, make all members of Entry private Created 4 years, 7 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_util.h ('k') | net/dns/host_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_util.cc
diff --git a/net/dns/dns_util.cc b/net/dns/dns_util.cc
index 5f10ad2365ff07be8ea85172bcb96497bb4fc46f..48be035c0e3380d37f5aa0d29e3406760b97db6d 100644
--- a/net/dns/dns_util.cc
+++ b/net/dns/dns_util.cc
@@ -13,6 +13,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "build/build_config.h"
+#include "net/base/address_list.h"
#if defined(OS_POSIX)
#include <netinet/in.h>
@@ -192,4 +193,35 @@ base::TimeDelta GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault(
}
#endif // !defined(OS_NACL)
+AddressListDeltaType FindAddressListDeltaType(const AddressList& a,
+ const AddressList& b) {
+ bool pairwise_mismatch = false;
+ bool any_match = false;
+ bool any_missing = false;
+ bool same_size = a.size() == b.size();
+
+ for (size_t i = 0; i < a.size(); ++i) {
+ bool this_match = false;
+ for (size_t j = 0; j < b.size(); ++j) {
+ if (a[i] == b[j]) {
+ any_match = true;
+ this_match = true;
+ } else if (i == j) {
+ pairwise_mismatch = true;
+ }
+ }
+ if (!this_match)
+ any_missing = true;
+ }
+
+ if (same_size && !pairwise_mismatch)
+ return DELTA_IDENTICAL;
+ else if (same_size && !any_missing)
+ return DELTA_REORDERED;
+ else if (any_match)
+ return DELTA_OVERLAP;
+ else
+ return DELTA_DISJOINT;
+}
+
} // namespace net
« no previous file with comments | « net/dns/dns_util.h ('k') | net/dns/host_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698