Sort unlaunched apps on app list start page by apps grid order.
[chromium-blink-merge.git] / net / quic / crypto / cached_network_parameters.h
blob34c89171897eb48ee3ae4ce93e7b409edcd53546
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;
71 has_min_rtt_ms_ = true;
73 bool has_min_rtt_ms() const { return has_min_rtt_ms_; }
75 int32 previous_connection_state() const {
76 return previous_connection_state_;
78 void set_previous_connection_state(int32 previous_connection_state) {
79 previous_connection_state_ = previous_connection_state;
82 int64 timestamp() const { return timestamp_; }
83 void set_timestamp(int64 timestamp) { timestamp_ = timestamp; }
85 private:
86 // serving_region_ is used to decide whether or not the bandwidth estimate and
87 // min RTT are reasonable and if they should be used.
88 // For example a group of geographically close servers may share the same
89 // serving_region_ string if they are expected to have similar network
90 // performance.
91 std::string serving_region_;
92 // The server can supply a bandwidth estimate (in bytes/s) which it may re-use
93 // on receipt of a source-address token with this field set.
94 int32 bandwidth_estimate_bytes_per_second_;
95 // The maximum bandwidth seen by the client, not necessarily the latest.
96 int32 max_bandwidth_estimate_bytes_per_second_;
97 // Timestamp (seconds since UNIX epoch) that indicates when the max bandwidth
98 // was seen by the server.
99 int64 max_bandwidth_timestamp_seconds_;
100 // The min RTT seen on a previous connection can be used by the server to
101 // inform initial connection parameters for new connections.
102 int32 min_rtt_ms_;
103 // Whenever min_rtt_ms_ is updated, it is set to true.
104 bool has_min_rtt_ms_;
105 // Encodes the PreviousConnectionState enum.
106 int32 previous_connection_state_;
107 // UNIX timestamp when this bandwidth estimate was created.
108 int64 timestamp_;
111 } // namespace net
113 #endif // NET_QUIC_CRYPTO_CACHED_NETWORK_PARAMETERS_H_