summaryrefslogtreecommitdiff
path: root/chromium/services/network/throttling/network_conditions.h
blob: 2c08c88e9b586b81d9d4d1f1e4930a2b0e40be4e (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
// Copyright 2014 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 SERVICES_NETWORK_THROTTLING_NETWORK_CONDITIONS_H_
#define SERVICES_NETWORK_THROTTLING_NETWORK_CONDITIONS_H_

#include <string>
#include <vector>

#include "base/component_export.h"
#include "base/macros.h"

namespace network {

// NetworkConditions holds information about desired network conditions.
class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkConditions {
 public:
  NetworkConditions();
  ~NetworkConditions();

  explicit NetworkConditions(bool offline);
  NetworkConditions(bool offline,
                    double latency,
                    double download_throughput,
                    double upload_throughput);

  bool IsThrottling() const;

  bool offline() const { return offline_; }

  // These are 0 if the corresponding throttle is disabled, >0 otherwise.
  double latency() const { return latency_; }
  double download_throughput() const { return download_throughput_; }
  double upload_throughput() const { return upload_throughput_; }

 private:
  const bool offline_;
  const double latency_;
  const double download_throughput_;
  const double upload_throughput_;

  DISALLOW_COPY_AND_ASSIGN(NetworkConditions);
};

}  // namespace network

#endif  // SERVICES_NETWORK_THROTTLING_NETWORK_CONDITIONS_H_