OLD | NEW |
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 #ifndef NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 5 #ifndef NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 6 #define NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "net/nqe/event_creator.h" | 27 #include "net/nqe/event_creator.h" |
28 #include "net/nqe/external_estimate_provider.h" | 28 #include "net/nqe/external_estimate_provider.h" |
29 #include "net/nqe/network_id.h" | 29 #include "net/nqe/network_id.h" |
30 #include "net/nqe/network_quality.h" | 30 #include "net/nqe/network_quality.h" |
31 #include "net/nqe/network_quality_observation.h" | 31 #include "net/nqe/network_quality_observation.h" |
32 #include "net/nqe/network_quality_observation_source.h" | 32 #include "net/nqe/network_quality_observation_source.h" |
33 #include "net/nqe/network_quality_store.h" | 33 #include "net/nqe/network_quality_store.h" |
34 #include "net/nqe/observation_buffer.h" | 34 #include "net/nqe/observation_buffer.h" |
35 #include "net/socket/socket_performance_watcher_factory.h" | 35 #include "net/socket/socket_performance_watcher_factory.h" |
36 | 36 |
| 37 #if defined(OS_ANDROID) |
| 38 #include "net/android/cellular_signal_strength.h" |
| 39 #endif // OS_ANDROID |
| 40 |
37 namespace base { | 41 namespace base { |
38 class TickClock; | 42 class TickClock; |
39 } // namespace base | 43 } // namespace base |
40 | 44 |
41 namespace net { | 45 namespace net { |
42 | 46 |
43 class NetLog; | 47 class NetLog; |
44 | 48 |
45 namespace nqe { | 49 namespace nqe { |
46 namespace internal { | 50 namespace internal { |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 // When set to true, the device offline check is disabled when computing the | 666 // When set to true, the device offline check is disabled when computing the |
663 // effective connection type or when writing the prefs. | 667 // effective connection type or when writing the prefs. |
664 bool disable_offline_check_; | 668 bool disable_offline_check_; |
665 | 669 |
666 // If true, default values provided by the platform are used for estimation. | 670 // If true, default values provided by the platform are used for estimation. |
667 const bool add_default_platform_observations_; | 671 const bool add_default_platform_observations_; |
668 | 672 |
669 // The factor by which the weight of an observation reduces every second. | 673 // The factor by which the weight of an observation reduces every second. |
670 const double weight_multiplier_per_second_; | 674 const double weight_multiplier_per_second_; |
671 | 675 |
672 // The factor by which the weight of an observation reduces for every dBm | 676 // The factor by which the weight of an observation reduces for every signal |
673 // difference between the current signal strength (in dBm), and the signal | 677 // strength level difference between the current signal strength, and the |
674 // strength at the time when the observation was taken. | 678 // signal strength at the time when the observation was taken. |
675 const double weight_multiplier_per_dbm_; | 679 const double weight_multiplier_per_signal_strength_level_; |
676 | 680 |
677 // Algorithm to use for computing effective connection type. The value is | 681 // Algorithm to use for computing effective connection type. The value is |
678 // obtained from field trial parameters. If the value from field trial | 682 // obtained from field trial parameters. If the value from field trial |
679 // parameters is unavailable, it is set to | 683 // parameters is unavailable, it is set to |
680 // kDefaultEffectiveConnectionTypeAlgorithm. | 684 // kDefaultEffectiveConnectionTypeAlgorithm. |
681 const EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; | 685 const EffectiveConnectionTypeAlgorithm effective_connection_type_algorithm_; |
682 | 686 |
683 // Tick clock used by the network quality estimator. | 687 // Tick clock used by the network quality estimator. |
684 std::unique_ptr<base::TickClock> tick_clock_; | 688 std::unique_ptr<base::TickClock> tick_clock_; |
685 | 689 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 | 783 |
780 // Current estimate of the network quality. | 784 // Current estimate of the network quality. |
781 nqe::internal::NetworkQuality network_quality_; | 785 nqe::internal::NetworkQuality network_quality_; |
782 | 786 |
783 // Current effective connection type. It is updated on connection change | 787 // Current effective connection type. It is updated on connection change |
784 // events. It is also updated every time there is network traffic (provided | 788 // events. It is also updated every time there is network traffic (provided |
785 // the last computation was more than | 789 // the last computation was more than |
786 // |effective_connection_type_recomputation_interval_| ago). | 790 // |effective_connection_type_recomputation_interval_| ago). |
787 EffectiveConnectionType effective_connection_type_; | 791 EffectiveConnectionType effective_connection_type_; |
788 | 792 |
789 // Last known value of the wireless signal strength. Set to INT32_MIN if | 793 // Last known value of the wireless signal strength level. Set to INT32_MIN if |
790 // unavailable. |signal_strength_dbm_| is reset to INT32_MIN on connection | 794 // unavailable. |signal_strength_| is reset to INT32_MIN on connection |
791 // change events. | 795 // change events. If the signal strength level is available, the value is set |
792 int32_t signal_strength_dbm_; | 796 // to between 0 and 4, both inclusive. |
| 797 base::Optional<int32_t> signal_strength_; |
793 | 798 |
794 // Minimum and maximum signal strength (in dBm) observed since last connection | 799 // Minimum and maximum signal strength level observed since last connection |
795 // change. Updated on connection change and main frame requests. | 800 // change. Updated on connection change and main frame requests. |
796 int32_t min_signal_strength_since_connection_change_; | 801 base::Optional<int32_t> min_signal_strength_since_connection_change_; |
797 int32_t max_signal_strength_since_connection_change_; | 802 base::Optional<int32_t> max_signal_strength_since_connection_change_; |
798 | 803 |
799 // It is costlier to add values to a sparse histogram. So, the correlation UMA | 804 // It is costlier to add values to a sparse histogram. So, the correlation UMA |
800 // is recorded with |correlation_uma_logging_probability_| since recording it | 805 // is recorded with |correlation_uma_logging_probability_| since recording it |
801 // in a sparse histogram for each request is unnecessary and cost-prohibitive. | 806 // in a sparse histogram for each request is unnecessary and cost-prohibitive. |
802 // e.g., if it is 0.0, then the UMA will never be recorded. On the other hand, | 807 // e.g., if it is 0.0, then the UMA will never be recorded. On the other hand, |
803 // if it is 1.0, then it will be recorded for all valid HTTP requests. | 808 // if it is 1.0, then it will be recorded for all valid HTTP requests. |
804 const double correlation_uma_logging_probability_; | 809 const double correlation_uma_logging_probability_; |
805 | 810 |
806 // Stores the qualities of different networks. | 811 // Stores the qualities of different networks. |
807 std::unique_ptr<nqe::internal::NetworkQualityStore> network_quality_store_; | 812 std::unique_ptr<nqe::internal::NetworkQualityStore> network_quality_store_; |
(...skipping 15 matching lines...) Expand all Loading... |
823 // Vector that contains observation sources that should not be used when | 828 // Vector that contains observation sources that should not be used when |
824 // computing the estimate at HTTP layer. | 829 // computing the estimate at HTTP layer. |
825 const std::vector<NetworkQualityObservationSource> | 830 const std::vector<NetworkQualityObservationSource> |
826 disallowed_observation_sources_for_http_; | 831 disallowed_observation_sources_for_http_; |
827 | 832 |
828 // Vector that contains observation sources that should not be used when | 833 // Vector that contains observation sources that should not be used when |
829 // computing the estimate at transport layer. | 834 // computing the estimate at transport layer. |
830 const std::vector<NetworkQualityObservationSource> | 835 const std::vector<NetworkQualityObservationSource> |
831 disallowed_observation_sources_for_transport_; | 836 disallowed_observation_sources_for_transport_; |
832 | 837 |
| 838 #if defined(OS_ANDROID) |
| 839 // Initialized only if the experiment to use the cellular signal strength |
| 840 // is enabled. |
| 841 std::unique_ptr<android::CellularSignalStrength> cellular_signal_strength_; |
| 842 #endif // OS_ANDROID |
| 843 |
833 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; | 844 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
834 | 845 |
835 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); | 846 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
836 }; | 847 }; |
837 | 848 |
838 } // namespace net | 849 } // namespace net |
839 | 850 |
840 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ | 851 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |
OLD | NEW |