cached_network_quality.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2016 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_CACHED_NETWORK_QUALITY_H_
  5. #define NET_NQE_CACHED_NETWORK_QUALITY_H_
  6. #include "base/time/time.h"
  7. #include "net/base/net_export.h"
  8. #include "net/nqe/effective_connection_type.h"
  9. #include "net/nqe/network_quality.h"
  10. namespace net::nqe::internal {
  11. // CachedNetworkQuality stores the quality of a previously seen network.
  12. class NET_EXPORT_PRIVATE CachedNetworkQuality {
  13. public:
  14. CachedNetworkQuality();
  15. explicit CachedNetworkQuality(
  16. EffectiveConnectionType effective_connection_type);
  17. // |last_update_time| is the time when the |network_quality| was computed.
  18. CachedNetworkQuality(base::TimeTicks last_update_time,
  19. const NetworkQuality& network_quality,
  20. EffectiveConnectionType effective_connection_type);
  21. CachedNetworkQuality(const CachedNetworkQuality& other);
  22. ~CachedNetworkQuality();
  23. // Returns the network quality associated with this cached entry.
  24. const NetworkQuality& network_quality() const { return network_quality_; }
  25. CachedNetworkQuality& operator=(const CachedNetworkQuality& other);
  26. // Returns true if this cache entry was updated before
  27. // |cached_network_quality|.
  28. bool OlderThan(const CachedNetworkQuality& cached_network_quality) const;
  29. base::TimeTicks last_update_time() { return last_update_time_; }
  30. EffectiveConnectionType effective_connection_type() const {
  31. return effective_connection_type_;
  32. }
  33. private:
  34. // Time when this cache entry was last updated.
  35. base::TimeTicks last_update_time_;
  36. // Quality of this cached network.
  37. NetworkQuality network_quality_;
  38. // Effective connection type of the cached network.
  39. EffectiveConnectionType effective_connection_type_;
  40. };
  41. } // namespace net::nqe::internal
  42. #endif // NET_NQE_CACHED_NETWORK_QUALITY_H_