OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/crypto/source_address_token.h" | 5 #include "net/quic/crypto/source_address_token.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
11 | 11 |
12 using std::string; | 12 using std::string; |
13 using std::vector; | 13 using std::vector; |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 CachedNetworkParameters::CachedNetworkParameters() { | 17 CachedNetworkParameters::CachedNetworkParameters() |
| 18 : bandwidth_estimate_bytes_per_second_(0), |
| 19 max_bandwidth_estimate_bytes_per_second_(0), |
| 20 max_bandwidth_timestamp_seconds_(0), |
| 21 min_rtt_ms_(0), |
| 22 previous_connection_state_(0), |
| 23 timestamp_(0) { |
18 } | 24 } |
19 | 25 |
20 CachedNetworkParameters::~CachedNetworkParameters() { | 26 CachedNetworkParameters::~CachedNetworkParameters() { |
21 } | 27 } |
22 | 28 |
23 SourceAddressToken::SourceAddressToken() { | 29 bool CachedNetworkParameters::operator==( |
| 30 const CachedNetworkParameters& other) const { |
| 31 return serving_region_ == other.serving_region_ && |
| 32 bandwidth_estimate_bytes_per_second_ == |
| 33 other.bandwidth_estimate_bytes_per_second_ && |
| 34 max_bandwidth_estimate_bytes_per_second_ == |
| 35 other.max_bandwidth_estimate_bytes_per_second_ && |
| 36 max_bandwidth_timestamp_seconds_ == |
| 37 other.max_bandwidth_timestamp_seconds_ && |
| 38 min_rtt_ms_ == other.min_rtt_ms_ && |
| 39 previous_connection_state_ == other.previous_connection_state_ && |
| 40 timestamp_ == other.timestamp_; |
| 41 } |
| 42 |
| 43 bool CachedNetworkParameters::operator!=( |
| 44 const CachedNetworkParameters& other) const { |
| 45 return !(*this == other); |
| 46 } |
| 47 |
| 48 SourceAddressToken::SourceAddressToken() |
| 49 : has_cached_network_parameters_(false) { |
24 } | 50 } |
25 | 51 |
26 SourceAddressToken::~SourceAddressToken() { | 52 SourceAddressToken::~SourceAddressToken() { |
27 } | 53 } |
28 | 54 |
29 string SourceAddressToken::SerializeAsString() const { | 55 string SourceAddressToken::SerializeAsString() const { |
30 string out; | 56 string out; |
31 out.push_back(ip_.size()); | 57 out.push_back(ip_.size()); |
32 out.append(ip_); | 58 out.append(ip_); |
33 string time_str = base::Int64ToString(timestamp_); | 59 string time_str = base::Int64ToString(timestamp_); |
(...skipping 26 matching lines...) Expand all Loading... |
60 | 86 |
61 ip_.assign(&plaintext[1], ip_len); | 87 ip_.assign(&plaintext[1], ip_len); |
62 timestamp_ = timestamp; | 88 timestamp_ = timestamp; |
63 | 89 |
64 // TODO(rtenneti): Implement parsing of optional CachedNetworkParameters when | 90 // TODO(rtenneti): Implement parsing of optional CachedNetworkParameters when |
65 // they are used. | 91 // they are used. |
66 return true; | 92 return true; |
67 } | 93 } |
68 | 94 |
69 } // namespace net | 95 } // namespace net |
OLD | NEW |