Chromium Code Reviews| 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..795e6b0340e38af21f99e9a4b4ec521b537ab5fb |
| --- /dev/null |
| +++ b/chrome/browser/net/nqe/ui_network_quality_estimator_service.h |
| @@ -0,0 +1,62 @@ |
| +// 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 <memory> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "components/keyed_service/core/keyed_service.h" |
| +#include "net/nqe/network_quality_estimator.h" |
| + |
| +class Profile; |
| + |
| +namespace chrome_browser_net { |
| + |
| +// UI service to determine the current EffectiveConnectionType. |
| +class UINetworkQualityEstimatorService : public KeyedService { |
| + public: |
| + explicit UINetworkQualityEstimatorService(Profile* profile); |
| + ~UINetworkQualityEstimatorService() override; |
| + |
| + // KeyedService implementation: |
| + void Shutdown() override; |
| + |
| + // Called when the EffectiveConnectionType has updated to |type|. |
|
mmenke
2016/07/14 19:10:12
May want to mention NCN::GetConnectionType, any ho
RyanSturm
2016/07/14 21:42:12
Done.
|
| + void EffectiveConnectionTypeChanged( |
| + net::NetworkQualityEstimator::EffectiveConnectionType type); |
|
mmenke
2016/07/14 19:10:12
methods that are only called by inner classes (ION
RyanSturm
2016/07/14 21:42:12
Done.
|
| + |
| + // Creates |io_observer_|, and posts a task to initialize it. |
|
mmenke
2016/07/14 19:10:12
See comment about getting rid of this. More gener
RyanSturm
2016/07/14 21:42:12
Done.
|
| + void Initialize( |
| + const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| + const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| + |
| + // The current EffectiveConnectionType. |
| + net::NetworkQualityEstimator::EffectiveConnectionType type() const; |
|
mmenke
2016/07/14 19:10:12
Since this isn't inlined, GetType, maybe?
RyanSturm
2016/07/14 21:42:12
Done.
|
| + |
| + private: |
| + class IONetworkQualityObserver; |
| + |
| + // The current EffectiveConnectionType. |
| + net::NetworkQualityEstimator::EffectiveConnectionType type_; |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| + |
| + // 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_ |