Chromium Code Reviews| Index: net/nqe/network_quality.h |
| diff --git a/net/nqe/network_quality.h b/net/nqe/network_quality.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a962be516a5493dbc999767db0ac70253ceb47c8 |
| --- /dev/null |
| +++ b/net/nqe/network_quality.h |
| @@ -0,0 +1,93 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef NET_NQE_NETWORK_QUALITY_H_ |
| +#define NET_NQE_NETWORK_QUALITY_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include <string> |
| + |
| +#include "base/gtest_prod_util.h" |
| +#include "base/macros.h" |
| +#include "base/time/time.h" |
| +#include "net/base/net_export.h" |
| + |
| +namespace net { |
| + |
| +namespace nqe { |
| + |
| +namespace internal { |
| + |
| +// Returns the RTT value to be used when the valid RTT is unavailable. Readers |
| +// should discard RTT if it is set to the value returned by |InvalidRTT()|. |
| +NET_EXPORT_PRIVATE base::TimeDelta InvalidRTT(); |
| + |
| +// Throughput is set to |kInvalidThroughput| if a valid value is |
| +// unavailable. Readers should discard throughput value if it is set to |
| +// |kInvalidThroughput|. |
| +const int32_t kInvalidThroughput = 0; |
|
bengr
2016/05/03 21:59:45
Why doesn't have a corresponding method? E.g., Inv
tbansal1
2016/05/04 22:07:24
Method was required for RTT because there can't be
|
| + |
| +// NetworkQuality is used to cache the quality of a network connection. |
| +class NET_EXPORT_PRIVATE NetworkQuality { |
| + public: |
| + NetworkQuality(); |
| + // |rtt| is the estimate of the round trip time. |
| + // |downstream_throughput_kbps| is the estimate of the downstream |
| + // throughput in kilobits per second. |
| + NetworkQuality(const base::TimeDelta& rtt, |
| + int32_t downstream_throughput_kbps); |
|
bengr
2016/05/03 21:59:45
You use int32_t and int64_t in different parts of
tbansal1
2016/05/04 22:07:24
I do not see int64_t anywhere in this CL.
It migh
|
| + NetworkQuality(const NetworkQuality& other); |
| + ~NetworkQuality(); |
| + |
| + NetworkQuality& operator=(const NetworkQuality& other); |
| + |
| + // Returns the estimate of the round trip time. |
| + const base::TimeDelta& rtt() const { return rtt_; } |
|
bengr
2016/05/03 21:59:45
Which RTT is this?
tbansal1
2016/05/04 22:07:24
Fixed. NetworkQuality structure needs to be expand
|
| + |
| + // Returns the estimate of the downstream throughput in Kbps (Kilobits per |
| + // second). |
| + int32_t downstream_throughput_kbps() const { |
| + return downstream_throughput_kbps_; |
| + } |
| + |
| + private: |
| + // Estimated round trip time. |
|
bengr
2016/05/03 21:59:45
Again, which RTT?
tbansal1
2016/05/04 22:07:24
Done.
|
| + base::TimeDelta rtt_; |
| + |
| + // Estimated downstream throughput in kilobits per second. |
| + int32_t downstream_throughput_kbps_; |
| +}; |
| + |
| +// CachedNetworkQuality stores the quality of a previously seen network. |
| +class NET_EXPORT_PRIVATE CachedNetworkQuality { |
| + public: |
| + explicit CachedNetworkQuality(const NetworkQuality& network_quality); |
| + CachedNetworkQuality(const CachedNetworkQuality& other); |
| + ~CachedNetworkQuality(); |
| + |
| + // Returns the network quality associated with this cached entry. |
| + const NetworkQuality& network_quality() const { return network_quality_; } |
| + |
| + // Returns true if this cache entry was updated before |
| + // |cached_network_quality|. |
| + bool OlderThan(const CachedNetworkQuality& cached_network_quality) const; |
| + |
| + // Time when this cache entry was last updated. |
| + const base::TimeTicks last_update_time_; |
| + |
| + // Quality of this cached network. |
| + const NetworkQuality network_quality_; |
| + |
| + private: |
| + DISALLOW_ASSIGN(CachedNetworkQuality); |
| +}; |
| + |
| +} // namespace internal |
| + |
| +} // namespace nqe |
| + |
| +} // namespace net |
| + |
| +#endif // NET_NQE_NETWORK_QUALITY_H_ |