| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/quic_server_info.h" | 5 #include "net/quic/crypto/quic_server_info.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool QuicServerInfo::ParseInner(const string& data) { | 58 bool QuicServerInfo::ParseInner(const string& data) { |
| 59 State* state = mutable_state(); | 59 State* state = mutable_state(); |
| 60 | 60 |
| 61 // No data was read from the disk cache. | 61 // No data was read from the disk cache. |
| 62 if (data.empty()) { | 62 if (data.empty()) { |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| 65 | 65 |
| 66 Pickle p(data.data(), data.size()); | 66 base::Pickle p(data.data(), data.size()); |
| 67 PickleIterator iter(p); | 67 base::PickleIterator iter(p); |
| 68 | 68 |
| 69 int version = -1; | 69 int version = -1; |
| 70 if (!iter.ReadInt(&version)) { | 70 if (!iter.ReadInt(&version)) { |
| 71 DVLOG(1) << "Missing version"; | 71 DVLOG(1) << "Missing version"; |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 | 74 |
| 75 if (version != kQuicCryptoConfigVersion) { | 75 if (version != kQuicCryptoConfigVersion) { |
| 76 DVLOG(1) << "Unsupported version"; | 76 DVLOG(1) << "Unsupported version"; |
| 77 return false; | 77 return false; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 | 111 |
| 112 string QuicServerInfo::Serialize() { | 112 string QuicServerInfo::Serialize() { |
| 113 string pickled_data = SerializeInner(); | 113 string pickled_data = SerializeInner(); |
| 114 state_.Clear(); | 114 state_.Clear(); |
| 115 return pickled_data; | 115 return pickled_data; |
| 116 } | 116 } |
| 117 | 117 |
| 118 string QuicServerInfo::SerializeInner() const { | 118 string QuicServerInfo::SerializeInner() const { |
| 119 Pickle p(sizeof(Pickle::Header)); | 119 base::Pickle p(sizeof(base::Pickle::Header)); |
| 120 | 120 |
| 121 if (!p.WriteInt(kQuicCryptoConfigVersion) || | 121 if (!p.WriteInt(kQuicCryptoConfigVersion) || |
| 122 !p.WriteString(state_.server_config) || | 122 !p.WriteString(state_.server_config) || |
| 123 !p.WriteString(state_.source_address_token) || | 123 !p.WriteString(state_.source_address_token) || |
| 124 !p.WriteString(state_.server_config_sig) || | 124 !p.WriteString(state_.server_config_sig) || |
| 125 state_.certs.size() > std::numeric_limits<uint32>::max() || | 125 state_.certs.size() > std::numeric_limits<uint32>::max() || |
| 126 !p.WriteUInt32(state_.certs.size())) { | 126 !p.WriteUInt32(state_.certs.size())) { |
| 127 return string(); | 127 return string(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 for (size_t i = 0; i < state_.certs.size(); i++) { | 130 for (size_t i = 0; i < state_.certs.size(); i++) { |
| 131 if (!p.WriteString(state_.certs[i])) { | 131 if (!p.WriteString(state_.certs[i])) { |
| 132 return string(); | 132 return string(); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 return string(reinterpret_cast<const char *>(p.data()), p.size()); | 136 return string(reinterpret_cast<const char *>(p.data()), p.size()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 QuicServerInfoFactory::~QuicServerInfoFactory() {} | 139 QuicServerInfoFactory::~QuicServerInfoFactory() {} |
| 140 | 140 |
| 141 } // namespace net | 141 } // namespace net |
| OLD | NEW |