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

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

Issue 2491703003: NQE: Notify observer as soon as it is added (Closed)
Patch Set: ryansturm comments Created 4 years, 1 month 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 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 19 matching lines...) Expand all
30 : public KeyedService, 30 : public KeyedService,
31 public net::NetworkQualityEstimator::NetworkQualityProvider { 31 public net::NetworkQualityEstimator::NetworkQualityProvider {
32 public: 32 public:
33 explicit UINetworkQualityEstimatorService(Profile* profile); 33 explicit UINetworkQualityEstimatorService(Profile* profile);
34 ~UINetworkQualityEstimatorService() override; 34 ~UINetworkQualityEstimatorService() override;
35 35
36 // NetworkQualityProvider implementation: 36 // NetworkQualityProvider implementation:
37 // Must be called on the UI thread. 37 // Must be called on the UI thread.
38 net::EffectiveConnectionType GetEffectiveConnectionType() const override; 38 net::EffectiveConnectionType GetEffectiveConnectionType() const override;
39 // Must be called on the UI thread. |observer| will be notified on the UI 39 // Must be called on the UI thread. |observer| will be notified on the UI
40 // thread. 40 // thread. |observer| would be notified of the current effective connection
41 // type in the next message pump, if it is still registered as an observer.
41 void AddEffectiveConnectionTypeObserver( 42 void AddEffectiveConnectionTypeObserver(
42 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer) 43 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer)
43 override; 44 override;
44 // Must be called on the UI thread. 45 // Must be called on the UI thread.
45 void RemoveEffectiveConnectionTypeObserver( 46 void RemoveEffectiveConnectionTypeObserver(
46 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer) 47 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer)
47 override; 48 override;
48 49
49 // Registers the profile-specific network quality estimator prefs. 50 // Registers the profile-specific network quality estimator prefs.
50 static void RegisterProfilePrefs(PrefRegistrySimple* registry); 51 static void RegisterProfilePrefs(PrefRegistrySimple* registry);
51 52
52 // Clear the network quality estimator prefs. 53 // Clear the network quality estimator prefs.
53 void ClearPrefs(); 54 void ClearPrefs();
54 55
55 // Tests can manually set EffectiveConnectionType, but browser tests should 56 // Tests can manually set EffectiveConnectionType, but browser tests should
56 // expect that the EffectiveConnectionType could change. 57 // expect that the EffectiveConnectionType could change.
57 void SetEffectiveConnectionTypeForTesting(net::EffectiveConnectionType type); 58 void SetEffectiveConnectionTypeForTesting(net::EffectiveConnectionType type);
58 59
59 // Reads the prefs from the disk, parses them into a map of NetworkIDs and 60 // Reads the prefs from the disk, parses them into a map of NetworkIDs and
60 // CachedNetworkQualities, and returns the map. 61 // CachedNetworkQualities, and returns the map.
61 std::map<net::nqe::internal::NetworkID, 62 std::map<net::nqe::internal::NetworkID,
62 net::nqe::internal::CachedNetworkQuality> 63 net::nqe::internal::CachedNetworkQuality>
63 ForceReadPrefsForTesting() const; 64 ForceReadPrefsForTesting() const;
64 65
65 private: 66 private:
66 class IONetworkQualityObserver; 67 class IONetworkQualityObserver;
67 68
69 // Notifies |observer| of the current effective connection type if |observer|
70 // is still registered as an observer.
71 void NotifyEffectiveConnectionTypeObserverIfPresent(
72 net::NetworkQualityEstimator::EffectiveConnectionTypeObserver* observer)
73 const;
74
68 // KeyedService implementation: 75 // KeyedService implementation:
69 void Shutdown() override; 76 void Shutdown() override;
70 77
71 // Called when the EffectiveConnectionType has updated to |type|. 78 // Called when the EffectiveConnectionType has updated to |type|.
72 // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the 79 // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the
73 // quality of the network that may differ from the actual network type 80 // quality of the network that may differ from the actual network type
74 // reported by NetworkchangeNotifier::GetConnectionType. 81 // reported by NetworkchangeNotifier::GetConnectionType.
75 void EffectiveConnectionTypeChanged(net::EffectiveConnectionType type); 82 void EffectiveConnectionTypeChanged(net::EffectiveConnectionType type);
76 83
77 // The current EffectiveConnectionType. 84 // The current EffectiveConnectionType.
(...skipping 11 matching lines...) Expand all
89 // Prefs manager that is owned by this service. Created on the UI thread, but 96 // Prefs manager that is owned by this service. Created on the UI thread, but
90 // used and deleted on the IO thread. 97 // used and deleted on the IO thread.
91 std::unique_ptr<net::NetworkQualitiesPrefsManager> prefs_manager_; 98 std::unique_ptr<net::NetworkQualitiesPrefsManager> prefs_manager_;
92 99
93 base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_; 100 base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_;
94 101
95 DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService); 102 DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService);
96 }; 103 };
97 104
98 #endif // CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ 105 #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') | net/nqe/network_quality_estimator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698