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 NET_NQE_NETWORK_QUALITY_PROVIDER_H_ |
| 6 #define NET_NQE_NETWORK_QUALITY_PROVIDER_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/optional.h" |
| 14 #include "base/time/time.h" |
| 15 #include "net/base/net_export.h" |
| 16 #include "net/nqe/effective_connection_type.h" |
| 17 |
| 18 namespace net { |
| 19 |
| 20 class EffectiveConnectionTypeObserver; |
| 21 class RTTAndThroughputEstimatesObserver; |
| 22 |
| 23 // Provides simple interface to obtain the network quality, and to listen to |
| 24 // the changes in the network quality. |
| 25 class NET_EXPORT NetworkQualityProvider { |
| 26 public: |
| 27 virtual ~NetworkQualityProvider() {} |
| 28 |
| 29 // Returns the current effective connection type. The effective connection |
| 30 // type is computed by the network quality estimator at regular intervals and |
| 31 // at certain events (e.g., connection change). |
| 32 virtual EffectiveConnectionType GetEffectiveConnectionType() const = 0; |
| 33 |
| 34 // Adds |observer| to a list of effective connection type observers. |
| 35 // The observer must register and unregister itself on the same thread. |
| 36 // |observer| would be notified on the thread on which it registered. |
| 37 // |observer| would be notified of the current effective connection |
| 38 // type in the next message pump. |
| 39 virtual void AddEffectiveConnectionTypeObserver( |
| 40 EffectiveConnectionTypeObserver* observer) {} |
| 41 |
| 42 // Removes |observer| from a list of effective connection type observers. |
| 43 virtual void RemoveEffectiveConnectionTypeObserver( |
| 44 EffectiveConnectionTypeObserver* observer) {} |
| 45 |
| 46 // Returns the current HTTP RTT estimate. If the estimate is unavailable, |
| 47 // the returned optional value is null. |
| 48 virtual base::Optional<base::TimeDelta> GetHttpRTT() const; |
| 49 |
| 50 // Returns the current transport RTT estimate. If the estimate is |
| 51 // unavailable, the returned optional value is null. |
| 52 virtual base::Optional<base::TimeDelta> GetTransportRTT() const; |
| 53 |
| 54 // Returns the current downstream throughput estimate (in kilobits per |
| 55 // second). If the estimate is unavailable, the returned optional value is |
| 56 // null. |
| 57 virtual base::Optional<int32_t> GetDownstreamThroughputKbps() const; |
| 58 |
| 59 // Adds |observer| to the list of RTT and throughput estimate observers. |
| 60 // The observer must register and unregister itself on the same thread. |
| 61 // |observer| would be notified on the thread on which it registered. |
| 62 // |observer| would be notified of the current values in the next message |
| 63 // pump. |
| 64 virtual void AddRTTAndThroughputEstimatesObserver( |
| 65 RTTAndThroughputEstimatesObserver* observer) {} |
| 66 |
| 67 // Removes |observer| from the list of RTT and throughput estimate |
| 68 // observers. |
| 69 virtual void RemoveRTTAndThroughputEstimatesObserver( |
| 70 RTTAndThroughputEstimatesObserver* observer) {} |
| 71 |
| 72 protected: |
| 73 NetworkQualityProvider() {} |
| 74 |
| 75 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(NetworkQualityProvider); |
| 77 }; |
| 78 |
| 79 } // namespace net |
| 80 |
| 81 #endif // NET_NQE_NETWORK_QUALITY_PROVIDER_H_ |
OLD | NEW |