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

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

Issue 2643213003: NQE: Add net log events when there is a significant change in metrics (Closed)
Patch Set: ryansturm comments Created 3 years, 11 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 | « net/nqe/network_quality_estimator.h ('k') | net/nqe/network_quality_estimator_test_util.h » ('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 15 matching lines...) Expand all
26 #include "base/trace_event/trace_event.h" 26 #include "base/trace_event/trace_event.h"
27 #include "build/build_config.h" 27 #include "build/build_config.h"
28 #include "net/base/load_flags.h" 28 #include "net/base/load_flags.h"
29 #include "net/base/load_timing_info.h" 29 #include "net/base/load_timing_info.h"
30 #include "net/base/network_interfaces.h" 30 #include "net/base/network_interfaces.h"
31 #include "net/base/trace_constants.h" 31 #include "net/base/trace_constants.h"
32 #include "net/base/url_util.h" 32 #include "net/base/url_util.h"
33 #include "net/http/http_response_headers.h" 33 #include "net/http/http_response_headers.h"
34 #include "net/http/http_response_info.h" 34 #include "net/http/http_response_info.h"
35 #include "net/http/http_status_code.h" 35 #include "net/http/http_status_code.h"
36 #include "net/nqe/event_creator.h"
37 #include "net/nqe/network_quality_estimator_params.h" 36 #include "net/nqe/network_quality_estimator_params.h"
38 #include "net/nqe/socket_watcher_factory.h" 37 #include "net/nqe/socket_watcher_factory.h"
39 #include "net/nqe/throughput_analyzer.h" 38 #include "net/nqe/throughput_analyzer.h"
40 #include "net/url_request/url_request.h" 39 #include "net/url_request/url_request.h"
41 #include "net/url_request/url_request_status.h" 40 #include "net/url_request/url_request_status.h"
42 #include "url/gurl.h" 41 #include "url/gurl.h"
43 42
44 #if defined(OS_ANDROID) 43 #if defined(OS_ANDROID)
45 #include "net/android/cellular_signal_strength.h" 44 #include "net/android/cellular_signal_strength.h"
46 #include "net/android/network_library.h" 45 #include "net/android/network_library.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 signal_strength_dbm_(INT32_MIN), 282 signal_strength_dbm_(INT32_MIN),
284 min_signal_strength_since_connection_change_(INT32_MAX), 283 min_signal_strength_since_connection_change_(INT32_MAX),
285 max_signal_strength_since_connection_change_(INT32_MIN), 284 max_signal_strength_since_connection_change_(INT32_MIN),
286 correlation_uma_logging_probability_( 285 correlation_uma_logging_probability_(
287 nqe::internal::correlation_uma_logging_probability(variation_params)), 286 nqe::internal::correlation_uma_logging_probability(variation_params)),
288 forced_effective_connection_type_set_( 287 forced_effective_connection_type_set_(
289 nqe::internal::forced_effective_connection_type_set( 288 nqe::internal::forced_effective_connection_type_set(
290 variation_params)), 289 variation_params)),
291 forced_effective_connection_type_( 290 forced_effective_connection_type_(
292 nqe::internal::forced_effective_connection_type(variation_params)), 291 nqe::internal::forced_effective_connection_type(variation_params)),
293 net_log_(net_log), 292 event_creator_(net_log),
294 weak_ptr_factory_(this) { 293 weak_ptr_factory_(this) {
295 // None of the algorithms can have an empty name. 294 // None of the algorithms can have an empty name.
296 DCHECK(algorithm_name_to_enum_.end() == 295 DCHECK(algorithm_name_to_enum_.end() ==
297 algorithm_name_to_enum_.find(std::string())); 296 algorithm_name_to_enum_.find(std::string()));
298 297
299 DCHECK_EQ(algorithm_name_to_enum_.size(), 298 DCHECK_EQ(algorithm_name_to_enum_.size(),
300 static_cast<size_t>(EffectiveConnectionTypeAlgorithm:: 299 static_cast<size_t>(EffectiveConnectionTypeAlgorithm::
301 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST)); 300 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST));
302 DCHECK_NE(EffectiveConnectionTypeAlgorithm:: 301 DCHECK_NE(EffectiveConnectionTypeAlgorithm::
303 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST, 302 EFFECTIVE_CONNECTION_TYPE_ALGORITHM_LAST,
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 bool disable_offline_check) { 739 bool disable_offline_check) {
741 DCHECK(thread_checker_.CalledOnValidThread()); 740 DCHECK(thread_checker_.CalledOnValidThread());
742 disable_offline_check_ = disable_offline_check; 741 disable_offline_check_ = disable_offline_check;
743 network_quality_store_->DisableOfflineCheckForTesting(disable_offline_check_); 742 network_quality_store_->DisableOfflineCheckForTesting(disable_offline_check_);
744 } 743 }
745 744
746 void NetworkQualityEstimator::ReportEffectiveConnectionTypeForTesting( 745 void NetworkQualityEstimator::ReportEffectiveConnectionTypeForTesting(
747 EffectiveConnectionType effective_connection_type) { 746 EffectiveConnectionType effective_connection_type) {
748 DCHECK(thread_checker_.CalledOnValidThread()); 747 DCHECK(thread_checker_.CalledOnValidThread());
749 748
750 nqe::internal::AddEffectiveConnectionTypeChangedEventToNetLog( 749 event_creator_.MaybeAddEffectiveConnectionTypeChangedEventToNetLog(
751 net_log_, typical_network_quality_[effective_connection_type].http_rtt(), 750 effective_connection_type_,
752 typical_network_quality_[effective_connection_type].transport_rtt(), 751 typical_network_quality_[effective_connection_type]);
753 typical_network_quality_[effective_connection_type]
754 .downstream_throughput_kbps(),
755 effective_connection_type);
756 752
757 for (auto& observer : effective_connection_type_observer_list_) 753 for (auto& observer : effective_connection_type_observer_list_)
758 observer.OnEffectiveConnectionTypeChanged(effective_connection_type); 754 observer.OnEffectiveConnectionTypeChanged(effective_connection_type);
759 755
760 network_quality_store_->Add(current_network_id_, 756 network_quality_store_->Add(current_network_id_,
761 nqe::internal::CachedNetworkQuality( 757 nqe::internal::CachedNetworkQuality(
762 tick_clock_->NowTicks(), network_quality_, 758 tick_clock_->NowTicks(), network_quality_,
763 effective_connection_type)); 759 effective_connection_type));
764 } 760 }
765 761
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 &downstream_throughput_kbps); 1031 &downstream_throughput_kbps);
1036 1032
1037 network_quality_ = nqe::internal::NetworkQuality(http_rtt, transport_rtt, 1033 network_quality_ = nqe::internal::NetworkQuality(http_rtt, transport_rtt,
1038 downstream_throughput_kbps); 1034 downstream_throughput_kbps);
1039 1035
1040 NotifyObserversOfRTTOrThroughputComputed(); 1036 NotifyObserversOfRTTOrThroughputComputed();
1041 1037
1042 if (past_type != effective_connection_type_) 1038 if (past_type != effective_connection_type_)
1043 NotifyObserversOfEffectiveConnectionTypeChanged(); 1039 NotifyObserversOfEffectiveConnectionTypeChanged();
1044 1040
1041 event_creator_.MaybeAddEffectiveConnectionTypeChangedEventToNetLog(
1042 effective_connection_type_, network_quality_);
1043
1045 rtt_observations_size_at_last_ect_computation_ = rtt_observations_.Size(); 1044 rtt_observations_size_at_last_ect_computation_ = rtt_observations_.Size();
1046 throughput_observations_size_at_last_ect_computation_ = 1045 throughput_observations_size_at_last_ect_computation_ =
1047 downstream_throughput_kbps_observations_.Size(); 1046 downstream_throughput_kbps_observations_.Size();
1048 } 1047 }
1049 1048
1050 EffectiveConnectionType NetworkQualityEstimator::GetEffectiveConnectionType() 1049 EffectiveConnectionType NetworkQualityEstimator::GetEffectiveConnectionType()
1051 const { 1050 const {
1052 DCHECK(thread_checker_.CalledOnValidThread()); 1051 DCHECK(thread_checker_.CalledOnValidThread());
1053 return effective_connection_type_; 1052 return effective_connection_type_;
1054 } 1053 }
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 return; 1579 return;
1581 } 1580 }
1582 ComputeEffectiveConnectionType(); 1581 ComputeEffectiveConnectionType();
1583 } 1582 }
1584 1583
1585 void NetworkQualityEstimator:: 1584 void NetworkQualityEstimator::
1586 NotifyObserversOfEffectiveConnectionTypeChanged() { 1585 NotifyObserversOfEffectiveConnectionTypeChanged() {
1587 DCHECK(thread_checker_.CalledOnValidThread()); 1586 DCHECK(thread_checker_.CalledOnValidThread());
1588 DCHECK_NE(EFFECTIVE_CONNECTION_TYPE_LAST, effective_connection_type_); 1587 DCHECK_NE(EFFECTIVE_CONNECTION_TYPE_LAST, effective_connection_type_);
1589 1588
1590 nqe::internal::AddEffectiveConnectionTypeChangedEventToNetLog(
1591 net_log_, network_quality_.http_rtt(), network_quality_.transport_rtt(),
1592 network_quality_.downstream_throughput_kbps(),
1593 effective_connection_type_);
1594
1595 // TODO(tbansal): Add hysteresis in the notification. 1589 // TODO(tbansal): Add hysteresis in the notification.
1596 for (auto& observer : effective_connection_type_observer_list_) 1590 for (auto& observer : effective_connection_type_observer_list_)
1597 observer.OnEffectiveConnectionTypeChanged(effective_connection_type_); 1591 observer.OnEffectiveConnectionTypeChanged(effective_connection_type_);
1598 1592
1599 // Add the estimates of the current network to the cache store. 1593 // Add the estimates of the current network to the cache store.
1600 if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) { 1594 if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
1601 network_quality_store_->Add(current_network_id_, 1595 network_quality_store_->Add(current_network_id_,
1602 nqe::internal::CachedNetworkQuality( 1596 nqe::internal::CachedNetworkQuality(
1603 tick_clock_->NowTicks(), network_quality_, 1597 tick_clock_->NowTicks(), network_quality_,
1604 effective_connection_type_)); 1598 effective_connection_type_));
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1714 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1721 downstream_throughput_kbps_observations_.AddObservation( 1715 downstream_throughput_kbps_observations_.AddObservation(
1722 throughput_observation); 1716 throughput_observation);
1723 NotifyObserversOfThroughput(throughput_observation); 1717 NotifyObserversOfThroughput(throughput_observation);
1724 } 1718 }
1725 1719
1726 ComputeEffectiveConnectionType(); 1720 ComputeEffectiveConnectionType();
1727 } 1721 }
1728 1722
1729 } // namespace net 1723 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator.h ('k') | net/nqe/network_quality_estimator_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698