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_THROUGHPUT_ANALYZER_H_ | 5 #ifndef NET_NQE_THROUGHPUT_ANALYZER_H_ |
6 #define NET_NQE_THROUGHPUT_ANALYZER_H_ | 6 #define NET_NQE_THROUGHPUT_ANALYZER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // Notifies |this| that the headers of |request| are about to be sent. | 64 // Notifies |this| that the headers of |request| are about to be sent. |
65 void NotifyStartTransaction(const URLRequest& request); | 65 void NotifyStartTransaction(const URLRequest& request); |
66 | 66 |
67 // Notifies |this| that |request| has completed. | 67 // Notifies |this| that |request| has completed. |
68 void NotifyRequestCompleted(const URLRequest& request); | 68 void NotifyRequestCompleted(const URLRequest& request); |
69 | 69 |
70 // Notifies |this| of a change in connection type. | 70 // Notifies |this| of a change in connection type. |
71 void OnConnectionTypeChanged(); | 71 void OnConnectionTypeChanged(); |
72 | 72 |
| 73 // |use_localhost_requests| should only be true when testing against local |
| 74 // HTTP server and allows the requests to local host to be used for network |
| 75 // quality estimation. |
| 76 void SetUseLocalHostRequestsForTesting(bool use_localhost_requests); |
| 77 |
| 78 // |use_smaller_responses_for_tests| should only be true when testing, and |
| 79 // allows the responses smaller than |kMinTransferSizeInBits| or shorter than |
| 80 // |kMinRequestDurationMicroseconds| to be used for network quality |
| 81 // estimation. |
| 82 void SetUseSmallResponsesForTesting(bool use_small_responses); |
| 83 |
73 protected: | 84 protected: |
74 // Exposed for testing. | 85 // Exposed for testing. |
75 bool disable_throughput_measurements() const { | 86 bool disable_throughput_measurements() const { |
76 return disable_throughput_measurements_; | 87 return disable_throughput_measurements_; |
77 } | 88 } |
78 | 89 |
79 // Returns the number of bits received by Chromium so far. The count may not | 90 // Returns the number of bits received by Chromium so far. The count may not |
80 // start from zero, so the caller should only look at difference from a prior | 91 // start from zero, so the caller should only look at difference from a prior |
81 // call. The count is obtained by polling TrafficStats on Android, and | 92 // call. The count is obtained by polling TrafficStats on Android, and |
82 // net::NetworkActivityMonitor on all other platforms. Virtualized for | 93 // net::NetworkActivityMonitor on all other platforms. Virtualized for |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 Requests requests_; | 159 Requests requests_; |
149 | 160 |
150 // If true, then |this| throughput analyzer stops tracking the throughput | 161 // If true, then |this| throughput analyzer stops tracking the throughput |
151 // observations until Chromium is restarted. This may happen if the throughput | 162 // observations until Chromium is restarted. This may happen if the throughput |
152 // analyzer has lost track of the requests that degrade throughput computation | 163 // analyzer has lost track of the requests that degrade throughput computation |
153 // accuracy. | 164 // accuracy. |
154 bool disable_throughput_measurements_; | 165 bool disable_throughput_measurements_; |
155 | 166 |
156 // Determines if the requests to local host can be used in estimating the | 167 // Determines if the requests to local host can be used in estimating the |
157 // network quality. Set to true only for tests. | 168 // network quality. Set to true only for tests. |
158 const bool use_localhost_requests_for_tests_; | 169 bool use_localhost_requests_for_tests_; |
159 | 170 |
160 // Determines if the responses smaller than |kMinTransferSizeInBits| | 171 // Determines if the responses smaller than |kMinTransferSizeInBits| |
161 // or shorter than |kMinTransferSizeInBits| can be used in estimating the | 172 // or shorter than |kMinTransferSizeInBits| can be used in estimating the |
162 // network quality. Set to true only for tests. | 173 // network quality. Set to true only for tests. |
163 const bool use_small_responses_for_tests_; | 174 bool use_small_responses_for_tests_; |
164 | 175 |
165 base::ThreadChecker thread_checker_; | 176 base::ThreadChecker thread_checker_; |
166 | 177 |
167 DISALLOW_COPY_AND_ASSIGN(ThroughputAnalyzer); | 178 DISALLOW_COPY_AND_ASSIGN(ThroughputAnalyzer); |
168 }; | 179 }; |
169 | 180 |
170 } // namespace internal | 181 } // namespace internal |
171 | 182 |
172 } // namespace nqe | 183 } // namespace nqe |
173 | 184 |
174 } // namespace net | 185 } // namespace net |
175 | 186 |
176 #endif // NET_NQE_THROUGHPUT_ANALYZER_H_ | 187 #endif // NET_NQE_THROUGHPUT_ANALYZER_H_ |
OLD | NEW |