| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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_BASE_EXTERNAL_ESTIMATE_PROVIDER_H_ | |
| 6 #define NET_BASE_EXTERNAL_ESTIMATE_PROVIDER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/time/time.h" | |
| 12 #include "net/base/net_export.h" | |
| 13 | |
| 14 namespace net { | |
| 15 | |
| 16 // Base class used by external providers such as operating system APIs to | |
| 17 // provide network quality estimates to NetworkQualityEstimator. | |
| 18 class NET_EXPORT ExternalEstimateProvider { | |
| 19 public: | |
| 20 class NET_EXPORT UpdatedEstimateDelegate { | |
| 21 public: | |
| 22 // Will be called when an updated estimate is available. | |
| 23 virtual void OnUpdatedEstimateAvailable() = 0; | |
| 24 | |
| 25 protected: | |
| 26 UpdatedEstimateDelegate() {} | |
| 27 virtual ~UpdatedEstimateDelegate() {} | |
| 28 | |
| 29 private: | |
| 30 DISALLOW_COPY_AND_ASSIGN(UpdatedEstimateDelegate); | |
| 31 }; | |
| 32 | |
| 33 ExternalEstimateProvider() {} | |
| 34 virtual ~ExternalEstimateProvider() {} | |
| 35 | |
| 36 // Returns true if the estimated RTT duration is available, and sets |rtt| | |
| 37 // to the estimate. | |
| 38 virtual bool GetRTT(base::TimeDelta* rtt) const = 0; | |
| 39 | |
| 40 // Returns true if the estimated downstream throughput (in Kbps -- Kilobits | |
| 41 // per second) is available, and sets |downstream_throughput_kbps| to the | |
| 42 // estimate. | |
| 43 virtual bool GetDownstreamThroughputKbps( | |
| 44 int32_t* downstream_throughput_kbps) const = 0; | |
| 45 | |
| 46 // Returns true if the estimated upstream throughput (in Kbps -- Kilobits | |
| 47 // per second) is available, and sets |upstream_throughput_kbps| to the | |
| 48 // estimate. | |
| 49 virtual bool GetUpstreamThroughputKbps( | |
| 50 int32_t* upstream_throughput_kbps) const = 0; | |
| 51 | |
| 52 // Returns true if the time since network quality was last updated is | |
| 53 // available, and sets |time_since_last_update| to that value. | |
| 54 virtual bool GetTimeSinceLastUpdate( | |
| 55 base::TimeDelta* time_since_last_update) const = 0; | |
| 56 | |
| 57 // Sets delegate that is notified when an updated estimate is available. | |
| 58 // |delegate| should outlive |ExternalEstimateProvider|. | |
| 59 virtual void SetUpdatedEstimateDelegate( | |
| 60 UpdatedEstimateDelegate* delegate) = 0; | |
| 61 | |
| 62 // Requests an updated network quality estimate from the external estimate | |
| 63 // provider. | |
| 64 virtual void Update() const = 0; | |
| 65 | |
| 66 private: | |
| 67 DISALLOW_COPY_AND_ASSIGN(ExternalEstimateProvider); | |
| 68 }; | |
| 69 | |
| 70 } // namespace net | |
| 71 | |
| 72 #endif // NET_BASE_EXTERNAL_ESTIMATE_PROVIDER_H_ | |
| OLD | NEW |