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

Unified Diff: net/nqe/network_quality_estimator.cc

Issue 2593243003: Add network quality change events to net log (Closed)
Patch Set: ps 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 side-by-side diff with in-line comments
Download patch
Index: net/nqe/network_quality_estimator.cc
diff --git a/net/nqe/network_quality_estimator.cc b/net/nqe/network_quality_estimator.cc
index 6bb69d9ee8ce69244ef2313aa4ac2cff04ad604f..221264b99d39bedc6293eb2df9ad24ca3cad2ad4 100644
--- a/net/nqe/network_quality_estimator.cc
+++ b/net/nqe/network_quality_estimator.cc
@@ -33,6 +33,7 @@
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/http/http_status_code.h"
+#include "net/nqe/event_creator.h"
#include "net/nqe/network_quality_estimator_params.h"
#include "net/nqe/socket_watcher_factory.h"
#include "net/nqe/throughput_analyzer.h"
@@ -207,29 +208,35 @@ void RecordEffectiveConnectionTypeAccuracy(
NetworkQualityEstimator::NetworkQualityEstimator(
std::unique_ptr<ExternalEstimateProvider> external_estimates_provider,
- const std::map<std::string, std::string>& variation_params)
+ const std::map<std::string, std::string>& variation_params,
+ NetLog* net_log)
: NetworkQualityEstimator(std::move(external_estimates_provider),
variation_params,
false,
- false) {}
+ false,
+ net_log) {}
NetworkQualityEstimator::NetworkQualityEstimator(
std::unique_ptr<ExternalEstimateProvider> external_estimates_provider,
const std::map<std::string, std::string>& variation_params,
bool use_local_host_requests_for_tests,
- bool use_smaller_responses_for_tests)
- : NetworkQualityEstimator(std::move(external_estimates_provider),
- variation_params,
- use_local_host_requests_for_tests,
- use_smaller_responses_for_tests,
- true) {}
+ bool use_smaller_responses_for_tests,
+ NetLog* net_log)
+ : NetworkQualityEstimator(
+ std::move(external_estimates_provider),
+ variation_params,
+ use_local_host_requests_for_tests,
+ use_smaller_responses_for_tests,
+ true,
+ NetLogWithSource::Make(net_log, net::NetLogSourceType::NONE)) {}
NetworkQualityEstimator::NetworkQualityEstimator(
std::unique_ptr<ExternalEstimateProvider> external_estimates_provider,
const std::map<std::string, std::string>& variation_params,
bool use_local_host_requests_for_tests,
bool use_smaller_responses_for_tests,
- bool add_default_platform_observations)
+ bool add_default_platform_observations,
+ const NetLogWithSource& net_log)
: algorithm_name_to_enum_({{"HttpRTTAndDownstreamThroughput",
EffectiveConnectionTypeAlgorithm::
HTTP_RTT_AND_DOWNSTREAM_THROUGHOUT},
@@ -275,6 +282,7 @@ NetworkQualityEstimator::NetworkQualityEstimator(
variation_params)),
forced_effective_connection_type_(
nqe::internal::forced_effective_connection_type(variation_params)),
+ net_log_(net_log),
weak_ptr_factory_(this) {
// None of the algorithms can have an empty name.
DCHECK(algorithm_name_to_enum_.end() ==
@@ -722,6 +730,14 @@ void NetworkQualityEstimator::SetUseSmallResponsesForTesting(
void NetworkQualityEstimator::ReportEffectiveConnectionTypeForTesting(
EffectiveConnectionType effective_connection_type) {
DCHECK(thread_checker_.CalledOnValidThread());
+
+ nqe::internal::AddEffectiveConnectionTypeChangedEventToNetLog(
+ net_log_, typical_network_quality_[effective_connection_type].http_rtt(),
+ typical_network_quality_[effective_connection_type].transport_rtt(),
+ typical_network_quality_[effective_connection_type]
+ .downstream_throughput_kbps(),
+ effective_connection_type);
+
for (auto& observer : effective_connection_type_observer_list_)
observer.OnEffectiveConnectionTypeChanged(effective_connection_type);
@@ -1008,7 +1024,8 @@ void NetworkQualityEstimator::ComputeEffectiveConnectionType() {
NotifyObserversOfRTTOrThroughputComputed();
if (past_type != effective_connection_type_)
- NotifyObserversOfEffectiveConnectionTypeChanged();
+ NotifyObserversOfEffectiveConnectionTypeChanged(http_rtt, transport_rtt,
+ downstream_throughput_kbps);
rtt_observations_size_at_last_ect_computation_ = rtt_observations_.Size();
throughput_observations_size_at_last_ect_computation_ =
@@ -1371,8 +1388,11 @@ bool NetworkQualityEstimator::ReadCachedNetworkQualityEstimate() {
effective_connection_type_ =
cached_network_quality.effective_connection_type();
- if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN)
- NotifyObserversOfEffectiveConnectionTypeChanged();
+ if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
+ NotifyObserversOfEffectiveConnectionTypeChanged(
+ network_quality_.http_rtt(), network_quality_.transport_rtt(),
+ network_quality_.downstream_throughput_kbps());
+ }
}
if (cached_network_quality.network_quality().downstream_throughput_kbps() !=
@@ -1546,11 +1566,17 @@ void NetworkQualityEstimator::MaybeComputeEffectiveConnectionType() {
ComputeEffectiveConnectionType();
}
-void NetworkQualityEstimator::
- NotifyObserversOfEffectiveConnectionTypeChanged() {
+void NetworkQualityEstimator::NotifyObserversOfEffectiveConnectionTypeChanged(
+ base::TimeDelta http_rtt,
RyanSturm 2017/01/10 16:22:37 Why are you passing these values in? Can't you acc
tbansal1 2017/01/10 18:27:53 Good catch. Done.
+ base::TimeDelta transport_rtt,
+ int32_t downstream_throughput_kbps) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_NE(EFFECTIVE_CONNECTION_TYPE_LAST, effective_connection_type_);
+ nqe::internal::AddEffectiveConnectionTypeChangedEventToNetLog(
+ net_log_, http_rtt, transport_rtt, downstream_throughput_kbps,
+ effective_connection_type_);
+
// TODO(tbansal): Add hysteresis in the notification.
for (auto& observer : effective_connection_type_observer_list_)
observer.OnEffectiveConnectionTypeChanged(effective_connection_type_);

Powered by Google App Engine
This is Rietveld 408576698