Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_util.h" | 5 #include "net/dns/dns_util.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <limits.h> | 8 #include <limits.h> |
| 9 | 9 |
| 10 #include <cstring> | 10 #include <cstring> |
| 11 | 11 |
| 12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "net/base/address_list.h" | |
| 16 | 17 |
| 17 #if defined(OS_POSIX) | 18 #if defined(OS_POSIX) |
| 18 #include <netinet/in.h> | 19 #include <netinet/in.h> |
| 19 #if !defined(OS_NACL) | 20 #if !defined(OS_NACL) |
| 20 #include <net/if.h> | 21 #include <net/if.h> |
| 21 #if !defined(OS_ANDROID) | 22 #if !defined(OS_ANDROID) |
| 22 #include <ifaddrs.h> | 23 #include <ifaddrs.h> |
| 23 #endif // !defined(OS_ANDROID) | 24 #endif // !defined(OS_ANDROID) |
| 24 #endif // !defined(OS_NACL) | 25 #endif // !defined(OS_NACL) |
| 25 #endif // defined(OS_POSIX) | 26 #endif // defined(OS_POSIX) |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 const char* field_trial, | 186 const char* field_trial, |
| 186 base::TimeDelta default_delta, | 187 base::TimeDelta default_delta, |
| 187 NetworkChangeNotifier::ConnectionType type) { | 188 NetworkChangeNotifier::ConnectionType type) { |
| 188 base::TimeDelta out; | 189 base::TimeDelta out; |
| 189 if (!GetTimeDeltaForConnectionTypeFromFieldTrial(field_trial, type, &out)) | 190 if (!GetTimeDeltaForConnectionTypeFromFieldTrial(field_trial, type, &out)) |
| 190 out = default_delta; | 191 out = default_delta; |
| 191 return out; | 192 return out; |
| 192 } | 193 } |
| 193 #endif // !defined(OS_NACL) | 194 #endif // !defined(OS_NACL) |
| 194 | 195 |
| 196 AddressListDeltaType FindAddressListDeltaType(const AddressList& a, | |
|
Randy Smith (Not in Mondays)
2016/04/28 16:24:16
This is only used in host_cache.cc; any reason not
Julia Tuttle
2016/04/29 17:33:51
Yeah, it's used in a follow-on CL.
| |
| 197 const AddressList& b) { | |
| 198 bool pairwise_mismatch = false; | |
| 199 bool any_match = false; | |
| 200 bool any_missing = false; | |
| 201 bool same_size = a.size() == b.size(); | |
| 202 | |
| 203 for (size_t i = 0; i < a.size(); ++i) { | |
| 204 bool this_match = false; | |
| 205 for (size_t j = 0; j < b.size(); ++j) { | |
| 206 if (a[i] == b[j]) { | |
| 207 any_match = true; | |
| 208 this_match = true; | |
| 209 } else if (i == j) { | |
| 210 pairwise_mismatch = true; | |
| 211 } | |
| 212 } | |
| 213 if (!this_match) | |
| 214 any_missing = true; | |
| 215 } | |
| 216 | |
| 217 if (same_size && !pairwise_mismatch) | |
| 218 return DELTA_IDENTICAL; | |
| 219 else if (same_size && !any_missing) | |
| 220 return DELTA_REORDERED; | |
| 221 else if (any_match) | |
| 222 return DELTA_OVERLAP; | |
| 223 else | |
| 224 return DELTA_DISJOINT; | |
| 225 } | |
| 226 | |
| 195 } // namespace net | 227 } // namespace net |
| OLD | NEW |