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

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

Issue 2369673004: Wire NQE Prefs to Profile (Closed)
Patch Set: ps Created 4 years, 2 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 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 "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "components/keyed_service/core/keyed_service.h" 10 #include "components/keyed_service/core/keyed_service.h"
11 #include "net/nqe/effective_connection_type.h" 11 #include "net/nqe/effective_connection_type.h"
12 #include "net/nqe/network_quality_estimator.h" 12 #include "net/nqe/network_quality_estimator.h"
13 13
14 class PrefRegistrySimple;
15 class Profile;
16
17 namespace net {
18 class NetworkQualitiesPrefsManager;
19 }
20
14 // UI service to determine the current EffectiveConnectionType. 21 // UI service to determine the current EffectiveConnectionType.
15 class UINetworkQualityEstimatorService 22 class UINetworkQualityEstimatorService
16 : public KeyedService, 23 : public KeyedService,
17 public net::NetworkQualityEstimator::NetworkQualityProvider { 24 public net::NetworkQualityEstimator::NetworkQualityProvider {
18 public: 25 public:
19 UINetworkQualityEstimatorService(); 26 explicit UINetworkQualityEstimatorService(Profile* profile);
20 ~UINetworkQualityEstimatorService() override; 27 ~UINetworkQualityEstimatorService() override;
21 28
29 // Registers the profile-specific network quality estimator prefs.
30 static void RegisterProfilePrefs(PrefRegistrySimple* registry);
31
22 // The current EffectiveConnectionType. 32 // The current EffectiveConnectionType.
23 net::EffectiveConnectionType GetEffectiveConnectionType() const override; 33 net::EffectiveConnectionType GetEffectiveConnectionType() const override;
24 34
25 // Tests can manually set EffectiveConnectionType, but browser tests should 35 // Tests can manually set EffectiveConnectionType, but browser tests should
26 // expect that the EffectiveConnectionType could change. 36 // expect that the EffectiveConnectionType could change.
27 void SetEffectiveConnectionTypeForTesting(net::EffectiveConnectionType type); 37 void SetEffectiveConnectionTypeForTesting(net::EffectiveConnectionType type);
28 38
29 private: 39 private:
30 class IONetworkQualityObserver; 40 class IONetworkQualityObserver;
31 41
32 // KeyedService implementation: 42 // KeyedService implementation:
33 void Shutdown() override; 43 void Shutdown() override;
34 44
35 // Called when the EffectiveConnectionType has updated to |type|. 45 // Called when the EffectiveConnectionType has updated to |type|.
36 // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the 46 // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the
37 // quality of the network that may differ from the actual network type 47 // quality of the network that may differ from the actual network type
38 // reported by NetworkchangeNotifier::GetConnectionType. 48 // reported by NetworkchangeNotifier::GetConnectionType.
39 void EffectiveConnectionTypeChanged(net::EffectiveConnectionType type); 49 void EffectiveConnectionTypeChanged(net::EffectiveConnectionType type);
40 50
41 // The current EffectiveConnectionType. 51 // The current EffectiveConnectionType.
42 net::EffectiveConnectionType type_; 52 net::EffectiveConnectionType type_;
43 53
44 // IO thread based observer that is owned by this service. Created on the UI 54 // IO thread based observer that is owned by this service. Created on the UI
45 // thread, but used and deleted on the IO thread. 55 // thread, but used and deleted on the IO thread.
46 IONetworkQualityObserver* io_observer_; 56 IONetworkQualityObserver* io_observer_;
47 57
58 // Prefs manager that is owned by this service. Created on the UI thread, but
59 // used and deleted on the IO thread.
60 net::NetworkQualitiesPrefsManager* prefs_manager_;
61
48 base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_; 62 base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_;
49 63
50 DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService); 64 DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService);
51 }; 65 };
52 66
53 #endif // CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ 67 #endif // CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698