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

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

Issue 2663963002: Add effective connection type to throughput mapping (Closed)
Patch Set: 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 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 const bool cached_estimate_available = network_quality_store_->GetById( 1375 const bool cached_estimate_available = network_quality_store_->GetById(
1376 current_network_id_, &cached_network_quality); 1376 current_network_id_, &cached_network_quality);
1377 UMA_HISTOGRAM_BOOLEAN("NQE.CachedNetworkQualityAvailable", 1377 UMA_HISTOGRAM_BOOLEAN("NQE.CachedNetworkQualityAvailable",
1378 cached_estimate_available); 1378 cached_estimate_available);
1379 1379
1380 if (!cached_estimate_available) 1380 if (!cached_estimate_available)
1381 return false; 1381 return false;
1382 1382
1383 const base::TimeTicks now = tick_clock_->NowTicks(); 1383 const base::TimeTicks now = tick_clock_->NowTicks();
1384 1384
1385 if (effective_connection_type_ == EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
1386 // Read the effective connection type from the cached estimate.
1387 last_effective_connection_type_computation_ = now;
1388 network_quality_ = cached_network_quality.network_quality();
1389 effective_connection_type_ =
1390 cached_network_quality.effective_connection_type();
1391
1392 if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN)
1393 NotifyObserversOfEffectiveConnectionTypeChanged();
1394 }
1395
1396 if (cached_network_quality.network_quality().downstream_throughput_kbps() != 1385 if (cached_network_quality.network_quality().downstream_throughput_kbps() !=
1397 nqe::internal::kInvalidThroughput) { 1386 nqe::internal::kInvalidThroughput) {
1398 ThroughputObservation througphput_observation( 1387 ThroughputObservation througphput_observation(
1399 cached_network_quality.network_quality().downstream_throughput_kbps(), 1388 cached_network_quality.network_quality().downstream_throughput_kbps(),
1400 now, INT32_MIN, 1389 now, INT32_MIN,
1401 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1390 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1402 downstream_throughput_kbps_observations_.AddObservation( 1391 downstream_throughput_kbps_observations_.AddObservation(
1403 througphput_observation); 1392 througphput_observation);
1404 NotifyObserversOfThroughput(througphput_observation); 1393 NotifyObserversOfThroughput(througphput_observation);
1405 } 1394 }
1406 1395
1407 if (cached_network_quality.network_quality().http_rtt() != 1396 if (cached_network_quality.network_quality().http_rtt() !=
1408 nqe::internal::InvalidRTT()) { 1397 nqe::internal::InvalidRTT()) {
1409 RttObservation rtt_observation( 1398 RttObservation rtt_observation(
1410 cached_network_quality.network_quality().http_rtt(), now, INT32_MIN, 1399 cached_network_quality.network_quality().http_rtt(), now, INT32_MIN,
1411 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1400 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1412 rtt_observations_.AddObservation(rtt_observation); 1401 rtt_observations_.AddObservation(rtt_observation);
1413 NotifyObserversOfRTT(rtt_observation); 1402 NotifyObserversOfRTT(rtt_observation);
1414 } 1403 }
1415 1404
1416 if (cached_network_quality.network_quality().transport_rtt() != 1405 if (cached_network_quality.network_quality().transport_rtt() !=
1417 nqe::internal::InvalidRTT()) { 1406 nqe::internal::InvalidRTT()) {
1418 RttObservation rtt_observation( 1407 RttObservation rtt_observation(
1419 cached_network_quality.network_quality().transport_rtt(), now, 1408 cached_network_quality.network_quality().transport_rtt(), now,
1420 INT32_MIN, 1409 INT32_MIN,
1421 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE); 1410 NETWORK_QUALITY_OBSERVATION_SOURCE_TRANSPORT_CACHED_ESTIMATE);
1422 rtt_observations_.AddObservation(rtt_observation); 1411 rtt_observations_.AddObservation(rtt_observation);
1423 NotifyObserversOfRTT(rtt_observation); 1412 NotifyObserversOfRTT(rtt_observation);
1424 } 1413 }
1414 ComputeEffectiveConnectionType();
1425 return true; 1415 return true;
1426 } 1416 }
1427 1417
1428 void NetworkQualityEstimator::OnUpdatedEstimateAvailable( 1418 void NetworkQualityEstimator::OnUpdatedEstimateAvailable(
1429 const base::TimeDelta& rtt, 1419 const base::TimeDelta& rtt,
1430 int32_t downstream_throughput_kbps, 1420 int32_t downstream_throughput_kbps,
1431 int32_t upstream_throughput_kbps) { 1421 int32_t upstream_throughput_kbps) {
1432 DCHECK(thread_checker_.CalledOnValidThread()); 1422 DCHECK(thread_checker_.CalledOnValidThread());
1433 DCHECK(external_estimate_provider_); 1423 DCHECK(external_estimate_provider_);
1434 1424
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1687 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1698 downstream_throughput_kbps_observations_.AddObservation( 1688 downstream_throughput_kbps_observations_.AddObservation(
1699 throughput_observation); 1689 throughput_observation);
1700 NotifyObserversOfThroughput(throughput_observation); 1690 NotifyObserversOfThroughput(throughput_observation);
1701 } 1691 }
1702 1692
1703 ComputeEffectiveConnectionType(); 1693 ComputeEffectiveConnectionType();
1704 } 1694 }
1705 1695
1706 } // namespace net 1696 } // 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