Chromium Code Reviews| 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 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1399 return false; | 1399 return false; |
| 1400 | 1400 |
| 1401 const base::TimeTicks now = tick_clock_->NowTicks(); | 1401 const base::TimeTicks now = tick_clock_->NowTicks(); |
| 1402 | 1402 |
| 1403 if (effective_connection_type_ == EFFECTIVE_CONNECTION_TYPE_UNKNOWN) { | 1403 if (effective_connection_type_ == EFFECTIVE_CONNECTION_TYPE_UNKNOWN) { |
| 1404 // Read the effective connection type from the cached estimate. | 1404 // Read the effective connection type from the cached estimate. |
| 1405 last_effective_connection_type_computation_ = now; | 1405 last_effective_connection_type_computation_ = now; |
| 1406 network_quality_ = cached_network_quality.network_quality(); | 1406 network_quality_ = cached_network_quality.network_quality(); |
| 1407 effective_connection_type_ = | 1407 effective_connection_type_ = |
| 1408 cached_network_quality.effective_connection_type(); | 1408 cached_network_quality.effective_connection_type(); |
| 1409 | |
| 1410 if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) | |
| 1411 NotifyObserversOfEffectiveConnectionTypeChanged(); | |
| 1412 } | 1409 } |
| 1413 | 1410 |
| 1414 if (cached_network_quality.network_quality().downstream_throughput_kbps() != | 1411 if (cached_network_quality.network_quality().downstream_throughput_kbps() != |
| 1415 nqe::internal::kInvalidThroughput) { | 1412 nqe::internal::kInvalidThroughput) { |
| 1416 ThroughputObservation througphput_observation( | 1413 ThroughputObservation througphput_observation( |
| 1417 cached_network_quality.network_quality().downstream_throughput_kbps(), | 1414 cached_network_quality.network_quality().downstream_throughput_kbps(), |
| 1418 now, INT32_MIN, | 1415 now, INT32_MIN, |
| 1419 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); | 1416 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); |
| 1420 downstream_throughput_kbps_observations_.AddObservation( | 1417 downstream_throughput_kbps_observations_.AddObservation( |
| 1421 througphput_observation); | 1418 througphput_observation); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1433 | 1430 |
| 1434 if (cached_network_quality.network_quality().transport_rtt() != | 1431 if (cached_network_quality.network_quality().transport_rtt() != |
| 1435 nqe::internal::InvalidRTT()) { | 1432 nqe::internal::InvalidRTT()) { |
| 1436 RttObservation rtt_observation( | 1433 RttObservation rtt_observation( |
| 1437 cached_network_quality.network_quality().transport_rtt(), now, | 1434 cached_network_quality.network_quality().transport_rtt(), now, |
| 1438 INT32_MIN, | 1435 INT32_MIN, |
| 1439 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE); | 1436 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE); |
| 1440 rtt_observations_.AddObservation(rtt_observation); | 1437 rtt_observations_.AddObservation(rtt_observation); |
| 1441 NotifyObserversOfRTT(rtt_observation); | 1438 NotifyObserversOfRTT(rtt_observation); |
| 1442 } | 1439 } |
| 1440 ComputeEffectiveConnectionType(); | |
|
RyanSturm
2017/01/25 19:15:34
If the computed type doesn't change from the ect o
tbansal1
2017/01/26 22:00:05
I removed that unnecessary code. ComputeECT() func
| |
| 1443 return true; | 1441 return true; |
| 1444 } | 1442 } |
| 1445 | 1443 |
| 1446 void NetworkQualityEstimator::OnUpdatedEstimateAvailable( | 1444 void NetworkQualityEstimator::OnUpdatedEstimateAvailable( |
| 1447 const base::TimeDelta& rtt, | 1445 const base::TimeDelta& rtt, |
| 1448 int32_t downstream_throughput_kbps, | 1446 int32_t downstream_throughput_kbps, |
| 1449 int32_t upstream_throughput_kbps) { | 1447 int32_t upstream_throughput_kbps) { |
| 1450 DCHECK(thread_checker_.CalledOnValidThread()); | 1448 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1451 DCHECK(external_estimate_provider_); | 1449 DCHECK(external_estimate_provider_); |
| 1452 | 1450 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1720 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); | 1718 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); |
| 1721 downstream_throughput_kbps_observations_.AddObservation( | 1719 downstream_throughput_kbps_observations_.AddObservation( |
| 1722 throughput_observation); | 1720 throughput_observation); |
| 1723 NotifyObserversOfThroughput(throughput_observation); | 1721 NotifyObserversOfThroughput(throughput_observation); |
| 1724 } | 1722 } |
| 1725 | 1723 |
| 1726 ComputeEffectiveConnectionType(); | 1724 ComputeEffectiveConnectionType(); |
| 1727 } | 1725 } |
| 1728 | 1726 |
| 1729 } // namespace net | 1727 } // namespace net |
| OLD | NEW |