Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/quic/crypto/source_address_token.h" | |
| 6 | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/strings/string_number_conversions.h" | |
| 10 #include "base/strings/string_split.h" | |
| 11 | |
| 12 using std::string; | |
| 13 using std::vector; | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 SourceAddressToken::SourceAddressToken() { | |
|
Nico
2015/03/08 02:41:40
This doesn't set timestamp_. Is that intentional?
ramant (doing other things)
2015/03/08 23:26:53
Good point. Will upload a change asap.
thanks
ram
ramant (doing other things)
2015/03/09 00:01:46
Uploaded https://codereview.chromium.org/985383003
| |
| 18 } | |
| 19 | |
| 20 SourceAddressToken::~SourceAddressToken() { | |
| 21 } | |
| 22 | |
| 23 string SourceAddressToken::SerializeAsString() const { | |
| 24 return ip_ + " " + base::Int64ToString(timestamp_); | |
| 25 } | |
| 26 | |
| 27 bool SourceAddressToken::ParseFromArray(unsigned char* plaintext, | |
| 28 size_t plaintext_length) { | |
| 29 string data(reinterpret_cast<const char*>(plaintext), plaintext_length); | |
| 30 vector<string> results; | |
| 31 base::SplitString(data, ' ', &results); | |
| 32 if (results.size() < 2) { | |
| 33 return false; | |
| 34 } | |
| 35 | |
| 36 int64 timestamp; | |
| 37 if (!base::StringToInt64(results[1], ×tamp)) { | |
| 38 return false; | |
| 39 } | |
| 40 | |
| 41 ip_ = results[0]; | |
| 42 timestamp_ = timestamp; | |
| 43 return true; | |
| 44 } | |
| 45 | |
| 46 } // namespace net | |
| OLD | NEW |