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_localhost_requests) { |
| 627 DCHECK(thread_checker_.CalledOnValidThread()); |
| 628 use_localhost_requests_ = use_localhost_requests; |
| 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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 NotifyObserversOfEffectiveConnectionTypeChanged() { | 1289 NotifyObserversOfEffectiveConnectionTypeChanged() { |
1275 DCHECK(thread_checker_.CalledOnValidThread()); | 1290 DCHECK(thread_checker_.CalledOnValidThread()); |
1276 | 1291 |
1277 // TODO(tbansal): Add hysteresis in the notification. | 1292 // TODO(tbansal): Add hysteresis in the notification. |
1278 FOR_EACH_OBSERVER( | 1293 FOR_EACH_OBSERVER( |
1279 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, | 1294 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, |
1280 OnEffectiveConnectionTypeChanged(effective_connection_type_)); | 1295 OnEffectiveConnectionTypeChanged(effective_connection_type_)); |
1281 } | 1296 } |
1282 | 1297 |
1283 } // namespace net | 1298 } // namespace net |
OLD | NEW |