| 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 #ifndef NET_DNS_DNS_UTIL_H_ | 5 #ifndef NET_DNS_DNS_UTIL_H_ |
| 6 #define NET_DNS_DNS_UTIL_H_ | 6 #define NET_DNS_DNS_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 #include "net/base/network_change_notifier.h" | 13 #include "net/base/network_change_notifier.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 class AddressList; |
| 18 |
| 17 // DNSDomainFromDot - convert a domain string to DNS format. From DJB's | 19 // DNSDomainFromDot - convert a domain string to DNS format. From DJB's |
| 18 // public domain DNS library. | 20 // public domain DNS library. |
| 19 // | 21 // |
| 20 // dotted: a string in dotted form: "www.google.com" | 22 // dotted: a string in dotted form: "www.google.com" |
| 21 // out: a result in DNS form: "\x03www\x06google\x03com\x00" | 23 // out: a result in DNS form: "\x03www\x06google\x03com\x00" |
| 22 NET_EXPORT_PRIVATE bool DNSDomainFromDot(const base::StringPiece& dotted, | 24 NET_EXPORT_PRIVATE bool DNSDomainFromDot(const base::StringPiece& dotted, |
| 23 std::string* out); | 25 std::string* out); |
| 24 | 26 |
| 25 // DNSDomainToString converts a domain in DNS format to a dotted string. | 27 // DNSDomainToString converts a domain in DNS format to a dotted string. |
| 26 // Excludes the dot at the end. | 28 // Excludes the dot at the end. |
| 27 NET_EXPORT_PRIVATE std::string DNSDomainToString( | 29 NET_EXPORT_PRIVATE std::string DNSDomainToString( |
| 28 const base::StringPiece& domain); | 30 const base::StringPiece& domain); |
| 29 | 31 |
| 30 // Returns true if it can determine that only loopback addresses are configured. | 32 // Returns true if it can determine that only loopback addresses are configured. |
| 31 // i.e. if only 127.0.0.1 and ::1 are routable. | 33 // i.e. if only 127.0.0.1 and ::1 are routable. |
| 32 // Also returns false if it cannot determine this. | 34 // Also returns false if it cannot determine this. |
| 33 NET_EXPORT_PRIVATE bool HaveOnlyLoopbackAddresses(); | 35 NET_EXPORT_PRIVATE bool HaveOnlyLoopbackAddresses(); |
| 34 | 36 |
| 35 #if !defined(OS_NACL) | 37 #if !defined(OS_NACL) |
| 36 NET_EXPORT_PRIVATE | 38 NET_EXPORT_PRIVATE |
| 37 base::TimeDelta GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault( | 39 base::TimeDelta GetTimeDeltaForConnectionTypeFromFieldTrialOrDefault( |
| 38 const char* field_trial_name, | 40 const char* field_trial_name, |
| 39 base::TimeDelta default_delta, | 41 base::TimeDelta default_delta, |
| 40 NetworkChangeNotifier::ConnectionType connection_type); | 42 NetworkChangeNotifier::ConnectionType connection_type); |
| 41 #endif // !defined(OS_NACL) | 43 #endif // !defined(OS_NACL) |
| 42 | 44 |
| 45 // How similar or different two AddressLists are (see values for details). |
| 46 // Used in histograms; do not modify existing values. |
| 47 enum AddressListDeltaType { |
| 48 // Both lists contain the same addresses in the same order. |
| 49 DELTA_IDENTICAL = 0, |
| 50 // Both lists contain the same addresses in a different order. |
| 51 DELTA_REORDERED = 1, |
| 52 // The two lists have at least one address in common, but not all of them. |
| 53 DELTA_OVERLAP = 2, |
| 54 // The two lists have no addresses in common. |
| 55 DELTA_DISJOINT = 3, |
| 56 MAX_DELTA_TYPE |
| 57 }; |
| 58 |
| 59 // Compares two AddressLists to see how similar or different their addresses |
| 60 // are. (See |AddressListDeltaType| for details of exactly what's checked.) |
| 61 AddressListDeltaType FindAddressListDeltaType(const AddressList& a, |
| 62 const AddressList& b); |
| 63 |
| 43 } // namespace net | 64 } // namespace net |
| 44 | 65 |
| 45 #endif // NET_DNS_DNS_UTIL_H_ | 66 #endif // NET_DNS_DNS_UTIL_H_ |
| OLD | NEW |