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

Unified Diff: net/nqe/throughput_analyzer.cc

Issue 2936823002: NQE: Exclude network observations from private networks (Closed)
Patch Set: bengr comments, rebased Created 3 years, 6 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 de1b0efacc574381e543eee71733c1268b583d39..b38c1e78f5e23043994184d14ab0fbc4508ce1ef 100644
--- a/net/nqe/throughput_analyzer.cc
+++ b/net/nqe/throughput_analyzer.cc
@@ -8,10 +8,13 @@
#include "base/location.h"
#include "base/single_thread_task_runner.h"
+#include "net/base/host_port_pair.h"
#include "net/base/network_activity_monitor.h"
#include "net/base/url_util.h"
#include "net/nqe/network_quality_estimator_params.h"
+#include "net/nqe/network_quality_estimator_util.h"
#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_context.h"
#if defined(OS_ANDROID)
#include "net/android/traffic_stats.h"
@@ -19,6 +22,8 @@
namespace net {
+class HostResolver;
+
namespace {
// Maximum number of accuracy degrading requests, and requests that do not
@@ -40,7 +45,8 @@ ThroughputAnalyzer::ThroughputAnalyzer(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
ThroughputObservationCallback throughput_observation_callback,
bool use_local_host_requests_for_tests,
- bool use_smaller_responses_for_tests)
+ bool use_smaller_responses_for_tests,
+ const NetLogWithSource& net_log)
: params_(params),
task_runner_(task_runner),
throughput_observation_callback_(throughput_observation_callback),
@@ -49,7 +55,8 @@ ThroughputAnalyzer::ThroughputAnalyzer(
bits_received_at_window_start_(0),
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) {
+ use_small_responses_for_tests_(use_smaller_responses_for_tests),
+ net_log_(net_log) {
DCHECK(params_);
DCHECK(task_runner_);
DCHECK(!IsCurrentlyTrackingThroughput());
@@ -264,8 +271,12 @@ int64_t ThroughputAnalyzer::GetBitsReceived() const {
bool ThroughputAnalyzer::DegradesAccuracy(const URLRequest& request) const {
DCHECK(thread_checker_.CalledOnValidThread());
- return !(use_localhost_requests_for_tests_ ||
- !IsLocalhost(request.url().host())) ||
+ bool private_network_request = nqe::internal::IsPrivateHost(
+ request.context()->host_resolver(),
+ HostPortPair(request.url().host(), request.url().EffectiveIntPort()),
+ net_log_);
+
+ return !(use_localhost_requests_for_tests_ || !private_network_request) ||
request.creation_time() < last_connection_change_;
}
« 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