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

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

Issue 2668403003: NQE: Do not record correlation if metric is missing (Closed)
Patch Set: ryansturm comments 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_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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return; 619 return;
620 620
621 // Use the system clock instead of |tick_clock_| to compare the current 621 // Use the system clock instead of |tick_clock_| to compare the current
622 // timestamp with the |load_timing_info| timestamp since the latter is set by 622 // timestamp with the |load_timing_info| timestamp since the latter is set by
623 // the system clock, and may be different from |tick_clock_| in tests. 623 // the system clock, and may be different from |tick_clock_| in tests.
624 const base::TimeTicks now = base::TimeTicks::Now(); 624 const base::TimeTicks now = base::TimeTicks::Now();
625 // Record UMA only for requests that started recently. 625 // Record UMA only for requests that started recently.
626 if (now - last_main_frame_request_ > base::TimeDelta::FromSeconds(15)) 626 if (now - last_main_frame_request_ > base::TimeDelta::FromSeconds(15))
627 return; 627 return;
628 628
629 if (last_connection_change_ >= last_main_frame_request_)
630 return;
631
629 DCHECK_GE(now, load_timing_info.send_start); 632 DCHECK_GE(now, load_timing_info.send_start);
630 633
631 int32_t rtt = 0; 634 int32_t rtt = 0;
632 635
633 if (UseTransportRTT()) { 636 if (estimated_quality_at_last_main_frame_.downstream_throughput_kbps() ==
634 rtt = estimated_quality_at_last_main_frame_.transport_rtt() != 637 nqe::internal::kInvalidThroughput) {
635 nqe::internal::InvalidRTT() 638 return;
636 ? FitInKBitsPerMetricBits(
637 estimated_quality_at_last_main_frame_.transport_rtt()
638 .InMilliseconds())
639 : 0;
640 } else {
641 rtt = estimated_quality_at_last_main_frame_.http_rtt() !=
642 nqe::internal::InvalidRTT()
643 ? FitInKBitsPerMetricBits(
644 estimated_quality_at_last_main_frame_.http_rtt()
645 .InMilliseconds())
646 : 0;
647 } 639 }
648 640
649 const int32_t downstream_throughput = 641 if (UseTransportRTT()) {
650 estimated_quality_at_last_main_frame_.downstream_throughput_kbps() != 642 if (estimated_quality_at_last_main_frame_.transport_rtt() ==
651 nqe::internal::kInvalidThroughput 643 nqe::internal::InvalidRTT()) {
652 ? FitInKBitsPerMetricBits(estimated_quality_at_last_main_frame_ 644 return;
653 .downstream_throughput_kbps()) 645 }
654 : 0; 646 rtt = FitInKBitsPerMetricBits(
647 estimated_quality_at_last_main_frame_.transport_rtt().InMilliseconds());
648 } else {
649 if (estimated_quality_at_last_main_frame_.http_rtt() ==
650 nqe::internal::InvalidRTT()) {
651 return;
652 }
653 rtt = FitInKBitsPerMetricBits(
654 estimated_quality_at_last_main_frame_.http_rtt().InMilliseconds());
655 }
656
657 const int32_t downstream_throughput = FitInKBitsPerMetricBits(
658 estimated_quality_at_last_main_frame_.downstream_throughput_kbps());
655 659
656 const int32_t resource_load_time = FitInKBitsPerMetricBits( 660 const int32_t resource_load_time = FitInKBitsPerMetricBits(
657 (now - load_timing_info.send_start).InMilliseconds()); 661 (now - load_timing_info.send_start).InMilliseconds());
658 662
659 int64_t resource_size = (request.GetTotalReceivedBytes() * 8) / 1024; 663 int64_t resource_size = (request.GetTotalReceivedBytes() * 8) / 1024;
660 if (resource_size >= (1 << kBitsPerMetric)) { 664 if (resource_size >= (1 << kBitsPerMetric)) {
661 // Too large resource size (at least 128 Kb). 665 // Too large resource size (at least 128 Kb).
662 return; 666 return;
663 } 667 }
664 668
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1727 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1724 downstream_throughput_kbps_observations_.AddObservation( 1728 downstream_throughput_kbps_observations_.AddObservation(
1725 throughput_observation); 1729 throughput_observation);
1726 NotifyObserversOfThroughput(throughput_observation); 1730 NotifyObserversOfThroughput(throughput_observation);
1727 } 1731 }
1728 1732
1729 ComputeEffectiveConnectionType(); 1733 ComputeEffectiveConnectionType();
1730 } 1734 }
1731 1735
1732 } // namespace net 1736 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/nqe/network_quality_estimator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698