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