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.
5 #ifndef NET_BASE_EXTERNAL_ESTIMATE_PROVIDER_H_
6 #define NET_BASE_EXTERNAL_ESTIMATE_PROVIDER_H_
10 #include "base/macros.h"
11 #include "base/time/time.h"
12 #include "net/base/net_export.h"
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
{
20 class NET_EXPORT UpdatedEstimateDelegate
{
22 // Will be called when an updated estimate is available.
23 virtual void OnUpdatedEstimateAvailable() = 0;
26 UpdatedEstimateDelegate() {}
27 virtual ~UpdatedEstimateDelegate() {}
30 DISALLOW_COPY_AND_ASSIGN(UpdatedEstimateDelegate
);
33 ExternalEstimateProvider() {}
34 virtual ~ExternalEstimateProvider() {}
36 // Returns true if the estimated RTT duration is available, and sets |rtt|
38 virtual bool GetRTT(base::TimeDelta
* rtt
) const = 0;
40 // Returns true if the estimated downstream throughput (in Kbps -- Kilobits
41 // per second) is available, and sets |downstream_throughput_kbps| to the
43 virtual bool GetDownstreamThroughputKbps(
44 int32_t* downstream_throughput_kbps
) const = 0;
46 // Returns true if the estimated upstream throughput (in Kbps -- Kilobits
47 // per second) is available, and sets |upstream_throughput_kbps| to the
49 virtual bool GetUpstreamThroughputKbps(
50 int32_t* upstream_throughput_kbps
) const = 0;
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;
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;
63 DISALLOW_COPY_AND_ASSIGN(ExternalEstimateProvider
);
68 #endif // NET_BASE_EXTERNAL_ESTIMATE_PROVIDER_H_