OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_NET_NETWORK_QUALITY_OBSERVER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_NET_NETWORK_QUALITY_OBSERVER_IMPL_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <memory> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "base/threading/thread_checker.h" |
| 14 #include "content/common/content_export.h" |
| 15 #include "content/public/browser/network_quality_observer_factory.h" |
| 16 #include "net/nqe/network_quality.h" |
| 17 #include "net/nqe/network_quality_estimator.h" |
| 18 |
| 19 namespace content { |
| 20 |
| 21 // Listens for changes to the network quality and manages sending updates to |
| 22 // each RenderProcess via mojo. |
| 23 class CONTENT_EXPORT NetworkQualityObserverImpl |
| 24 : public net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver { |
| 25 public: |
| 26 explicit NetworkQualityObserverImpl( |
| 27 net::NetworkQualityEstimator* network_quality_estimator); |
| 28 |
| 29 ~NetworkQualityObserverImpl() override; |
| 30 |
| 31 private: |
| 32 class UiThreadObserver; |
| 33 |
| 34 // net::NetworkQualityEstimator::RTTAndThroughputEstimatesObserver |
| 35 // implementation: |
| 36 void OnRTTOrThroughputEstimatesComputed( |
| 37 base::TimeDelta http_rtt, |
| 38 base::TimeDelta transport_rtt, |
| 39 int32_t downstream_throughput_kbps) override; |
| 40 |
| 41 // |ui_thread_observer_| is owned by |this|, and interacts with |
| 42 // the render processes. It is created on the IO thread but afterwards, should |
| 43 // only be accessed on the UI thread. |ui_thread_observer_| is guaranteed to |
| 44 // be non-null during the lifetime of |this|. |
| 45 std::unique_ptr<UiThreadObserver> ui_thread_observer_; |
| 46 |
| 47 // |network_quality_estimator_| is guaranteed to be non-null during the |
| 48 // lifetime of |this|. |
| 49 net::NetworkQualityEstimator* network_quality_estimator_; |
| 50 |
| 51 // The network quality when the |ui_thread_observer_| was last notified. |
| 52 net::nqe::internal::NetworkQuality last_notified_network_quality_; |
| 53 |
| 54 base::ThreadChecker thread_checker_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(NetworkQualityObserverImpl); |
| 57 }; |
| 58 |
| 59 } // namespace content |
| 60 |
| 61 #endif // CONTENT_BROWSER_NET_NETWORK_QUALITY_OBSERVER_IMPL_H_ |
OLD | NEW |