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

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

Issue 2005143005: Record network quality UMA metrics on main frame requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed rebase issues Created 4 years, 6 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_unittest.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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 if (!GetHttpRTTEstimate(&estimated_http_rtt)) 453 if (!GetHttpRTTEstimate(&estimated_http_rtt))
454 estimated_http_rtt = nqe::internal::InvalidRTT(); 454 estimated_http_rtt = nqe::internal::InvalidRTT();
455 455
456 int32_t downstream_throughput_kbps; 456 int32_t downstream_throughput_kbps;
457 if (!GetDownlinkThroughputKbpsEstimate(&downstream_throughput_kbps)) 457 if (!GetDownlinkThroughputKbpsEstimate(&downstream_throughput_kbps))
458 downstream_throughput_kbps = nqe::internal::kInvalidThroughput; 458 downstream_throughput_kbps = nqe::internal::kInvalidThroughput;
459 459
460 estimated_median_network_quality_ = nqe::internal::NetworkQuality( 460 estimated_median_network_quality_ = nqe::internal::NetworkQuality(
461 estimated_http_rtt, nqe::internal::InvalidRTT(), 461 estimated_http_rtt, nqe::internal::InvalidRTT(),
462 downstream_throughput_kbps); 462 downstream_throughput_kbps);
463
464 RecordMetricsOnMainFrameRequest();
463 } 465 }
464 466
465 base::TimeTicks now = base::TimeTicks::Now(); 467 base::TimeTicks now = base::TimeTicks::Now();
466 LoadTimingInfo load_timing_info; 468 LoadTimingInfo load_timing_info;
467 request.GetLoadTimingInfo(&load_timing_info); 469 request.GetLoadTimingInfo(&load_timing_info);
468 470
469 // If the load timing info is unavailable, it probably means that the request 471 // If the load timing info is unavailable, it probably means that the request
470 // did not go over the network. 472 // did not go over the network.
471 if (load_timing_info.send_start.is_null() || 473 if (load_timing_info.send_start.is_null() ||
472 load_timing_info.receive_headers_end.is_null()) { 474 load_timing_info.receive_headers_end.is_null()) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 base::TimeTicks(), kPercentiles[i]); 692 base::TimeTicks(), kPercentiles[i]);
691 693
692 transport_rtt_percentile = GetHistogram( 694 transport_rtt_percentile = GetHistogram(
693 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".", 695 "TransportRTT.Percentile" + base::IntToString(kPercentiles[i]) + ".",
694 current_network_id_.type, 10 * 1000); // 10 seconds 696 current_network_id_.type, 10 * 1000); // 10 seconds
695 transport_rtt_percentile->Add(rtt.InMilliseconds()); 697 transport_rtt_percentile->Add(rtt.InMilliseconds());
696 } 698 }
697 } 699 }
698 } 700 }
699 701
702 void NetworkQualityEstimator::RecordMetricsOnMainFrameRequest() const {
703 DCHECK(thread_checker_.CalledOnValidThread());
704
705 base::TimeDelta http_rtt;
706 if (GetHttpRTTEstimate(&http_rtt)) {
707 // Add the 50th percentile value.
708 base::HistogramBase* rtt_percentile = GetHistogram(
709 "MainFrame.RTT.Percentile50.", current_network_id_.type, 10 * 1000);
710 rtt_percentile->Add(http_rtt.InMilliseconds());
711 }
712
713 base::TimeDelta transport_rtt;
714 if (GetTransportRTTEstimate(&transport_rtt)) {
715 // Add the 50th percentile value.
716 base::HistogramBase* transport_rtt_percentile =
717 GetHistogram("MainFrame.TransportRTT.Percentile50.",
718 current_network_id_.type, 10 * 1000);
719 transport_rtt_percentile->Add(transport_rtt.InMilliseconds());
720 }
721
722 int32_t kbps;
723 if (GetDownlinkThroughputKbpsEstimate(&kbps)) {
724 // Add the 50th percentile value.
725 base::HistogramBase* throughput_percentile = GetHistogram(
726 "MainFrame.Kbps.Percentile50.", current_network_id_.type, 1000 * 1000);
727 throughput_percentile->Add(kbps);
728 }
729 }
730
700 NetworkQualityEstimator::EffectiveConnectionType 731 NetworkQualityEstimator::EffectiveConnectionType
701 NetworkQualityEstimator::GetEffectiveConnectionType() const { 732 NetworkQualityEstimator::GetEffectiveConnectionType() const {
702 DCHECK(thread_checker_.CalledOnValidThread()); 733 DCHECK(thread_checker_.CalledOnValidThread());
703 return GetRecentEffectiveConnectionType(base::TimeTicks()); 734 return GetRecentEffectiveConnectionType(base::TimeTicks());
704 } 735 }
705 736
706 NetworkQualityEstimator::EffectiveConnectionType 737 NetworkQualityEstimator::EffectiveConnectionType
707 NetworkQualityEstimator::GetRecentEffectiveConnectionType( 738 NetworkQualityEstimator::GetRecentEffectiveConnectionType(
708 const base::TimeTicks& start_time) const { 739 const base::TimeTicks& start_time) const {
709 DCHECK(thread_checker_.CalledOnValidThread()); 740 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 } 1144 }
1114 ThroughputObservation throughput_observation( 1145 ThroughputObservation throughput_observation(
1115 downstream_kbps, base::TimeTicks::Now(), 1146 downstream_kbps, base::TimeTicks::Now(),
1116 NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST); 1147 NETWORK_QUALITY_OBSERVATION_SOURCE_URL_REQUEST);
1117 downstream_throughput_kbps_observations_.AddObservation( 1148 downstream_throughput_kbps_observations_.AddObservation(
1118 throughput_observation); 1149 throughput_observation);
1119 NotifyObserversOfThroughput(throughput_observation); 1150 NotifyObserversOfThroughput(throughput_observation);
1120 } 1151 }
1121 1152
1122 } // namespace net 1153 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator.h ('k') | net/nqe/network_quality_estimator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698