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/logging.h" |
11 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
12 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
13 #include "net/quic/crypto/cached_network_parameters.h" | 14 #include "net/quic/crypto/cached_network_parameters.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 // TODO(rtenneti): sync with server more rationally. | 18 // TODO(rtenneti): sync with server more rationally. |
18 // A SourceAddressToken is serialised, encrypted and sent to clients so that | 19 // A SourceAddressToken is serialised, encrypted and sent to clients so that |
19 // they can prove ownership of an IP address. | 20 // they can prove ownership of an IP address. |
20 class NET_EXPORT_PRIVATE SourceAddressToken { | 21 class NET_EXPORT_PRIVATE SourceAddressToken { |
21 public: | 22 public: |
22 SourceAddressToken(); | 23 SourceAddressToken(); |
23 ~SourceAddressToken(); | 24 ~SourceAddressToken(); |
24 | 25 |
25 std::string SerializeAsString() const; | 26 std::string SerializeAsString() const; |
26 | 27 |
27 bool ParseFromArray(const char* plaintext, size_t plaintext_length); | 28 bool ParseFromArray(const char* plaintext, size_t plaintext_length); |
28 | 29 |
29 std::string ip() const { | 30 std::string ip() const { |
30 return ip_; | 31 return ip_; |
31 } | 32 } |
32 void set_ip(base::StringPiece ip) { | 33 void set_ip(base::StringPiece ip) { |
33 ip_ = ip.as_string(); | 34 ip_ = ip.as_string(); |
| 35 DCHECK_LE(ip_.size(), |
| 36 static_cast<size_t>(std::numeric_limits<char>::max())); |
34 } | 37 } |
35 | 38 |
36 int64 timestamp() const { | 39 int64 timestamp() const { |
37 return timestamp_; | 40 return timestamp_; |
38 } | 41 } |
39 void set_timestamp(int64 timestamp) { | 42 void set_timestamp(int64 timestamp) { |
40 timestamp_ = timestamp; | 43 timestamp_ = timestamp; |
41 } | 44 } |
42 | 45 |
43 const CachedNetworkParameters& cached_network_parameters() const { | 46 const CachedNetworkParameters& cached_network_parameters() const { |
(...skipping 22 matching lines...) Loading... |
66 // TODO(rtenneti): Delete |has_cached_network_parameters_| after we convert | 69 // TODO(rtenneti): Delete |has_cached_network_parameters_| after we convert |
67 // SourceAddressToken to protobuf. | 70 // SourceAddressToken to protobuf. |
68 bool has_cached_network_parameters_; | 71 bool has_cached_network_parameters_; |
69 | 72 |
70 DISALLOW_COPY_AND_ASSIGN(SourceAddressToken); | 73 DISALLOW_COPY_AND_ASSIGN(SourceAddressToken); |
71 }; | 74 }; |
72 | 75 |
73 } // namespace net | 76 } // namespace net |
74 | 77 |
75 #endif // NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ | 78 #endif // NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ |
OLD | NEW |