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. |
| 30 virtual EffectiveConnectionType GetEffectiveConnectionType() const = 0; |
| 31 |
| 32 // Adds |observer| to a list of effective connection type observers. |
| 33 virtual void AddEffectiveConnectionTypeObserver( |
| 34 EffectiveConnectionTypeObserver* observer) = 0; |
| 35 |
| 36 // Removes |observer| from a list of effective connection type observers. |
| 37 virtual void RemoveEffectiveConnectionTypeObserver( |
| 38 EffectiveConnectionTypeObserver* observer) = 0; |
| 39 |
| 40 // Returns the current HTTP RTT estimate. If the estimate is unavailable, |
| 41 // the returned optional value is null. |
| 42 virtual base::Optional<base::TimeDelta> GetHttpRTT() const; |
| 43 |
| 44 // Returns the current transport RTT estimate. If the estimate is |
| 45 // unavailable, the returned optional value is null. |
| 46 virtual base::Optional<base::TimeDelta> GetTransportRTT() const; |
| 47 |
| 48 // Returns the current downstream throughput estimate (in kilobits per |
| 49 // second). If the estimate is unavailable, the returned optional value is |
| 50 // null. |
| 51 virtual base::Optional<int32_t> GetDownstreamThroughputKbps() const; |
| 52 |
| 53 // Adds |observer| to the list of RTT and throughput estimate observers. |
| 54 // |observer| would be notified of the current RTT and throughput estimates |
| 55 // in the next message pump. |
| 56 virtual void AddRTTAndThroughputEstimatesObserver( |
| 57 RTTAndThroughputEstimatesObserver* observer) = 0; |
| 58 |
| 59 // Removes |observer| from the list of RTT and throughput estimate |
| 60 // observers. |
| 61 virtual void RemoveRTTAndThroughputEstimatesObserver( |
| 62 RTTAndThroughputEstimatesObserver* observer) = 0; |
| 63 |
| 64 protected: |
| 65 NetworkQualityProvider() {} |
| 66 |
| 67 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(NetworkQualityProvider); |
| 69 }; |
| 70 |
| 71 } // namespace net |
| 72 |
| 73 #endif // NET_NQE_NETWORK_QUALITY_PROVIDER_H_ |
OLD | NEW |