| 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 "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 | 9 |
| 10 using std::string; | 10 using std::string; |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 SourceAddressToken::SourceAddressToken() | 14 SourceAddressToken::SourceAddressToken() |
| 15 : has_cached_network_parameters_(false) { | 15 : has_cached_network_parameters_(false) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 SourceAddressToken::~SourceAddressToken() { | 18 SourceAddressToken::~SourceAddressToken() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 string SourceAddressToken::SerializeAsString() const { | 21 string SourceAddressToken::SerializeAsString() const { |
| 22 string out; | 22 string out; |
| 23 out.push_back(ip_.size()); | 23 out.push_back(static_cast<char>(ip_.size())); |
| 24 out.append(ip_); | 24 out.append(ip_); |
| 25 string time_str = base::Int64ToString(timestamp_); | 25 string time_str = base::Int64ToString(timestamp_); |
| 26 out.push_back(time_str.size()); | 26 out.push_back(static_cast<char>(time_str.size())); |
| 27 out.append(time_str); | 27 out.append(time_str); |
| 28 // TODO(rtenneti): Implement serialization of optional CachedNetworkParameters | 28 // TODO(rtenneti): Implement serialization of optional CachedNetworkParameters |
| 29 // when they are used. | 29 // when they are used. |
| 30 return out; | 30 return out; |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool SourceAddressToken::ParseFromArray(const char* plaintext, | 33 bool SourceAddressToken::ParseFromArray(const char* plaintext, |
| 34 size_t plaintext_length) { | 34 size_t plaintext_length) { |
| 35 if (plaintext_length == 0) { | 35 if (plaintext_length == 0) { |
| 36 return false; | 36 return false; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 52 | 52 |
| 53 ip_.assign(&plaintext[1], ip_len); | 53 ip_.assign(&plaintext[1], ip_len); |
| 54 timestamp_ = timestamp; | 54 timestamp_ = timestamp; |
| 55 | 55 |
| 56 // TODO(rtenneti): Implement parsing of optional CachedNetworkParameters when | 56 // TODO(rtenneti): Implement parsing of optional CachedNetworkParameters when |
| 57 // they are used. | 57 // they are used. |
| 58 return true; | 58 return true; |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace net | 61 } // namespace net |
| OLD | NEW |