Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: net/quic/crypto/quic_server_info.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/crypto/quic_server_info.h ('k') | net/quic/crypto/scoped_evp_aead_ctx.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if (!iter.ReadString(&state->source_address_token)) { 82 if (!iter.ReadString(&state->source_address_token)) {
83 DVLOG(1) << "Malformed source_address_token"; 83 DVLOG(1) << "Malformed source_address_token";
84 return false; 84 return false;
85 } 85 }
86 if (!iter.ReadString(&state->server_config_sig)) { 86 if (!iter.ReadString(&state->server_config_sig)) {
87 DVLOG(1) << "Malformed server_config_sig"; 87 DVLOG(1) << "Malformed server_config_sig";
88 return false; 88 return false;
89 } 89 }
90 90
91 // Read certs. 91 // Read certs.
92 uint32 num_certs; 92 uint32_t num_certs;
93 if (!iter.ReadUInt32(&num_certs)) { 93 if (!iter.ReadUInt32(&num_certs)) {
94 DVLOG(1) << "Malformed num_certs"; 94 DVLOG(1) << "Malformed num_certs";
95 return false; 95 return false;
96 } 96 }
97 97
98 for (uint32 i = 0; i < num_certs; i++) { 98 for (uint32_t i = 0; i < num_certs; i++) {
99 string cert; 99 string cert;
100 if (!iter.ReadString(&cert)) { 100 if (!iter.ReadString(&cert)) {
101 DVLOG(1) << "Malformed cert"; 101 DVLOG(1) << "Malformed cert";
102 return false; 102 return false;
103 } 103 }
104 state->certs.push_back(cert); 104 state->certs.push_back(cert);
105 } 105 }
106 106
107 return true; 107 return true;
108 } 108 }
109 109
110 string QuicServerInfo::Serialize() { 110 string QuicServerInfo::Serialize() {
111 string pickled_data = SerializeInner(); 111 string pickled_data = SerializeInner();
112 state_.Clear(); 112 state_.Clear();
113 return pickled_data; 113 return pickled_data;
114 } 114 }
115 115
116 string QuicServerInfo::SerializeInner() const { 116 string QuicServerInfo::SerializeInner() const {
117 base::Pickle p(sizeof(base::Pickle::Header)); 117 base::Pickle p(sizeof(base::Pickle::Header));
118 118
119 if (!p.WriteInt(kQuicCryptoConfigVersion) || 119 if (!p.WriteInt(kQuicCryptoConfigVersion) ||
120 !p.WriteString(state_.server_config) || 120 !p.WriteString(state_.server_config) ||
121 !p.WriteString(state_.source_address_token) || 121 !p.WriteString(state_.source_address_token) ||
122 !p.WriteString(state_.server_config_sig) || 122 !p.WriteString(state_.server_config_sig) ||
123 state_.certs.size() > std::numeric_limits<uint32>::max() || 123 state_.certs.size() > std::numeric_limits<uint32_t>::max() ||
124 !p.WriteUInt32(state_.certs.size())) { 124 !p.WriteUInt32(state_.certs.size())) {
125 return string(); 125 return string();
126 } 126 }
127 127
128 for (size_t i = 0; i < state_.certs.size(); i++) { 128 for (size_t i = 0; i < state_.certs.size(); i++) {
129 if (!p.WriteString(state_.certs[i])) { 129 if (!p.WriteString(state_.certs[i])) {
130 return string(); 130 return string();
131 } 131 }
132 } 132 }
133 133
134 return string(reinterpret_cast<const char*>(p.data()), p.size()); 134 return string(reinterpret_cast<const char*>(p.data()), p.size());
135 } 135 }
136 136
137 QuicServerInfoFactory::~QuicServerInfoFactory() {} 137 QuicServerInfoFactory::~QuicServerInfoFactory() {}
138 138
139 } // namespace net 139 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_server_info.h ('k') | net/quic/crypto/scoped_evp_aead_ctx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698