summaryrefslogtreecommitdiffstats
path: root/net/base/external_estimate_provider.h
blob: bc029882d3ec0070abc2160fbbce834564670d26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_BASE_EXTERNAL_ESTIMATE_PROVIDER_H_
#define NET_BASE_EXTERNAL_ESTIMATE_PROVIDER_H_

#include <stdint.h>

#include "base/macros.h"
#include "base/time/time.h"
#include "net/base/net_export.h"

namespace net {

// Base class used by external providers such as operating system APIs to
// provide network quality estimates to NetworkQualityEstimator.
class NET_EXPORT ExternalEstimateProvider {
 public:
  class NET_EXPORT UpdatedEstimateDelegate {
   public:
    // Will be called when an updated estimate is available.
    virtual void OnUpdatedEstimateAvailable() = 0;

   protected:
    UpdatedEstimateDelegate() {}
    virtual ~UpdatedEstimateDelegate() {}

   private:
    DISALLOW_COPY_AND_ASSIGN(UpdatedEstimateDelegate);
  };

  ExternalEstimateProvider() {}
  virtual ~ExternalEstimateProvider() {}

  // Returns true if the estimated RTT duration is available, and sets |rtt|
  // to the estimate.
  virtual bool GetRTT(base::TimeDelta* rtt) const = 0;

  // Returns true if the estimated downstream throughput (in Kbps -- Kilobits
  // per second) is available, and sets |downstream_throughput_kbps| to the
  // estimate.
  virtual bool GetDownstreamThroughputKbps(
      int32_t* downstream_throughput_kbps) const = 0;

  // Returns true if the estimated upstream throughput (in Kbps -- Kilobits
  // per second) is available, and sets |upstream_throughput_kbps| to the
  // estimate.
  virtual bool GetUpstreamThroughputKbps(
      int32_t* upstream_throughput_kbps) const = 0;

  // Returns true if the time since network quality was last updated is
  // available, and sets |time_since_last_update| to that value.
  virtual bool GetTimeSinceLastUpdate(
      base::TimeDelta* time_since_last_update) const = 0;

  // Sets delegate that is notified when an updated estimate is available.
  // |delegate| should outlive |ExternalEstimateProvider|.
  virtual void SetUpdatedEstimateDelegate(
      UpdatedEstimateDelegate* delegate) = 0;

 private:
  DISALLOW_COPY_AND_ASSIGN(ExternalEstimateProvider);
};

}  // namespace net

#endif  // NET_BASE_EXTERNAL_ESTIMATE_PROVIDER_H_