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

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

Issue 2265873002: Adjust callers and networking delegates in net/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: rebased Created 4 years, 3 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
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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 const int estimated_observed_diff_milliseconds = 799 const int estimated_observed_diff_milliseconds =
800 external_estimate_provider_quality_.http_rtt().InMilliseconds() - 800 external_estimate_provider_quality_.http_rtt().InMilliseconds() -
801 recent_http_rtt.InMilliseconds(); 801 recent_http_rtt.InMilliseconds();
802 802
803 RecordRTTAccuracy("NQE.ExternalEstimateProvider.RTT.Accuracy", 803 RecordRTTAccuracy("NQE.ExternalEstimateProvider.RTT.Accuracy",
804 estimated_observed_diff_milliseconds, measuring_duration, 804 estimated_observed_diff_milliseconds, measuring_duration,
805 recent_http_rtt); 805 recent_http_rtt);
806 } 806 }
807 } 807 }
808 808
809 void NetworkQualityEstimator::NotifyRequestCompleted( 809 void NetworkQualityEstimator::NotifyRequestCompleted(const URLRequest& request,
810 const URLRequest& request) { 810 int net_error) {
811 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), 811 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"),
812 "NetworkQualityEstimator::NotifyRequestCompleted"); 812 "NetworkQualityEstimator::NotifyRequestCompleted");
813 DCHECK(thread_checker_.CalledOnValidThread()); 813 DCHECK(thread_checker_.CalledOnValidThread());
814 814
815 if (!RequestSchemeIsHTTPOrHTTPS(request)) 815 if (!RequestSchemeIsHTTPOrHTTPS(request))
816 return; 816 return;
817 817
818 throughput_analyzer_->NotifyRequestCompleted(request); 818 throughput_analyzer_->NotifyRequestCompleted(request);
819 RecordCorrelationMetric(request); 819 RecordCorrelationMetric(request, net_error);
820 } 820 }
821 821
822 void NetworkQualityEstimator::RecordCorrelationMetric( 822 void NetworkQualityEstimator::RecordCorrelationMetric(const URLRequest& request,
823 const URLRequest& request) const { 823 int net_error) const {
824 DCHECK(thread_checker_.CalledOnValidThread()); 824 DCHECK(thread_checker_.CalledOnValidThread());
825 825
826 // The histogram is recorded with probability 826 // The histogram is recorded with probability
827 // |correlation_uma_logging_probability_| to reduce overhead involved with 827 // |correlation_uma_logging_probability_| to reduce overhead involved with
828 // sparse histograms. Also, recording the correlation on each request is 828 // sparse histograms. Also, recording the correlation on each request is
829 // unnecessary. 829 // unnecessary.
830 if (RandDouble() >= correlation_uma_logging_probability_) 830 if (RandDouble() >= correlation_uma_logging_probability_)
831 return; 831 return;
832 832
833 if (request.response_info().was_cached || 833 if (request.response_info().was_cached ||
834 !request.response_info().network_accessed) { 834 !request.response_info().network_accessed) {
835 return; 835 return;
836 } 836 }
837 837
838 LoadTimingInfo load_timing_info; 838 LoadTimingInfo load_timing_info;
839 request.GetLoadTimingInfo(&load_timing_info); 839 request.GetLoadTimingInfo(&load_timing_info);
840 // If the load timing info is unavailable, it probably means that the request 840 // If the load timing info is unavailable, it probably means that the request
841 // did not go over the network. 841 // did not go over the network.
842 if (load_timing_info.send_start.is_null() || 842 if (load_timing_info.send_start.is_null() ||
843 load_timing_info.receive_headers_end.is_null()) { 843 load_timing_info.receive_headers_end.is_null()) {
844 return; 844 return;
845 } 845 }
846 846
847 // Record UMA only for successful requests that have completed. 847 // Record UMA only for successful requests that have completed.
848 if (!request.status().is_success() || request.status().is_io_pending()) 848 if (net_error != OK || net_error == ERR_IO_PENDING)
mmenke 2016/08/30 22:13:22 The ERR_IO_PENDING part of this comparison is redu
maksims (do not use this acc) 2016/09/01 12:22:30 Do you mean all the paths here? Do you think they
849 return; 849 return;
850 if (request.GetResponseCode() != HTTP_OK) 850 if (request.GetResponseCode() != HTTP_OK)
851 return; 851 return;
852 if (load_timing_info.receive_headers_end < last_main_frame_request_) 852 if (load_timing_info.receive_headers_end < last_main_frame_request_)
853 return; 853 return;
854 854
855 const base::TimeTicks now = tick_clock_->NowTicks(); 855 const base::TimeTicks now = tick_clock_->NowTicks();
856 // Record UMA only for requests that started recently. 856 // Record UMA only for requests that started recently.
857 if (now - last_main_frame_request_ > base::TimeDelta::FromSeconds(15)) 857 if (now - last_main_frame_request_ > base::TimeDelta::FromSeconds(15))
858 return; 858 return;
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) { 1704 if (effective_connection_type_ != EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
1705 network_quality_store_->Add( 1705 network_quality_store_->Add(
1706 current_network_id_, 1706 current_network_id_,
1707 nqe::internal::CachedNetworkQuality( 1707 nqe::internal::CachedNetworkQuality(
1708 tick_clock_->NowTicks(), estimated_quality_at_last_main_frame_, 1708 tick_clock_->NowTicks(), estimated_quality_at_last_main_frame_,
1709 effective_connection_type_)); 1709 effective_connection_type_));
1710 } 1710 }
1711 } 1711 }
1712 1712
1713 } // namespace net 1713 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698