OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "net/nqe/network_quality_estimator.h" | 5 #include "net/nqe/network_quality_estimator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <utility> | 10 #include <utility> |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 throughput_observer_list_.RemoveObserver(throughput_observer); | 615 throughput_observer_list_.RemoveObserver(throughput_observer); |
616 } | 616 } |
617 | 617 |
618 SocketPerformanceWatcherFactory* | 618 SocketPerformanceWatcherFactory* |
619 NetworkQualityEstimator::GetSocketPerformanceWatcherFactory() { | 619 NetworkQualityEstimator::GetSocketPerformanceWatcherFactory() { |
620 DCHECK(thread_checker_.CalledOnValidThread()); | 620 DCHECK(thread_checker_.CalledOnValidThread()); |
621 | 621 |
622 return watcher_factory_.get(); | 622 return watcher_factory_.get(); |
623 } | 623 } |
624 | 624 |
625 void NetworkQualityEstimator::SetUseLocalHostRequestsForTesting( | |
626 bool use_local_host_requests_for_tests) { | |
mef
2016/06/24 20:10:37
nit: use_local_host_requests_for_tests -> use_loca
tbansal1
2016/06/24 22:41:39
Done.
| |
627 DCHECK(thread_checker_.CalledOnValidThread()); | |
628 use_localhost_requests_ = use_local_host_requests_for_tests; | |
629 throughput_analyzer_->SetUseLocalHostRequestsForTesting( | |
630 use_localhost_requests_); | |
631 } | |
632 | |
633 void NetworkQualityEstimator::SetUseSmallResponsesForTesting( | |
634 bool use_small_responses) { | |
635 DCHECK(thread_checker_.CalledOnValidThread()); | |
636 use_small_responses_ = use_small_responses; | |
637 throughput_analyzer_->SetUseSmallResponsesForTesting(use_small_responses_); | |
638 } | |
639 | |
625 bool NetworkQualityEstimator::RequestProvidesRTTObservation( | 640 bool NetworkQualityEstimator::RequestProvidesRTTObservation( |
626 const URLRequest& request) const { | 641 const URLRequest& request) const { |
627 DCHECK(thread_checker_.CalledOnValidThread()); | 642 DCHECK(thread_checker_.CalledOnValidThread()); |
628 | 643 |
629 return (use_localhost_requests_ || !IsLocalhost(request.url().host())) && | 644 return (use_localhost_requests_ || !IsLocalhost(request.url().host())) && |
630 // Verify that response headers are received, so it can be ensured that | 645 // Verify that response headers are received, so it can be ensured that |
631 // response is not cached. | 646 // response is not cached. |
632 !request.response_info().response_time.is_null() && | 647 !request.response_info().response_time.is_null() && |
633 !request.was_cached() && | 648 !request.was_cached() && |
634 request.creation_time() >= last_connection_change_; | 649 request.creation_time() >= last_connection_change_; |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1239 NotifyObserversOfEffectiveConnectionTypeChanged() { | 1254 NotifyObserversOfEffectiveConnectionTypeChanged() { |
1240 DCHECK(thread_checker_.CalledOnValidThread()); | 1255 DCHECK(thread_checker_.CalledOnValidThread()); |
1241 | 1256 |
1242 // TODO(tbansal): Add hysteresis in the notification. | 1257 // TODO(tbansal): Add hysteresis in the notification. |
1243 FOR_EACH_OBSERVER( | 1258 FOR_EACH_OBSERVER( |
1244 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, | 1259 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, |
1245 OnEffectiveConnectionTypeChanged(effective_connection_type_)); | 1260 OnEffectiveConnectionTypeChanged(effective_connection_type_)); |
1246 } | 1261 } |
1247 | 1262 |
1248 } // namespace net | 1263 } // namespace net |
OLD | NEW |