Chromium Code Reviews| 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_local_host_requests_for_tests| should only be true when testing | |
| 74 // against local HTTP server and allows the requests to local host to be | |
| 75 // used for network quality estimation. | |
| 76 void SetUseLocalHostRequestsForTesting( | |
| 77 bool use_local_host_requests_for_tests); | |
|
mef
2016/06/24 20:10:37
nit: drop '_for_tests' for consistency.
tbansal1
2016/06/24 22:41:39
Done.
| |
| 78 | |
| 79 // |use_smaller_responses_for_tests| should only be true when testing, and | |
| 80 // allows the responses smaller than |kMinTransferSizeInBits| or shorter than | |
| 81 // |kMinRequestDurationMicroseconds| to be used for network quality | |
| 82 // estimation. | |
| 83 void SetUseSmallResponsesForTesting(bool use_small_responses); | |
| 84 | |
| 73 protected: | 85 protected: |
| 74 // Exposed for testing. | 86 // Exposed for testing. |
| 75 bool disable_throughput_measurements() const { | 87 bool disable_throughput_measurements() const { |
| 76 return disable_throughput_measurements_; | 88 return disable_throughput_measurements_; |
| 77 } | 89 } |
| 78 | 90 |
| 79 // Returns the number of bits received by Chromium so far. The count may not | 91 // 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 | 92 // 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 | 93 // call. The count is obtained by polling TrafficStats on Android, and |
| 82 // net::NetworkActivityMonitor on all other platforms. Virtualized for | 94 // net::NetworkActivityMonitor on all other platforms. Virtualized for |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 Requests requests_; | 160 Requests requests_; |
| 149 | 161 |
| 150 // If true, then |this| throughput analyzer stops tracking the throughput | 162 // If true, then |this| throughput analyzer stops tracking the throughput |
| 151 // observations until Chromium is restarted. This may happen if the throughput | 163 // observations until Chromium is restarted. This may happen if the throughput |
| 152 // analyzer has lost track of the requests that degrade throughput computation | 164 // analyzer has lost track of the requests that degrade throughput computation |
| 153 // accuracy. | 165 // accuracy. |
| 154 bool disable_throughput_measurements_; | 166 bool disable_throughput_measurements_; |
| 155 | 167 |
| 156 // Determines if the requests to local host can be used in estimating the | 168 // Determines if the requests to local host can be used in estimating the |
| 157 // network quality. Set to true only for tests. | 169 // network quality. Set to true only for tests. |
| 158 const bool use_localhost_requests_for_tests_; | 170 bool use_localhost_requests_for_tests_; |
| 159 | 171 |
| 160 // Determines if the responses smaller than |kMinTransferSizeInBits| | 172 // Determines if the responses smaller than |kMinTransferSizeInBits| |
| 161 // or shorter than |kMinTransferSizeInBits| can be used in estimating the | 173 // or shorter than |kMinTransferSizeInBits| can be used in estimating the |
| 162 // network quality. Set to true only for tests. | 174 // network quality. Set to true only for tests. |
| 163 const bool use_small_responses_for_tests_; | 175 bool use_small_responses_for_tests_; |
| 164 | 176 |
| 165 base::ThreadChecker thread_checker_; | 177 base::ThreadChecker thread_checker_; |
| 166 | 178 |
| 167 DISALLOW_COPY_AND_ASSIGN(ThroughputAnalyzer); | 179 DISALLOW_COPY_AND_ASSIGN(ThroughputAnalyzer); |
| 168 }; | 180 }; |
| 169 | 181 |
| 170 } // namespace internal | 182 } // namespace internal |
| 171 | 183 |
| 172 } // namespace nqe | 184 } // namespace nqe |
| 173 | 185 |
| 174 } // namespace net | 186 } // namespace net |
| 175 | 187 |
| 176 #endif // NET_NQE_THROUGHPUT_ANALYZER_H_ | 188 #endif // NET_NQE_THROUGHPUT_ANALYZER_H_ |
| OLD | NEW |