Index: chrome/browser/net/nqe/ui_network_quality_estimator_service.h |
diff --git a/chrome/browser/net/nqe/ui_network_quality_estimator_service.h b/chrome/browser/net/nqe/ui_network_quality_estimator_service.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7e9e04aee99331a66ceeaa57b328e6ada84d9910 |
--- /dev/null |
+++ b/chrome/browser/net/nqe/ui_network_quality_estimator_service.h |
@@ -0,0 +1,56 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ |
+#define CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ |
+ |
+#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/threading/thread_checker.h" |
+#include "components/keyed_service/core/keyed_service.h" |
+#include "net/nqe/network_quality_estimator.h" |
+ |
+class Profile; |
+ |
+namespace chrome_browser_net { |
mmenke
2016/07/20 17:11:33
The currently preferred style is not to use the ch
RyanSturm
2016/07/20 17:37:38
Done.
|
+ |
+// UI service to determine the current EffectiveConnectionType. |
+class UINetworkQualityEstimatorService : public KeyedService { |
+ public: |
+ explicit UINetworkQualityEstimatorService(Profile* profile); |
+ ~UINetworkQualityEstimatorService() override; |
+ |
+ // The current EffectiveConnectionType. |
+ net::NetworkQualityEstimator::EffectiveConnectionType |
+ GetEffectiveConnectionType() const; |
+ |
+ private: |
+ class IONetworkQualityObserver; |
+ |
+ // KeyedService implementation: |
+ void Shutdown() override; |
+ |
+ // Called when the EffectiveConnectionType has updated to |type|. |
+ // NetworkQualityEstimator::EffectiveConnectionType is an estimate of the |
+ // quality of the network that may differ from the actual network type |
+ // reported by NetworkchangeNotifier::GetConnectionType. |
+ void EffectiveConnectionTypeChanged( |
+ net::NetworkQualityEstimator::EffectiveConnectionType type); |
+ |
+ // The current EffectiveConnectionType. |
+ net::NetworkQualityEstimator::EffectiveConnectionType type_; |
+ |
+ // IO thread based observer that is owned by this service. Created on the UI |
+ // thread, but used and deleted on the IO thread. |
+ IONetworkQualityObserver* io_observer_; |
+ base::ThreadChecker thread_checker_; |
+ |
+ base::WeakPtrFactory<UINetworkQualityEstimatorService> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(UINetworkQualityEstimatorService); |
+}; |
+ |
+} // namespace chrome_browser_net |
+ |
+#endif // CHROME_BROWSER_NET_NQE_UI_NETWORK_QUALITY_ESTIMATOR_SERVICE_H_ |