1 // Copyright 2017 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_NQE_NETWORK_QUALITY_ESTIMATOR_UTIL_H_ 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_UTIL_H_ 7 8 #include <stdint.h> 9 10 #include "net/base/net_export.h" 11 #include "net/log/net_log_with_source.h" 12 13 namespace net { 14 15 class HostPortPair; 16 class HostResolver; 17 class NetworkAnonymizationKey; 18 class URLRequest; 19 20 namespace nqe::internal { 21 22 // A unified compact representation of an IPv6 or an IPv4 address. 23 typedef uint64_t IPHash; 24 25 // Returns true if the host contained of |request.url()| is a host in a 26 // private Internet as defined by RFC 1918 or if the requests to it are not 27 // expected to generate useful network quality information. This includes 28 // localhost, hosts on private subnets, and hosts on subnets that are reserved 29 // for specific usage, and are unlikely to be used by public web servers. 30 // 31 // To make this determination, this method makes the best effort estimate 32 // including trying to resolve the host from the HostResolver's cache. This 33 // method is synchronous. 34 NET_EXPORT_PRIVATE bool IsRequestForPrivateHost(const URLRequest& request, 35 NetLogWithSource net_log); 36 37 // Provides access to the method used internally by IsRequestForPrivateHost(), 38 // for testing. 39 NET_EXPORT_PRIVATE bool IsPrivateHostForTesting( 40 HostResolver* host_resolver, 41 const HostPortPair& host_port_pair, 42 const NetworkAnonymizationKey& network_anonymization_key); 43 44 } // namespace nqe::internal 45 46 } // namespace net 47 48 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_UTIL_H_ 49