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

Unified Diff: net/nqe/network_quality_estimator_params.h

Issue 2775223004: NQE: Make params a class (Closed)
Patch Set: ryansturm nits Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/nqe/network_quality_estimator.cc ('k') | net/nqe/network_quality_estimator_params.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/nqe/network_quality_estimator_params.h
diff --git a/net/nqe/network_quality_estimator_params.h b/net/nqe/network_quality_estimator_params.h
index 6d7310f95ea78d8c5816dee522768492ed366dcd..9996735c4902a6625619bf53b66c494f5b3c0877 100644
--- a/net/nqe/network_quality_estimator_params.h
+++ b/net/nqe/network_quality_estimator_params.h
@@ -8,6 +8,8 @@
#include <map>
#include <string>
+#include "base/macros.h"
+#include "base/threading/thread_checker.h"
#include "net/base/network_change_notifier.h"
#include "net/nqe/effective_connection_type.h"
#include "net/nqe/network_quality.h"
@@ -18,70 +20,81 @@ namespace nqe {
namespace internal {
-// Returns the algorithm that should be used for computing effective connection
-// type based on field trial params. Returns an empty string if a valid
-// algorithm paramter is not present in the field trial params.
-std::string GetEffectiveConnectionTypeAlgorithm(
- const std::map<std::string, std::string>& variation_params);
-
-// Computes and returns the weight multiplier per second, which represents the
-// factor by which the weight of an observation reduces every second.
-// |variation_params| is the map containing all field trial parameters
-// related to the NetworkQualityualityEstimator field trial.
-double GetWeightMultiplierPerSecond(
- const std::map<std::string, std::string>& variation_params);
-
-// Returns the factor by which the weight of an observation reduces for every
-// dBm difference between the current signal strength (in dBm), and the signal
-// strength at the time when the observation was taken.
-double GetWeightMultiplierPerDbm(
- const std::map<std::string, std::string>& variation_params);
-
-// Returns a descriptive name corresponding to |connection_type|.
-const char* GetNameForConnectionType(
- net::NetworkChangeNotifier::ConnectionType connection_type);
-
-// Sets the default observation for different connection types in
-// |default_observations|. The default observations are different for different
-// connection types (e.g., 2G, 3G, 4G, WiFi). The default observations may be
-// used to determine the network quality in absence of any other information.
-void ObtainDefaultObservations(
- const std::map<std::string, std::string>& variation_params,
- nqe::internal::NetworkQuality default_observations[]);
-
-// Sets |typical_network_quality| to typical network quality for different
-// effective connection types.
-void ObtainTypicalNetworkQuality(NetworkQuality typical_network_quality[]);
-
-// Parses the variation paramaters and sets the thresholds for different
-// effective connection types in |connection_thresholds|.
-void ObtainEffectiveConnectionTypeModelParams(
- const std::map<std::string, std::string>& variation_params,
- nqe::internal::NetworkQuality connection_thresholds[]);
-
-// Returns the fraction of URL requests that should record the correlation UMA.
-double correlation_uma_logging_probability(
- const std::map<std::string, std::string>& variation_params);
-
-// Returns true if the effective connection type has been determined via
-// variation parameters.
-bool forced_effective_connection_type_set(
- const std::map<std::string, std::string>& variation_params);
-
-// Returns the effective connection type that was configured by variation
-// parameters.
-EffectiveConnectionType forced_effective_connection_type(
- const std::map<std::string, std::string>& variation_params);
-
-// Returns true if reading from the persistent cache has been enabled via field
-// trial.
-bool persistent_cache_reading_enabled(
- const std::map<std::string, std::string>& variation_params);
-
-// Returns the the minimum interval betweeen consecutive notifications to a
-// single socket watcher.
-base::TimeDelta GetMinSocketWatcherNotificationInterval(
- const std::map<std::string, std::string>& variation_params);
+// NetworkQualityEstimatorParams computes the configuration parameters for
+// the network quality estimator.
+class NetworkQualityEstimatorParams {
+ public:
+ // |params| is the map containing all field trial parameters related to
+ // NetworkQualityEstimator field trial.
+ explicit NetworkQualityEstimatorParams(
+ const std::map<std::string, std::string>& params);
+
+ ~NetworkQualityEstimatorParams();
+
+ // Returns the algorithm that should be used for computing effective
+ // connection type. Returns an empty string if a valid algorithm paramter is
+ // not specified.
+ std::string GetEffectiveConnectionTypeAlgorithm() const;
+
+ // Computes and returns the weight multiplier per second, which represents the
+ // factor by which the weight of an observation reduces every second.
+ double GetWeightMultiplierPerSecond() const;
+
+ // Returns the factor by which the weight of an observation reduces for every
+ // dBm difference between the current signal strength (in dBm), and the signal
+ // strength at the time when the observation was taken.
+ double GetWeightMultiplierPerDbm() const;
+
+ // Returns a descriptive name corresponding to |connection_type|.
+ static const char* GetNameForConnectionType(
+ net::NetworkChangeNotifier::ConnectionType connection_type);
+
+ // Sets the default observation for different connection types in
+ // |default_observations|. The default observations are different for
+ // different connection types (e.g., 2G, 3G, 4G, WiFi). The default
+ // observations may be used to determine the network quality in absence of any
+ // other information.
+ void ObtainDefaultObservations(
+ nqe::internal::NetworkQuality default_observations[]) const;
+
+ // Sets |typical_network_quality| to typical network quality for different
+ // effective connection types.
+ void ObtainTypicalNetworkQuality(
+ NetworkQuality typical_network_quality[]) const;
+
+ // Sets the thresholds for different effective connection types in
+ // |connection_thresholds|.
+ void ObtainEffectiveConnectionTypeModelParams(
+ nqe::internal::NetworkQuality connection_thresholds[]) const;
+
+ // Returns the fraction of URL requests that should record the correlation
+ // UMA.
+ double correlation_uma_logging_probability() const;
+
+ // Returns true if the effective connection type has been forced via field
+ // trial parameters.
+ bool forced_effective_connection_type_set() const;
+
+ // Returns the effective connection type if it has been forced via field trial
+ // parameters.
+ EffectiveConnectionType forced_effective_connection_type() const;
+
+ // Returns true if reading from the persistent cache is enabled.
+ bool persistent_cache_reading_enabled() const;
+
+ // Returns the the minimum interval betweeen consecutive notifications to a
+ // single socket watcher.
+ base::TimeDelta GetMinSocketWatcherNotificationInterval() const;
+
+ private:
+ // Map containing all field trial parameters related to
+ // NetworkQualityEstimator field trial.
+ const std::map<std::string, std::string> params_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimatorParams);
+};
} // namespace internal
« no previous file with comments | « net/nqe/network_quality_estimator.cc ('k') | net/nqe/network_quality_estimator_params.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698