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

Side by Side Diff: chrome/browser/net/nqe/ui_network_quality_estimator_service.h

Issue 2717153002: NQE: Plumb RTT and throughput estimates to the UI thread (Closed)
Patch Set: Rebase, Fix more compilation errors 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/net/nqe/ui_network_quality_estimator_service.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ 5 #ifndef CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_
6 #define CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ 6 #define CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 29 matching lines...) Expand all
40 // thread. |observer| would be notified of the current effective connection 40 // thread. |observer| would be notified of the current effective connection
41 // type in the next message pump. 41 // type in the next message pump.
42 void AddEffectiveConnectionTypeObserver( 42 void AddEffectiveConnectionTypeObserver(
43 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer) 43 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer)
44 override; 44 override;
45 // Must be called on the UI thread. 45 // Must be called on the UI thread.
46 void RemoveEffectiveConnectionTypeObserver( 46 void RemoveEffectiveConnectionTypeObserver(
47 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer) 47 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer)
48 override; 48 override;
49 49
50 // Must be called on the UI thread. |observer| will be notified on the UI
51 // thread. |observer| would be notified of the changes in the HTTP RTT,
52 // transport RTT or throughput. |observer| would be notified of the current
53 // values in the next message pump.
54 void AddRTTAndThroughputEstimatesObserver(
55 net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver* observer)
56 override;
57
58 // Removes |observer| from the list of RTT and throughput estimate observers.
59 // Must be called on the UI thread.
60 void RemoveRTTAndThroughputEstimatesObserver(
61 net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver* observer)
62 override;
63
50 // Registers the profile-specific network quality estimator prefs. 64 // Registers the profile-specific network quality estimator prefs.
51 static void RegisterProfilePrefs(PrefRegistrySimple* registry); 65 static void RegisterProfilePrefs(PrefRegistrySimple* registry);
52 66
53 // Clear the network quality estimator prefs. 67 // Clear the network quality estimator prefs.
54 void ClearPrefs(); 68 void ClearPrefs();
55 69
56 // Tests can manually set EffectiveConnectionType, but browser tests should 70 // Tests can manually set EffectiveConnectionType, but browser tests should
57 // expect that the EffectiveConnectionType could change. 71 // expect that the EffectiveConnectionType could change.
58 void SetEffectiveConnectionTypeForTesting(net::EffectiveConnectionType type); 72 void SetEffectiveConnectionTypeForTesting(net::EffectiveConnectionType type);
59 73
60 // Reads the prefs from the disk, parses them into a map of NetworkIDs and 74 // Reads the prefs from the disk, parses them into a map of NetworkIDs and
61 // CachedNetworkQualities, and returns the map. 75 // CachedNetworkQualities, and returns the map.
62 std::map<net::nqe::internal::NetworkID, 76 std::map<net::nqe::internal::NetworkID,
63 net::nqe::internal::CachedNetworkQuality> 77 net::nqe::internal::CachedNetworkQuality>
64 ForceReadPrefsForTesting() const; 78 ForceReadPrefsForTesting() const;
65 79
66 private: 80 private:
67 class IONetworkQualityObserver; 81 class IONetworkQualityObserver;
68 82
69 // Notifies |observer| of the current effective connection type if |observer| 83 // Notifies |observer| of the current effective connection type if |observer|
70 // is still registered as an observer. 84 // is still registered as an observer.
71 void NotifyEffectiveConnectionTypeObserverIfPresent( 85 void NotifyEffectiveConnectionTypeObserverIfPresent(
72 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer) 86 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer)
73 const; 87 const;
74 88
89 // Notifies |observer| of the current effective connection type if |observer|
90 // is still registered as an observer.
91 void NotifyRTTAndThroughputObserverIfPresent(
92 net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver* observer)
93 const;
94
75 // KeyedService implementation: 95 // KeyedService implementation:
76 void Shutdown() override; 96 void Shutdown() override;
77 97
78 // Called when the EffectiveConnectionType has updated to |type|. 98 // Called when the EffectiveConnectionType has updated to |type|.
79 // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the 99 // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the
80 // quality of the network that may differ from the actual network type 100 // quality of the network that may differ from the actual network type
81 // reported by NetworkchangeNotifier::GetConnectionType. 101 // reported by NetworkchangeNotifier::GetConnectionType.
82 void EffectiveConnectionTypeChanged(net::EffectiveConnectionType type); 102 void EffectiveConnectionTypeChanged(net::EffectiveConnectionType type);
83 103
104 // Called when the estimated HTTP RTT, estimated transport RTT or estimated
105 // downstream throughput is computed.
106 void RTTOrThroughputComputed(base::TimeDelta http_rtt,
107 base::TimeDelta transport_rtt,
108 int32_t downstream_throughput_kbps);
109
84 // The current EffectiveConnectionType. 110 // The current EffectiveConnectionType.
85 net::EffectiveConnectionType type_; 111 net::EffectiveConnectionType type_;
86 112
113 // Current network quality metrics.
114 base::TimeDelta http_rtt_;
115 base::TimeDelta transport_rtt_;
116 int32_t downstream_throughput_kbps_;
117
87 // IO thread based observer that is owned by this service. Created on the UI 118 // IO thread based observer that is owned by this service. Created on the UI
88 // thread, but used and deleted on the IO thread. 119 // thread, but used and deleted on the IO thread.
89 std::unique_ptr<IONetworkQualityObserver> io_observer_; 120 std::unique_ptr<IONetworkQualityObserver> io_observer_;
90 121
91 // Observer list for changes in effective connection type. 122 // Observer list for changes in effective connection type.
92 base::ObserverList< 123 base::ObserverList<
93 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver> 124 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver>
94 effective_connection_type_observer_list_; 125 effective_connection_type_observer_list_;
95 126
127 // Observer list for changes in RTT or throughput values.
128 base::ObserverList<
129 net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver>
130 rtt_throughput_observer_list_;
131
96 // Prefs manager that is owned by this service. Created on the UI thread, but 132 // Prefs manager that is owned by this service. Created on the UI thread, but
97 // used and deleted on the IO thread. 133 // used and deleted on the IO thread.
98 std::unique_ptr<net::NetworkQualitiesPrefsManager> prefs_manager_; 134 std::unique_ptr<net::NetworkQualitiesPrefsManager> prefs_manager_;
99 135
100 base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_; 136 base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_;
101 137
102 DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService); 138 DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService);
103 }; 139 };
104 140
105 #endif // CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ 141 #endif // CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/nqe/ui_network_quality_estimator_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698