Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: net/nqe/network_quality_estimator.cc

Issue 2648353003: Add effective connection type to throughput mapping (Closed)
Patch Set: ryansturm comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/nqe/network_quality_estimator_params.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 const bool cached_estimate_available = network_quality_store_->GetById( 1392 const bool cached_estimate_available = network_quality_store_->GetById(
1393 current_network_id_, &cached_network_quality); 1393 current_network_id_, &cached_network_quality);
1394 UMA_HISTOGRAM_BOOLEAN("NQE.CachedNetworkQualityAvailable", 1394 UMA_HISTOGRAM_BOOLEAN("NQE.CachedNetworkQualityAvailable",
1395 cached_estimate_available); 1395 cached_estimate_available);
1396 1396
1397 if (!cached_estimate_available) 1397 if (!cached_estimate_available)
1398 return false; 1398 return false;
1399 1399
1400 const base::TimeTicks now = tick_clock_->NowTicks(); 1400 const base::TimeTicks now = tick_clock_->NowTicks();
1401 1401
1402 if (effective_connection_type_ == EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
1403 // Read the effective connection type from the cached estimate.
1404 last_effective_connection_type_computation_ = now;
1405 network_quality_ = cached_network_quality.network_quality();
1406 effective_connection_type_ =
1407 cached_network_quality.effective_connection_type();
1408
1409 if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN)
1410 NotifyObserversOfEffectiveConnectionTypeChanged();
1411 }
1412
1413 if (cached_network_quality.network_quality().downstream_throughput_kbps() != 1402 if (cached_network_quality.network_quality().downstream_throughput_kbps() !=
1414 nqe::internal::kInvalidThroughput) { 1403 nqe::internal::kInvalidThroughput) {
1415 ThroughputObservation througphput_observation( 1404 ThroughputObservation througphput_observation(
1416 cached_network_quality.network_quality().downstream_throughput_kbps(), 1405 cached_network_quality.network_quality().downstream_throughput_kbps(),
1417 now, INT32_MIN, 1406 now, INT32_MIN,
1418 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1407 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1419 downstream_throughput_kbps_observations_.AddObservation( 1408 downstream_throughput_kbps_observations_.AddObservation(
1420 througphput_observation); 1409 througphput_observation);
1421 NotifyObserversOfThroughput(througphput_observation); 1410 NotifyObserversOfThroughput(througphput_observation);
1422 } 1411 }
1423 1412
1424 if (cached_network_quality.network_quality().http_rtt() != 1413 if (cached_network_quality.network_quality().http_rtt() !=
1425 nqe::internal::InvalidRTT()) { 1414 nqe::internal::InvalidRTT()) {
1426 RttObservation rtt_observation( 1415 RttObservation rtt_observation(
1427 cached_network_quality.network_quality().http_rtt(), now, INT32_MIN, 1416 cached_network_quality.network_quality().http_rtt(), now, INT32_MIN,
1428 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1417 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1429 rtt_observations_.AddObservation(rtt_observation); 1418 rtt_observations_.AddObservation(rtt_observation);
1430 NotifyObserversOfRTT(rtt_observation); 1419 NotifyObserversOfRTT(rtt_observation);
1431 } 1420 }
1432 1421
1433 if (cached_network_quality.network_quality().transport_rtt() != 1422 if (cached_network_quality.network_quality().transport_rtt() !=
1434 nqe::internal::InvalidRTT()) { 1423 nqe::internal::InvalidRTT()) {
1435 RttObservation rtt_observation( 1424 RttObservation rtt_observation(
1436 cached_network_quality.network_quality().transport_rtt(), now, 1425 cached_network_quality.network_quality().transport_rtt(), now,
1437 INT32_MIN, 1426 INT32_MIN,
1438 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE); 1427 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE);
1439 rtt_observations_.AddObservation(rtt_observation); 1428 rtt_observations_.AddObservation(rtt_observation);
1440 NotifyObserversOfRTT(rtt_observation); 1429 NotifyObserversOfRTT(rtt_observation);
1441 } 1430 }
1431 ComputeEffectiveConnectionType();
1442 return true; 1432 return true;
1443 } 1433 }
1444 1434
1445 void NetworkQualityEstimator::OnUpdatedEstimateAvailable( 1435 void NetworkQualityEstimator::OnUpdatedEstimateAvailable(
1446 const base::TimeDelta& rtt, 1436 const base::TimeDelta& rtt,
1447 int32_t downstream_throughput_kbps, 1437 int32_t downstream_throughput_kbps,
1448 int32_t upstream_throughput_kbps) { 1438 int32_t upstream_throughput_kbps) {
1449 DCHECK(thread_checker_.CalledOnValidThread()); 1439 DCHECK(thread_checker_.CalledOnValidThread());
1450 DCHECK(external_estimate_provider_); 1440 DCHECK(external_estimate_provider_);
1451 1441
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1704 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1715 downstream_throughput_kbps_observations_.AddObservation( 1705 downstream_throughput_kbps_observations_.AddObservation(
1716 throughput_observation); 1706 throughput_observation);
1717 NotifyObserversOfThroughput(throughput_observation); 1707 NotifyObserversOfThroughput(throughput_observation);
1718 } 1708 }
1719 1709
1720 ComputeEffectiveConnectionType(); 1710 ComputeEffectiveConnectionType();
1721 } 1711 }
1722 1712
1723 } // namespace net 1713 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/nqe/network_quality_estimator_params.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698