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 #ifndef NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ | 5 #ifndef NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ |
6 #define NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ | 6 #define NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 // TODO(rtenneti): sync with server more rationally. | 15 // TODO(rtenneti): sync with server more rationally. |
16 class SourceAddressToken { | 16 class SourceAddressToken { |
17 public: | 17 public: |
18 SourceAddressToken(); | 18 SourceAddressToken(); |
19 ~SourceAddressToken(); | 19 ~SourceAddressToken(); |
20 | 20 |
21 std::string SerializeAsString() const; | 21 std::string SerializeAsString() const; |
22 | 22 |
23 bool ParseFromArray(const char* plaintext, size_t plaintext_length); | 23 bool ParseFromArray(const char* plaintext, size_t plaintext_length); |
24 | 24 |
25 std::string ip() const { | 25 std::string ip() const { return ip_; } |
26 return ip_; | |
27 } | |
28 | 26 |
29 int64 timestamp() const { | 27 int64 timestamp() const { return timestamp_; } |
30 return timestamp_; | |
31 } | |
32 | 28 |
33 void set_ip(base::StringPiece ip) { | 29 void set_ip(base::StringPiece ip) { ip_ = ip.as_string(); } |
34 ip_ = ip.as_string(); | |
35 } | |
36 | 30 |
37 void set_timestamp(int64 timestamp) { | 31 void set_timestamp(int64 timestamp) { timestamp_ = timestamp; } |
38 timestamp_ = timestamp; | |
39 } | |
40 | 32 |
41 private: | 33 private: |
42 std::string ip_; | 34 std::string ip_; |
43 int64 timestamp_; | 35 int64 timestamp_; |
44 | 36 |
45 DISALLOW_COPY_AND_ASSIGN(SourceAddressToken); | 37 DISALLOW_COPY_AND_ASSIGN(SourceAddressToken); |
46 }; | 38 }; |
47 | 39 |
48 } // namespace net | 40 } // namespace net |
49 | 41 |
50 #endif // NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ | 42 #endif // NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ |
OLD | NEW |