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

Unified Diff: net/nqe/throughput_analyzer.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/nqe/throughput_analyzer.h ('k') | net/nqe/throughput_analyzer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/nqe/throughput_analyzer.cc
diff --git a/net/nqe/throughput_analyzer.cc b/net/nqe/throughput_analyzer.cc
index 6785d1438053a2b79f5f2a2f2917ac21c8686796..de1b0efacc574381e543eee71733c1268b583d39 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),
+ 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;
}
@@ -141,7 +148,7 @@ void ThroughputAnalyzer::NotifyRequestCompleted(const URLRequest& request) {
}
int32_t downstream_kbps;
- if (MayBeGetThroughputObservation(&downstream_kbps)) {
+ if (MaybeGetThroughputObservation(&downstream_kbps)) {
// Notify the provided callback.
task_runner_->PostTask(
FROM_HERE,
@@ -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;
}
@@ -172,7 +179,7 @@ void ThroughputAnalyzer::NotifyRequestCompleted(const URLRequest& request) {
NOTREACHED();
}
-bool ThroughputAnalyzer::MayBeGetThroughputObservation(
+bool ThroughputAnalyzer::MaybeGetThroughputObservation(
int32_t* downstream_kbps) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(downstream_kbps);
« no previous file with comments | « net/nqe/throughput_analyzer.h ('k') | net/nqe/throughput_analyzer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698