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

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

Issue 2681483002: NQE: Do not record correlation if metric is missing (Closed)
Patch Set: 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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 return; 611 return;
612 612
613 // Use the system clock instead of |tick_clock_| to compare the current 613 // Use the system clock instead of |tick_clock_| to compare the current
614 // timestamp with the |load_timing_info| timestamp since the latter is set by 614 // timestamp with the |load_timing_info| timestamp since the latter is set by
615 // the system clock, and may be different from |tick_clock_| in tests. 615 // the system clock, and may be different from |tick_clock_| in tests.
616 const base::TimeTicks now = base::TimeTicks::Now(); 616 const base::TimeTicks now = base::TimeTicks::Now();
617 // Record UMA only for requests that started recently. 617 // Record UMA only for requests that started recently.
618 if (now - last_main_frame_request_ > base::TimeDelta::FromSeconds(15)) 618 if (now - last_main_frame_request_ > base::TimeDelta::FromSeconds(15))
619 return; 619 return;
620 620
621 if (last_connection_change_ >= last_main_frame_request_)
622 return;
623
621 DCHECK_GE(now, load_timing_info.send_start); 624 DCHECK_GE(now, load_timing_info.send_start);
622 625
623 int32_t rtt = 0; 626 int32_t rtt = 0;
624 627
625 if (UseTransportRTT()) { 628 if (estimated_quality_at_last_main_frame_.downstream_throughput_kbps() ==
626 rtt = estimated_quality_at_last_main_frame_.transport_rtt() != 629 nqe::internal::kInvalidThroughput) {
627 nqe::internal::InvalidRTT() 630 return;
628 ? FitInKBitsPerMetricBits(
629 estimated_quality_at_last_main_frame_.transport_rtt()
630 .InMilliseconds())
631 : 0;
632 } else {
633 rtt = estimated_quality_at_last_main_frame_.http_rtt() !=
634 nqe::internal::InvalidRTT()
635 ? FitInKBitsPerMetricBits(
636 estimated_quality_at_last_main_frame_.http_rtt()
637 .InMilliseconds())
638 : 0;
639 } 631 }
640 632
641 const int32_t downstream_throughput = 633 if (UseTransportRTT()) {
642 estimated_quality_at_last_main_frame_.downstream_throughput_kbps() != 634 if (estimated_quality_at_last_main_frame_.transport_rtt() ==
643 nqe::internal::kInvalidThroughput 635 nqe::internal::InvalidRTT()) {
644 ? FitInKBitsPerMetricBits(estimated_quality_at_last_main_frame_ 636 return;
645 .downstream_throughput_kbps()) 637 }
646 : 0; 638 rtt = FitInKBitsPerMetricBits(
639 estimated_quality_at_last_main_frame_.transport_rtt().InMilliseconds());
640 } else {
641 if (estimated_quality_at_last_main_frame_.http_rtt() ==
642 nqe::internal::InvalidRTT()) {
643 return;
644 }
645 rtt = FitInKBitsPerMetricBits(
646 estimated_quality_at_last_main_frame_.http_rtt().InMilliseconds());
647 }
648
649 const int32_t downstream_throughput = FitInKBitsPerMetricBits(
650 estimated_quality_at_last_main_frame_.downstream_throughput_kbps());
647 651
648 const int32_t resource_load_time = FitInKBitsPerMetricBits( 652 const int32_t resource_load_time = FitInKBitsPerMetricBits(
649 (now - load_timing_info.send_start).InMilliseconds()); 653 (now - load_timing_info.send_start).InMilliseconds());
650 654
651 int64_t resource_size = (request.GetTotalReceivedBytes() * 8) / 1024; 655 int64_t resource_size = (request.GetTotalReceivedBytes() * 8) / 1024;
652 if (resource_size >= (1 << kBitsPerMetric)) { 656 if (resource_size >= (1 << kBitsPerMetric)) {
653 // Too large resource size (at least 128 Kb). 657 // Too large resource size (at least 128 Kb).
654 return; 658 return;
655 } 659 }
656 660
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE); 1691 NETWORK_QUALITY_OBSERVATION_SOURCE_HTTP_CACHED_ESTIMATE);
1688 downstream_throughput_kbps_observations_.AddObservation( 1692 downstream_throughput_kbps_observations_.AddObservation(
1689 throughput_observation); 1693 throughput_observation);
1690 NotifyObserversOfThroughput(throughput_observation); 1694 NotifyObserversOfThroughput(throughput_observation);
1691 } 1695 }
1692 1696
1693 ComputeEffectiveConnectionType(); 1697 ComputeEffectiveConnectionType();
1694 } 1698 }
1695 1699
1696 } // namespace net 1700 } // 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