OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_NQE_NETWORK_QUALITY_H_ | 5 #ifndef NET_NQE_NETWORK_QUALITY_H_ |
6 #define NET_NQE_NETWORK_QUALITY_H_ | 6 #define NET_NQE_NETWORK_QUALITY_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | |
17 namespace nqe { | 16 namespace nqe { |
18 | |
19 namespace internal { | 17 namespace internal { |
20 | 18 |
21 // Returns the RTT value to be used when the valid RTT is unavailable. Readers | 19 // Returns the RTT value to be used when the valid RTT is unavailable. Readers |
22 // should discard RTT if it is set to the value returned by |InvalidRTT()|. | 20 // should discard RTT if it is set to the value returned by |InvalidRTT()|. |
23 NET_EXPORT_PRIVATE base::TimeDelta InvalidRTT(); | 21 NET_EXPORT_PRIVATE base::TimeDelta InvalidRTT(); |
24 | 22 |
25 // Throughput is set to |kInvalidThroughput| if a valid value is | 23 // Throughput is set to |kInvalidThroughput| if a valid value is |
26 // unavailable. Readers should discard throughput value if it is set to | 24 // unavailable. Readers should discard throughput value if it is set to |
27 // |kInvalidThroughput|. | 25 // |kInvalidThroughput|. |
28 const int32_t kInvalidThroughput = 0; | 26 const int32_t kInvalidThroughput = 0; |
29 | 27 |
30 // NetworkQuality is used to cache the quality of a network connection. | 28 // NetworkQuality is used to cache the quality of a network connection. |
31 class NET_EXPORT_PRIVATE NetworkQuality { | 29 class NET_EXPORT_PRIVATE NetworkQuality { |
32 public: | 30 public: |
33 NetworkQuality(); | 31 NetworkQuality(); |
34 // |http_rtt| is the estimate of the round trip time at the HTTP layer. | 32 // |http_rtt| is the estimate of the round trip time at the HTTP layer. |
35 // |transport_rtt| is the estimate of the round trip time at the transport | 33 // |transport_rtt| is the estimate of the round trip time at the transport |
36 // layer. |downstream_throughput_kbps| is the estimate of the downstream | 34 // layer. |downstream_throughput_kbps| is the estimate of the downstream |
37 // throughput in kilobits per second. | 35 // throughput in kilobits per second. |
38 NetworkQuality(const base::TimeDelta& http_rtt, | 36 NetworkQuality(const base::TimeDelta& http_rtt, |
39 const base::TimeDelta& transport_rtt, | 37 const base::TimeDelta& transport_rtt, |
40 int32_t downstream_throughput_kbps); | 38 int32_t downstream_throughput_kbps); |
41 NetworkQuality(const NetworkQuality& other); | 39 NetworkQuality(const NetworkQuality& other); |
42 ~NetworkQuality(); | 40 ~NetworkQuality(); |
43 | 41 |
44 NetworkQuality& operator=(const NetworkQuality& other); | 42 NetworkQuality& operator=(const NetworkQuality& other); |
45 | 43 |
| 44 bool operator==(const NetworkQuality& other) const; |
| 45 |
46 // Returns the estimate of the round trip time at the HTTP layer. | 46 // Returns the estimate of the round trip time at the HTTP layer. |
47 const base::TimeDelta& http_rtt() const { return http_rtt_; } | 47 const base::TimeDelta& http_rtt() const { return http_rtt_; } |
48 | 48 |
49 void set_http_rtt(const base::TimeDelta& http_rtt) { http_rtt_ = http_rtt; } | 49 void set_http_rtt(const base::TimeDelta& http_rtt) { http_rtt_ = http_rtt; } |
50 | 50 |
51 // Returns the estimate of the round trip time at the transport layer. | 51 // Returns the estimate of the round trip time at the transport layer. |
52 const base::TimeDelta& transport_rtt() const { return transport_rtt_; } | 52 const base::TimeDelta& transport_rtt() const { return transport_rtt_; } |
53 | 53 |
54 void set_transport_rtt(const base::TimeDelta& transport_rtt) { | 54 void set_transport_rtt(const base::TimeDelta& transport_rtt) { |
55 transport_rtt_ = transport_rtt; | 55 transport_rtt_ = transport_rtt; |
(...skipping 14 matching lines...) Expand all Loading... |
70 base::TimeDelta http_rtt_; | 70 base::TimeDelta http_rtt_; |
71 | 71 |
72 // Estimated round trip time at the transport layer. | 72 // Estimated round trip time at the transport layer. |
73 base::TimeDelta transport_rtt_; | 73 base::TimeDelta transport_rtt_; |
74 | 74 |
75 // Estimated downstream throughput in kilobits per second. | 75 // Estimated downstream throughput in kilobits per second. |
76 int32_t downstream_throughput_kbps_; | 76 int32_t downstream_throughput_kbps_; |
77 }; | 77 }; |
78 | 78 |
79 } // namespace internal | 79 } // namespace internal |
80 | |
81 } // namespace nqe | 80 } // namespace nqe |
82 | |
83 } // namespace net | 81 } // namespace net |
84 | 82 |
85 #endif // NET_NQE_NETWORK_QUALITY_H_ | 83 #endif // NET_NQE_NETWORK_QUALITY_H_ |
OLD | NEW |