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

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

Issue 2593243003: Add network quality change events to net log (Closed)
Patch Set: ps Created 3 years, 11 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 #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>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "base/threading/thread_checker.h" 20 #include "base/threading/thread_checker.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "net/base/net_export.h" 22 #include "net/base/net_export.h"
23 #include "net/base/network_change_notifier.h" 23 #include "net/base/network_change_notifier.h"
24 #include "net/log/net_log_with_source.h"
24 #include "net/nqe/cached_network_quality.h" 25 #include "net/nqe/cached_network_quality.h"
25 #include "net/nqe/effective_connection_type.h" 26 #include "net/nqe/effective_connection_type.h"
26 #include "net/nqe/external_estimate_provider.h" 27 #include "net/nqe/external_estimate_provider.h"
27 #include "net/nqe/network_id.h" 28 #include "net/nqe/network_id.h"
28 #include "net/nqe/network_quality.h" 29 #include "net/nqe/network_quality.h"
29 #include "net/nqe/network_quality_observation.h" 30 #include "net/nqe/network_quality_observation.h"
30 #include "net/nqe/network_quality_observation_source.h" 31 #include "net/nqe/network_quality_observation_source.h"
31 #include "net/nqe/network_quality_store.h" 32 #include "net/nqe/network_quality_store.h"
32 #include "net/nqe/observation_buffer.h" 33 #include "net/nqe/observation_buffer.h"
33 #include "net/socket/socket_performance_watcher_factory.h" 34 #include "net/socket/socket_performance_watcher_factory.h"
34 35
35 namespace base { 36 namespace base {
36 class TickClock; 37 class TickClock;
37 } // namespace base 38 } // namespace base
38 39
39 namespace net { 40 namespace net {
40 41
42 class NetLog;
43
41 namespace nqe { 44 namespace nqe {
42 namespace internal { 45 namespace internal {
43 class ThroughputAnalyzer; 46 class ThroughputAnalyzer;
44 } 47 }
45 } 48 }
46 49
47 class URLRequest; 50 class URLRequest;
48 51
49 // NetworkQualityEstimator provides network quality estimates (quality of the 52 // NetworkQualityEstimator provides network quality estimates (quality of the
50 // full paths to all origins that have been connected to). 53 // full paths to all origins that have been connected to).
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 protected: 172 protected:
170 NetworkQualityProvider() {} 173 NetworkQualityProvider() {}
171 174
172 private: 175 private:
173 DISALLOW_COPY_AND_ASSIGN(NetworkQualityProvider); 176 DISALLOW_COPY_AND_ASSIGN(NetworkQualityProvider);
174 }; 177 };
175 178
176 // Creates a new NetworkQualityEstimator. 179 // Creates a new NetworkQualityEstimator.
177 // |variation_params| is the map containing all field trial parameters 180 // |variation_params| is the map containing all field trial parameters
178 // related to NetworkQualityEstimator field trial. 181 // related to NetworkQualityEstimator field trial.
179 // |external_estimates_provider| may be NULL. 182 // |external_estimates_provider| may be NULL. |net_log| is guaranteed to be
RyanSturm 2017/01/10 16:22:37 Can you rephrase this to something like "The embed
tbansal1 2017/01/10 18:27:53 Done.
183 // non-null.
180 NetworkQualityEstimator( 184 NetworkQualityEstimator(
181 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider, 185 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider,
182 const std::map<std::string, std::string>& variation_params); 186 const std::map<std::string, std::string>& variation_params,
187 NetLog* net_log);
183 188
184 // Construct a NetworkQualityEstimator instance allowing for test 189 // Construct a NetworkQualityEstimator instance allowing for test
185 // configuration. Registers for network type change notifications so estimates 190 // configuration. Registers for network type change notifications so estimates
186 // can be kept network specific. 191 // can be kept network specific.
187 // |external_estimates_provider| may be NULL. 192 // |external_estimates_provider| may be NULL.
188 // |variation_params| is the map containing all field trial parameters for the 193 // |variation_params| is the map containing all field trial parameters for the
189 // network quality estimator field trial. 194 // network quality estimator field trial.
190 // |use_local_host_requests_for_tests| should only be true when testing 195 // |use_local_host_requests_for_tests| should only be true when testing
191 // against local HTTP server and allows the requests to local host to be 196 // against local HTTP server and allows the requests to local host to be
192 // used for network quality estimation. 197 // used for network quality estimation.
193 // |use_smaller_responses_for_tests| should only be true when testing. 198 // |use_smaller_responses_for_tests| should only be true when testing.
194 // Allows the responses smaller than |kMinTransferSizeInBits| to be used for 199 // Allows the responses smaller than |kMinTransferSizeInBits| to be used for
195 // network quality estimation. 200 // network quality estimation. |net_log| is guaranteed to be non-null.
RyanSturm 2017/01/10 16:22:37 same as above comment
tbansal1 2017/01/10 18:27:53 Done.
196 NetworkQualityEstimator( 201 NetworkQualityEstimator(
197 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider, 202 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider,
198 const std::map<std::string, std::string>& variation_params, 203 const std::map<std::string, std::string>& variation_params,
199 bool use_local_host_requests_for_tests, 204 bool use_local_host_requests_for_tests,
200 bool use_smaller_responses_for_tests); 205 bool use_smaller_responses_for_tests,
206 NetLog* net_log);
201 207
202 ~NetworkQualityEstimator() override; 208 ~NetworkQualityEstimator() override;
203 209
204 // Returns the last computed effective type of the current connection. The 210 // Returns the last computed effective type of the current connection. The
205 // effective connection type is computed by the network quality estimator at 211 // effective connection type is computed by the network quality estimator at
206 // regular intervals and at certain events (e.g., connection change). 212 // regular intervals and at certain events (e.g., connection change).
207 // Virtualized for testing. 213 // Virtualized for testing.
208 virtual EffectiveConnectionType GetEffectiveConnectionType() const; 214 virtual EffectiveConnectionType GetEffectiveConnectionType() const;
209 215
210 // Returns the effective type of the current connection based on only the 216 // Returns the effective type of the current connection based on only the
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 nqe::internal::CachedNetworkQuality> read_prefs); 304 nqe::internal::CachedNetworkQuality> read_prefs);
299 305
300 protected: 306 protected:
301 // A protected constructor for testing that allows setting the value of 307 // A protected constructor for testing that allows setting the value of
302 // |add_default_platform_observations_|. 308 // |add_default_platform_observations_|.
303 NetworkQualityEstimator( 309 NetworkQualityEstimator(
304 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider, 310 std::unique_ptr<ExternalEstimateProvider> external_estimates_provider,
305 const std::map<std::string, std::string>& variation_params, 311 const std::map<std::string, std::string>& variation_params,
306 bool use_local_host_requests_for_tests, 312 bool use_local_host_requests_for_tests,
307 bool use_smaller_responses_for_tests, 313 bool use_smaller_responses_for_tests,
308 bool add_default_platform_observations); 314 bool add_default_platform_observations,
315 const NetLogWithSource& net_log);
309 316
310 // NetworkChangeNotifier::ConnectionTypeObserver implementation: 317 // NetworkChangeNotifier::ConnectionTypeObserver implementation:
311 void OnConnectionTypeChanged( 318 void OnConnectionTypeChanged(
312 NetworkChangeNotifier::ConnectionType type) override; 319 NetworkChangeNotifier::ConnectionType type) override;
313 320
314 // ExternalEstimateProvider::UpdatedEstimateObserver implementation. 321 // ExternalEstimateProvider::UpdatedEstimateObserver implementation.
315 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt, 322 void OnUpdatedEstimateAvailable(const base::TimeDelta& rtt,
316 int32_t downstream_throughput_kbps, 323 int32_t downstream_throughput_kbps,
317 int32_t upstream_throughput_kbps) override; 324 int32_t upstream_throughput_kbps) override;
318 325
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 void NotifyObserversOfThroughput(const ThroughputObservation& observation); 505 void NotifyObserversOfThroughput(const ThroughputObservation& observation);
499 506
500 // Returns true only if the |request| can be used for RTT estimation. 507 // Returns true only if the |request| can be used for RTT estimation.
501 bool RequestProvidesRTTObservation(const URLRequest& request) const; 508 bool RequestProvidesRTTObservation(const URLRequest& request) const;
502 509
503 // Recomputes effective connection type, if it was computed more than the 510 // Recomputes effective connection type, if it was computed more than the
504 // specified duration ago, or if there has been a connection change recently. 511 // specified duration ago, or if there has been a connection change recently.
505 void MaybeComputeEffectiveConnectionType(); 512 void MaybeComputeEffectiveConnectionType();
506 513
507 // Notifies observers of a change in effective connection type. 514 // Notifies observers of a change in effective connection type.
508 void NotifyObserversOfEffectiveConnectionTypeChanged(); 515 // |http_rtt| is the estimate of the HTTP RTT. |transport_rtt| is the estimate
516 // of the transport RTT. |downstream_throughput_kbps| is the estimate of the
RyanSturm 2017/01/10 16:22:37 units for the RTTs (msec)
tbansal1 2017/01/10 18:27:53 RTTs are in base::TimeDelta. So, units are not req
517 // downstream throughput (in kilobits per second).
518 void NotifyObserversOfEffectiveConnectionTypeChanged(
519 base::TimeDelta http_rtt,
520 base::TimeDelta transport_rtt,
521 int32_t downstream_throughput_kbps);
509 522
510 // Notifies the observers of RTT or throughput estimates computation. 523 // Notifies the observers of RTT or throughput estimates computation.
511 void NotifyObserversOfRTTOrThroughputComputed() const; 524 void NotifyObserversOfRTTOrThroughputComputed() const;
512 525
513 // Notifies |observer| of the current effective connection type if |observer| 526 // Notifies |observer| of the current effective connection type if |observer|
514 // is still registered as an observer. 527 // is still registered as an observer.
515 void NotifyEffectiveConnectionTypeObserverIfPresent( 528 void NotifyEffectiveConnectionTypeObserverIfPresent(
516 EffectiveConnectionTypeObserver* observer) const; 529 EffectiveConnectionTypeObserver* observer) const;
517 530
518 // Notifies |observer| of the current RTT and throughput if |observer| is 531 // Notifies |observer| of the current RTT and throughput if |observer| is
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 std::unique_ptr<nqe::internal::NetworkQualityStore> network_quality_store_; 747 std::unique_ptr<nqe::internal::NetworkQualityStore> network_quality_store_;
735 748
736 // True if effective connection type value has been forced via variation 749 // True if effective connection type value has been forced via variation
737 // parameters. If set to true, GetEffectiveConnectionType() will always return 750 // parameters. If set to true, GetEffectiveConnectionType() will always return
738 // |forced_effective_connection_type_|. 751 // |forced_effective_connection_type_|.
739 const bool forced_effective_connection_type_set_; 752 const bool forced_effective_connection_type_set_;
740 const EffectiveConnectionType forced_effective_connection_type_; 753 const EffectiveConnectionType forced_effective_connection_type_;
741 754
742 base::ThreadChecker thread_checker_; 755 base::ThreadChecker thread_checker_;
743 756
757 NetLogWithSource net_log_;
758
744 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; 759 base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
745 760
746 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); 761 DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
747 }; 762 };
748 763
749 } // namespace net 764 } // namespace net
750 765
751 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ 766 #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698