Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / net / quic / crypto / cached_network_parameters.h
blob5f22070dc4f75f8156916dfdf1aedb11ac2d842f
1 // Copyright (c) 2014 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_QUIC_CRYPTO_CACHED_NETWORK_PARAMETERS_H_
6 #define NET_QUIC_CRYPTO_CACHED_NETWORK_PARAMETERS_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/strings/string_piece.h"
12 #include "net/base/net_export.h"
14 namespace net {
16 // TODO(rtenneti): sync with server more rationally.
17 // CachedNetworkParameters contains data that can be used to choose appropriate
18 // connection parameters (initial RTT, initial CWND, etc.) in new connections.
19 class NET_EXPORT_PRIVATE CachedNetworkParameters {
20 public:
21 // Describes the state of the connection during which the supplied network
22 // parameters were calculated.
23 enum PreviousConnectionState {
24 SLOW_START = 0,
25 CONGESTION_AVOIDANCE = 1,
28 CachedNetworkParameters();
29 ~CachedNetworkParameters();
31 bool operator==(const CachedNetworkParameters& other) const;
32 bool operator!=(const CachedNetworkParameters& other) const;
34 std::string serving_region() const {
35 return serving_region_;
37 void set_serving_region(base::StringPiece serving_region) {
38 serving_region_ = serving_region.as_string();
41 int32 bandwidth_estimate_bytes_per_second() const {
42 return bandwidth_estimate_bytes_per_second_;
44 void set_bandwidth_estimate_bytes_per_second(
45 int32 bandwidth_estimate_bytes_per_second) {
46 bandwidth_estimate_bytes_per_second_ = bandwidth_estimate_bytes_per_second;
49 int32 max_bandwidth_estimate_bytes_per_second() const {
50 return max_bandwidth_estimate_bytes_per_second_;
52 void set_max_bandwidth_estimate_bytes_per_second(
53 int32 max_bandwidth_estimate_bytes_per_second) {
54 max_bandwidth_estimate_bytes_per_second_ =
55 max_bandwidth_estimate_bytes_per_second;
58 int64 max_bandwidth_timestamp_seconds() const {
59 return max_bandwidth_timestamp_seconds_;
61 void set_max_bandwidth_timestamp_seconds(
62 int64 max_bandwidth_timestamp_seconds) {
63 max_bandwidth_timestamp_seconds_ = max_bandwidth_timestamp_seconds;
66 int32 min_rtt_ms() const {
67 return min_rtt_ms_;
69 void set_min_rtt_ms(int32 min_rtt_ms) {
70 min_rtt_ms_ = min_rtt_ms;
73 int32 previous_connection_state() const {
74 return previous_connection_state_;
76 void set_previous_connection_state(int32 previous_connection_state) {
77 previous_connection_state_ = previous_connection_state;
80 int64 timestamp() const { return timestamp_; }
81 void set_timestamp(int64 timestamp) { timestamp_ = timestamp; }
83 private:
84 // serving_region_ is used to decide whether or not the bandwidth estimate and
85 // min RTT are reasonable and if they should be used.
86 // For example a group of geographically close servers may share the same
87 // serving_region_ string if they are expected to have similar network
88 // performance.
89 std::string serving_region_;
90 // The server can supply a bandwidth estimate (in bytes/s) which it may re-use
91 // on receipt of a source-address token with this field set.
92 int32 bandwidth_estimate_bytes_per_second_;
93 // The maximum bandwidth seen by the client, not necessarily the latest.
94 int32 max_bandwidth_estimate_bytes_per_second_;
95 // Timestamp (seconds since UNIX epoch) that indicates when the max bandwidth
96 // was seen by the server.
97 int64 max_bandwidth_timestamp_seconds_;
98 // The min RTT seen on a previous connection can be used by the server to
99 // inform initial connection parameters for new connections.
100 int32 min_rtt_ms_;
101 // Encodes the PreviousConnectionState enum.
102 int32 previous_connection_state_;
103 // UNIX timestamp when this bandwidth estimate was created.
104 int64 timestamp_;
107 } // namespace net
109 #endif // NET_QUIC_CRYPTO_CACHED_NETWORK_PARAMETERS_H_