| 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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 use_localhost_requests_); | 730 use_localhost_requests_); |
| 731 } | 731 } |
| 732 | 732 |
| 733 void NetworkQualityEstimator::SetUseSmallResponsesForTesting( | 733 void NetworkQualityEstimator::SetUseSmallResponsesForTesting( |
| 734 bool use_small_responses) { | 734 bool use_small_responses) { |
| 735 DCHECK(thread_checker_.CalledOnValidThread()); | 735 DCHECK(thread_checker_.CalledOnValidThread()); |
| 736 use_small_responses_ = use_small_responses; | 736 use_small_responses_ = use_small_responses; |
| 737 throughput_analyzer_->SetUseSmallResponsesForTesting(use_small_responses_); | 737 throughput_analyzer_->SetUseSmallResponsesForTesting(use_small_responses_); |
| 738 } | 738 } |
| 739 | 739 |
| 740 void NetworkQualityEstimator::ReportEffectiveConnectionTypeForTesting( |
| 741 EffectiveConnectionType effective_connection_type) { |
| 742 DCHECK(thread_checker_.CalledOnValidThread()); |
| 743 FOR_EACH_OBSERVER( |
| 744 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, |
| 745 OnEffectiveConnectionTypeChanged(effective_connection_type)); |
| 746 } |
| 747 |
| 740 bool NetworkQualityEstimator::RequestProvidesRTTObservation( | 748 bool NetworkQualityEstimator::RequestProvidesRTTObservation( |
| 741 const URLRequest& request) const { | 749 const URLRequest& request) const { |
| 742 DCHECK(thread_checker_.CalledOnValidThread()); | 750 DCHECK(thread_checker_.CalledOnValidThread()); |
| 743 | 751 |
| 744 return (use_localhost_requests_ || !IsLocalhost(request.url().host())) && | 752 return (use_localhost_requests_ || !IsLocalhost(request.url().host())) && |
| 745 // Verify that response headers are received, so it can be ensured that | 753 // Verify that response headers are received, so it can be ensured that |
| 746 // response is not cached. | 754 // response is not cached. |
| 747 !request.response_info().response_time.is_null() && | 755 !request.response_info().response_time.is_null() && |
| 748 !request.was_cached() && | 756 !request.was_cached() && |
| 749 request.creation_time() >= last_connection_change_; | 757 request.creation_time() >= last_connection_change_; |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 NotifyObserversOfEffectiveConnectionTypeChanged() { | 1480 NotifyObserversOfEffectiveConnectionTypeChanged() { |
| 1473 DCHECK(thread_checker_.CalledOnValidThread()); | 1481 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1474 | 1482 |
| 1475 // TODO(tbansal): Add hysteresis in the notification. | 1483 // TODO(tbansal): Add hysteresis in the notification. |
| 1476 FOR_EACH_OBSERVER( | 1484 FOR_EACH_OBSERVER( |
| 1477 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, | 1485 EffectiveConnectionTypeObserver, effective_connection_type_observer_list_, |
| 1478 OnEffectiveConnectionTypeChanged(effective_connection_type_)); | 1486 OnEffectiveConnectionTypeChanged(effective_connection_type_)); |
| 1479 } | 1487 } |
| 1480 | 1488 |
| 1481 } // namespace net | 1489 } // namespace net |
| OLD | NEW |