network_quality_estimator_util.h 1.6 KB

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