Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: net/nqe/throughput_analyzer.h

Issue 2893933004: Throughput: Change the min number of requests in flight required (Closed)
Patch Set: ryansturm comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/nqe/network_quality_estimator_params.cc ('k') | net/nqe/throughput_analyzer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 } 24 }
25 25
26 namespace net { 26 namespace net {
27 27
28 class URLRequest; 28 class URLRequest;
29 29
30 namespace nqe { 30 namespace nqe {
31 31
32 namespace internal { 32 namespace internal {
33 33
34 class NetworkQualityEstimatorParams;
35
34 // Makes throughput observations. Polls NetworkActivityMonitor 36 // Makes throughput observations. Polls NetworkActivityMonitor
35 // (TrafficStats on Android) to count number of bits received over throughput 37 // (TrafficStats on Android) to count number of bits received over throughput
36 // observation windows in accordance with the following rules: 38 // observation windows in accordance with the following rules:
37 // (1) A new window of observation begins any time a URL request header is 39 // (1) A new window of observation begins any time a URL request header is
38 // about to be sent, or a request completes or is destroyed. 40 // about to be sent, or a request completes or is destroyed.
39 // (2) A request is "active" if its headers are sent, but it hasn't completed, 41 // (2) A request is "active" if its headers are sent, but it hasn't completed,
40 // and "local" if destined to local host. If at any time during a 42 // and "local" if destined to local host. If at any time during a
41 // throughput observation window there is an active, local request, the 43 // throughput observation window there is an active, local request, the
42 // window is discarded. 44 // window is discarded.
43 // (3) If less than 32KB is received over the network during a window of 45 // (3) If less than 32KB is received over the network during a window of
44 // observation, that window is discarded. 46 // observation, that window is discarded.
45 class NET_EXPORT_PRIVATE ThroughputAnalyzer { 47 class NET_EXPORT_PRIVATE ThroughputAnalyzer {
46 public: 48 public:
47 // |throughput_observation_callback| is called on the |task_runner| when 49 // |throughput_observation_callback| is called on the |task_runner| when
48 // |this| has a new throughput observation. 50 // |this| has a new throughput observation.
49 // |use_local_host_requests_for_tests| should only be true when testing 51 // |use_local_host_requests_for_tests| should only be true when testing
50 // against local HTTP server and allows the requests to local host to be 52 // against local HTTP server and allows the requests to local host to be
51 // used for network quality estimation. |use_smaller_responses_for_tests| 53 // used for network quality estimation. |use_smaller_responses_for_tests|
52 // should only be true when testing, and allows the responses smaller than 54 // should only be true when testing, and allows the responses smaller than
53 // |kMinTransferSizeInBits| or shorter than 55 // |kMinTransferSizeInBits| or shorter than
54 // |kMinRequestDurationMicroseconds| to be used for network quality 56 // |kMinRequestDurationMicroseconds| to be used for network quality
55 // estimation. 57 // estimation.
56 // Virtualized for testing. 58 // Virtualized for testing.
57 ThroughputAnalyzer( 59 ThroughputAnalyzer(
60 const NetworkQualityEstimatorParams* params,
58 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 61 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
59 ThroughputObservationCallback throughput_observation_callback, 62 ThroughputObservationCallback throughput_observation_callback,
60 bool use_local_host_requests_for_tests, 63 bool use_local_host_requests_for_tests,
61 bool use_smaller_responses_for_tests); 64 bool use_smaller_responses_for_tests);
62 virtual ~ThroughputAnalyzer(); 65 virtual ~ThroughputAnalyzer();
63 66
64 // Notifies |this| that the headers of |request| are about to be sent. 67 // Notifies |this| that the headers of |request| are about to be sent.
65 void NotifyStartTransaction(const URLRequest& request); 68 void NotifyStartTransaction(const URLRequest& request);
66 69
67 // Notifies |this| that |request| has completed. 70 // Notifies |this| that |request| has completed.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 102
100 typedef base::hash_set<const URLRequest*> Requests; 103 typedef base::hash_set<const URLRequest*> Requests;
101 104
102 // Returns true if downstream throughput can be recorded. In that case, 105 // Returns true if downstream throughput can be recorded. In that case,
103 // |downstream_kbps| is set to the computed downstream throughput (in 106 // |downstream_kbps| is set to the computed downstream throughput (in
104 // kilobits per second). If a downstream throughput observation is taken, 107 // kilobits per second). If a downstream throughput observation is taken,
105 // then the throughput observation window is reset so as to continue 108 // then the throughput observation window is reset so as to continue
106 // tracking throughput. A throughput observation can be taken only if the 109 // tracking throughput. A throughput observation can be taken only if the
107 // time-window is currently active, and enough bytes have accumulated in 110 // time-window is currently active, and enough bytes have accumulated in
108 // that window. |downstream_kbps| should not be null. 111 // that window. |downstream_kbps| should not be null.
109 bool MayBeGetThroughputObservation(int32_t* downstream_kbps); 112 bool MaybeGetThroughputObservation(int32_t* downstream_kbps);
110 113
111 // Starts the throughput observation window that keeps track of network 114 // Starts the throughput observation window that keeps track of network
112 // bytes if the following conditions are true: 115 // bytes if the following conditions are true:
113 // (i) All active requests are non-local; 116 // (i) All active requests are non-local;
114 // (ii) There is at least one active, non-local request; and, 117 // (ii) There is at least one active, non-local request; and,
115 // (iii) The throughput observation window is not already tracking 118 // (iii) The throughput observation window is not already tracking
116 // throughput. The window is started by setting the |start_| and 119 // throughput. The window is started by setting the |start_| and
117 // |bits_received_|. 120 // |bits_received_|.
118 void MaybeStartThroughputObservationWindow(); 121 void MaybeStartThroughputObservationWindow();
119 122
120 // EndThroughputObservationWindow ends the throughput observation window. 123 // EndThroughputObservationWindow ends the throughput observation window.
121 void EndThroughputObservationWindow(); 124 void EndThroughputObservationWindow();
122 125
123 // Returns true if throughput is currently tracked by a throughput 126 // Returns true if throughput is currently tracked by a throughput
124 // observation window. 127 // observation window.
125 bool IsCurrentlyTrackingThroughput() const; 128 bool IsCurrentlyTrackingThroughput() const;
126 129
127 // Returns true if the |request| degrades the accuracy of the throughput 130 // Returns true if the |request| degrades the accuracy of the throughput
128 // observation window. A local request or a request that spans a connection 131 // observation window. A local request or a request that spans a connection
129 // change degrades the accuracy of the throughput computation. 132 // change degrades the accuracy of the throughput computation.
130 bool DegradesAccuracy(const URLRequest& request) const; 133 bool DegradesAccuracy(const URLRequest& request) const;
131 134
132 // Bounds |accuracy_degrading_requests_| and |requests_| to ensure their sizes 135 // Bounds |accuracy_degrading_requests_| and |requests_| to ensure their sizes
133 // do not exceed their capacities. 136 // do not exceed their capacities.
134 void BoundRequestsSize(); 137 void BoundRequestsSize();
135 138
139 const NetworkQualityEstimatorParams* params_;
136 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 140 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
137 141
138 // Called every time a new throughput observation is available. 142 // Called every time a new throughput observation is available.
139 ThroughputObservationCallback throughput_observation_callback_; 143 ThroughputObservationCallback throughput_observation_callback_;
140 144
141 // Time when last connection change was observed. 145 // Time when last connection change was observed.
142 base::TimeTicks last_connection_change_; 146 base::TimeTicks last_connection_change_;
143 147
144 // Start time of the current throughput observation window. Set to null if 148 // Start time of the current throughput observation window. Set to null if
145 // the window is not currently active. 149 // the window is not currently active.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 DISALLOW_COPY_AND_ASSIGN(ThroughputAnalyzer); 182 DISALLOW_COPY_AND_ASSIGN(ThroughputAnalyzer);
179 }; 183 };
180 184
181 } // namespace internal 185 } // namespace internal
182 186
183 } // namespace nqe 187 } // namespace nqe
184 188
185 } // namespace net 189 } // namespace net
186 190
187 #endif // NET_NQE_THROUGHPUT_ANALYZER_H_ 191 #endif // NET_NQE_THROUGHPUT_ANALYZER_H_
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator_params.cc ('k') | net/nqe/throughput_analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698