| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 current_network_id_.type, 10 * 1000); // 10 seconds | 685 current_network_id_.type, 10 * 1000); // 10 seconds |
| 686 transport_rtt_percentile->Add(rtt.InMilliseconds()); | 686 transport_rtt_percentile->Add(rtt.InMilliseconds()); |
| 687 } | 687 } |
| 688 } | 688 } |
| 689 } | 689 } |
| 690 | 690 |
| 691 NetworkQualityEstimator::EffectiveConnectionType | 691 NetworkQualityEstimator::EffectiveConnectionType |
| 692 NetworkQualityEstimator::GetEffectiveConnectionType() const { | 692 NetworkQualityEstimator::GetEffectiveConnectionType() const { |
| 693 DCHECK(thread_checker_.CalledOnValidThread()); | 693 DCHECK(thread_checker_.CalledOnValidThread()); |
| 694 | 694 |
| 695 // If the device is currently offline, then return |
| 696 // EFFECTIVE_CONNECTION_TYPE_OFFLINE. |
| 697 if (GetCurrentNetworkID().type == NetworkChangeNotifier::CONNECTION_NONE) |
| 698 return EFFECTIVE_CONNECTION_TYPE_OFFLINE; |
| 699 |
| 695 base::TimeDelta url_request_rtt = nqe::internal::InvalidRTT(); | 700 base::TimeDelta url_request_rtt = nqe::internal::InvalidRTT(); |
| 696 if (!GetURLRequestRTTEstimate(&url_request_rtt)) | 701 if (!GetURLRequestRTTEstimate(&url_request_rtt)) |
| 697 url_request_rtt = nqe::internal::InvalidRTT(); | 702 url_request_rtt = nqe::internal::InvalidRTT(); |
| 698 | 703 |
| 699 int32_t kbps = nqe::internal::kInvalidThroughput; | 704 int32_t kbps = nqe::internal::kInvalidThroughput; |
| 700 if (!GetDownlinkThroughputKbpsEstimate(&kbps)) | 705 if (!GetDownlinkThroughputKbpsEstimate(&kbps)) |
| 701 kbps = nqe::internal::kInvalidThroughput; | 706 kbps = nqe::internal::kInvalidThroughput; |
| 702 | 707 |
| 703 if (url_request_rtt == nqe::internal::InvalidRTT() && | 708 if (url_request_rtt == nqe::internal::InvalidRTT() && |
| 704 kbps == nqe::internal::kInvalidThroughput) { | 709 kbps == nqe::internal::kInvalidThroughput) { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 } | 1100 } |
| 1096 ThroughputObservation throughput_observation( | 1101 ThroughputObservation throughput_observation( |
| 1097 downstream_kbps, base::TimeTicks::Now(), | 1102 downstream_kbps, base::TimeTicks::Now(), |
| 1098 NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST); | 1103 NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST); |
| 1099 downstream_throughput_kbps_observations_.AddObservation( | 1104 downstream_throughput_kbps_observations_.AddObservation( |
| 1100 throughput_observation); | 1105 throughput_observation); |
| 1101 NotifyObserversOfThroughput(throughput_observation); | 1106 NotifyObserversOfThroughput(throughput_observation); |
| 1102 } | 1107 } |
| 1103 | 1108 |
| 1104 } // namespace net | 1109 } // namespace net |
| OLD | NEW |