 Chromium Code Reviews
 Chromium Code Reviews Issue 2893933004:
  Throughput: Change the min number of requests in flight required  (Closed)
    
  
    Issue 2893933004:
  Throughput: Change the min number of requests in flight required  (Closed) 
  | Index: net/nqe/throughput_analyzer.cc | 
| diff --git a/net/nqe/throughput_analyzer.cc b/net/nqe/throughput_analyzer.cc | 
| index 6785d1438053a2b79f5f2a2f2917ac21c8686796..8d4c58f8a00719c87a20562847eaf63a3894843f 100644 | 
| --- a/net/nqe/throughput_analyzer.cc | 
| +++ b/net/nqe/throughput_analyzer.cc | 
| @@ -10,6 +10,7 @@ | 
| #include "base/single_thread_task_runner.h" | 
| #include "net/base/network_activity_monitor.h" | 
| #include "net/base/url_util.h" | 
| +#include "net/nqe/network_quality_estimator_params.h" | 
| #include "net/url_request/url_request.h" | 
| #if defined(OS_ANDROID) | 
| @@ -35,11 +36,13 @@ namespace nqe { | 
| namespace internal { | 
| ThroughputAnalyzer::ThroughputAnalyzer( | 
| + const NetworkQualityEstimatorParams* params, | 
| scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 
| ThroughputObservationCallback throughput_observation_callback, | 
| bool use_local_host_requests_for_tests, | 
| bool use_smaller_responses_for_tests) | 
| - : task_runner_(task_runner), | 
| + : params_(params), | 
| 
RyanSturm
2017/05/22 19:45:04
Do you plan to use this for other metrics? If not,
 
tbansal1
2017/05/22 19:58:01
Yes, I am going to do it for other metrics too.
 
RyanSturm
2017/05/22 20:14:40
Acknowledged.
 | 
| + task_runner_(task_runner), | 
| throughput_observation_callback_(throughput_observation_callback), | 
| last_connection_change_(base::TimeTicks::Now()), | 
| window_start_time_(base::TimeTicks()), | 
| @@ -47,6 +50,7 @@ ThroughputAnalyzer::ThroughputAnalyzer( | 
| disable_throughput_measurements_(false), | 
| use_localhost_requests_for_tests_(use_local_host_requests_for_tests), | 
| use_small_responses_for_tests_(use_smaller_responses_for_tests) { | 
| + DCHECK(params_); | 
| DCHECK(task_runner_); | 
| DCHECK(!IsCurrentlyTrackingThroughput()); | 
| } | 
| @@ -66,7 +70,8 @@ void ThroughputAnalyzer::MaybeStartThroughputObservationWindow() { | 
| // started, and there is at least one active request that does not degrade | 
| // throughput computation accuracy. | 
| if (accuracy_degrading_requests_.size() > 0 || | 
| - IsCurrentlyTrackingThroughput() || requests_.size() <= 0) { | 
| + IsCurrentlyTrackingThroughput() || | 
| + requests_.size() < params_->throughput_min_requests_in_flight()) { | 
| return; | 
| } | 
| window_start_time_ = base::TimeTicks::Now(); | 
| @@ -96,6 +101,8 @@ bool ThroughputAnalyzer::IsCurrentlyTrackingThroughput() const { | 
| // requests should be currently active. | 
| DCHECK_EQ(0U, accuracy_degrading_requests_.size()); | 
| + DCHECK_LE(params_->throughput_min_requests_in_flight(), requests_.size()); | 
| + | 
| return true; | 
| } | 
| @@ -164,7 +171,7 @@ void ThroughputAnalyzer::NotifyRequestCompleted(const URLRequest& request) { | 
| if (requests_.erase(&request) == 1u) { | 
| // If there is no network activity, stop tracking throughput to prevent | 
| // recording of any observations. | 
| - if (requests_.size() == 0) | 
| + if (requests_.size() < params_->throughput_min_requests_in_flight()) | 
| EndThroughputObservationWindow(); | 
| return; | 
| } |