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

Side by Side Diff: net/http/http_response_info.cc

Issue 818833004: Remove deprecated methods from Pickle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 12 months 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/http/http_response_headers_unittest.cc ('k') | net/http/http_vary_data.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/http/http_response_info.h" 5 #include "net/http/http_response_info.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "net/base/auth.h" 10 #include "net/base/auth.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 metadata = rhs.metadata; 153 metadata = rhs.metadata;
154 return *this; 154 return *this;
155 } 155 }
156 156
157 bool HttpResponseInfo::InitFromPickle(const Pickle& pickle, 157 bool HttpResponseInfo::InitFromPickle(const Pickle& pickle,
158 bool* response_truncated) { 158 bool* response_truncated) {
159 PickleIterator iter(pickle); 159 PickleIterator iter(pickle);
160 160
161 // Read flags and verify version 161 // Read flags and verify version
162 int flags; 162 int flags;
163 if (!pickle.ReadInt(&iter, &flags)) 163 if (!iter.ReadInt(&flags))
164 return false; 164 return false;
165 int version = flags & RESPONSE_INFO_VERSION_MASK; 165 int version = flags & RESPONSE_INFO_VERSION_MASK;
166 if (version < RESPONSE_INFO_MINIMUM_VERSION || 166 if (version < RESPONSE_INFO_MINIMUM_VERSION ||
167 version > RESPONSE_INFO_VERSION) { 167 version > RESPONSE_INFO_VERSION) {
168 DLOG(ERROR) << "unexpected response info version: " << version; 168 DLOG(ERROR) << "unexpected response info version: " << version;
169 return false; 169 return false;
170 } 170 }
171 171
172 // Read request-time 172 // Read request-time
173 int64 time_val; 173 int64 time_val;
174 if (!pickle.ReadInt64(&iter, &time_val)) 174 if (!iter.ReadInt64(&time_val))
175 return false; 175 return false;
176 request_time = Time::FromInternalValue(time_val); 176 request_time = Time::FromInternalValue(time_val);
177 was_cached = true; // Set status to show cache resurrection. 177 was_cached = true; // Set status to show cache resurrection.
178 178
179 // Read response-time 179 // Read response-time
180 if (!pickle.ReadInt64(&iter, &time_val)) 180 if (!iter.ReadInt64(&time_val))
181 return false; 181 return false;
182 response_time = Time::FromInternalValue(time_val); 182 response_time = Time::FromInternalValue(time_val);
183 183
184 // Read response-headers 184 // Read response-headers
185 headers = new HttpResponseHeaders(pickle, &iter); 185 headers = new HttpResponseHeaders(&iter);
186 if (headers->response_code() == -1) 186 if (headers->response_code() == -1)
187 return false; 187 return false;
188 188
189 // Read ssl-info 189 // Read ssl-info
190 if (flags & RESPONSE_INFO_HAS_CERT) { 190 if (flags & RESPONSE_INFO_HAS_CERT) {
191 X509Certificate::PickleType type = GetPickleTypeForVersion(version); 191 X509Certificate::PickleType type = GetPickleTypeForVersion(version);
192 ssl_info.cert = X509Certificate::CreateFromPickle(pickle, &iter, type); 192 ssl_info.cert = X509Certificate::CreateFromPickle(&iter, type);
193 if (!ssl_info.cert.get()) 193 if (!ssl_info.cert.get())
194 return false; 194 return false;
195 } 195 }
196 if (flags & RESPONSE_INFO_HAS_CERT_STATUS) { 196 if (flags & RESPONSE_INFO_HAS_CERT_STATUS) {
197 CertStatus cert_status; 197 CertStatus cert_status;
198 if (!pickle.ReadUInt32(&iter, &cert_status)) 198 if (!iter.ReadUInt32(&cert_status))
199 return false; 199 return false;
200 ssl_info.cert_status = cert_status; 200 ssl_info.cert_status = cert_status;
201 } 201 }
202 if (flags & RESPONSE_INFO_HAS_SECURITY_BITS) { 202 if (flags & RESPONSE_INFO_HAS_SECURITY_BITS) {
203 int security_bits; 203 int security_bits;
204 if (!pickle.ReadInt(&iter, &security_bits)) 204 if (!iter.ReadInt(&security_bits))
205 return false; 205 return false;
206 ssl_info.security_bits = security_bits; 206 ssl_info.security_bits = security_bits;
207 } 207 }
208 208
209 if (flags & RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS) { 209 if (flags & RESPONSE_INFO_HAS_SSL_CONNECTION_STATUS) {
210 int connection_status; 210 int connection_status;
211 if (!pickle.ReadInt(&iter, &connection_status)) 211 if (!iter.ReadInt(&connection_status))
212 return false; 212 return false;
213 ssl_info.connection_status = connection_status; 213 ssl_info.connection_status = connection_status;
214 } 214 }
215 215
216 if (flags & RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS) { 216 if (flags & RESPONSE_INFO_HAS_SIGNED_CERTIFICATE_TIMESTAMPS) {
217 int num_scts; 217 int num_scts;
218 if (!pickle.ReadInt(&iter, &num_scts)) 218 if (!iter.ReadInt(&num_scts))
219 return false; 219 return false;
220 for (int i = 0; i < num_scts; ++i) { 220 for (int i = 0; i < num_scts; ++i) {
221 scoped_refptr<ct::SignedCertificateTimestamp> sct( 221 scoped_refptr<ct::SignedCertificateTimestamp> sct(
222 ct::SignedCertificateTimestamp::CreateFromPickle(&iter)); 222 ct::SignedCertificateTimestamp::CreateFromPickle(&iter));
223 uint16 status; 223 uint16 status;
224 if (!sct.get() || !pickle.ReadUInt16(&iter, &status)) 224 if (!sct.get() || !iter.ReadUInt16(&status))
225 return false; 225 return false;
226 ssl_info.signed_certificate_timestamps.push_back( 226 ssl_info.signed_certificate_timestamps.push_back(
227 SignedCertificateTimestampAndStatus( 227 SignedCertificateTimestampAndStatus(
228 sct, static_cast<ct::SCTVerifyStatus>(status))); 228 sct, static_cast<ct::SCTVerifyStatus>(status)));
229 } 229 }
230 } 230 }
231 231
232 // Read vary-data 232 // Read vary-data
233 if (flags & RESPONSE_INFO_HAS_VARY_DATA) { 233 if (flags & RESPONSE_INFO_HAS_VARY_DATA) {
234 if (!vary_data.InitFromPickle(pickle, &iter)) 234 if (!vary_data.InitFromPickle(&iter))
235 return false; 235 return false;
236 } 236 }
237 237
238 // Read socket_address. 238 // Read socket_address.
239 std::string socket_address_host; 239 std::string socket_address_host;
240 if (pickle.ReadString(&iter, &socket_address_host)) { 240 if (iter.ReadString(&socket_address_host)) {
241 // If the host was written, we always expect the port to follow. 241 // If the host was written, we always expect the port to follow.
242 uint16 socket_address_port; 242 uint16 socket_address_port;
243 if (!pickle.ReadUInt16(&iter, &socket_address_port)) 243 if (!iter.ReadUInt16(&socket_address_port))
244 return false; 244 return false;
245 socket_address = HostPortPair(socket_address_host, socket_address_port); 245 socket_address = HostPortPair(socket_address_host, socket_address_port);
246 } else if (version > 1) { 246 } else if (version > 1) {
247 // socket_address was not always present in version 1 of the response 247 // socket_address was not always present in version 1 of the response
248 // info, so we don't fail if it can't be read. 248 // info, so we don't fail if it can't be read.
249 return false; 249 return false;
250 } 250 }
251 251
252 // Read protocol-version. 252 // Read protocol-version.
253 if (flags & RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL) { 253 if (flags & RESPONSE_INFO_HAS_NPN_NEGOTIATED_PROTOCOL) {
254 if (!pickle.ReadString(&iter, &npn_negotiated_protocol)) 254 if (!iter.ReadString(&npn_negotiated_protocol))
255 return false; 255 return false;
256 } 256 }
257 257
258 // Read connection info. 258 // Read connection info.
259 if (flags & RESPONSE_INFO_HAS_CONNECTION_INFO) { 259 if (flags & RESPONSE_INFO_HAS_CONNECTION_INFO) {
260 int value; 260 int value;
261 if (!pickle.ReadInt(&iter, &value)) 261 if (!iter.ReadInt(&value))
262 return false; 262 return false;
263 263
264 if (value > static_cast<int>(CONNECTION_INFO_UNKNOWN) && 264 if (value > static_cast<int>(CONNECTION_INFO_UNKNOWN) &&
265 value < static_cast<int>(NUM_OF_CONNECTION_INFOS)) { 265 value < static_cast<int>(NUM_OF_CONNECTION_INFOS)) {
266 connection_info = static_cast<ConnectionInfo>(value); 266 connection_info = static_cast<ConnectionInfo>(value);
267 } 267 }
268 } 268 }
269 269
270 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0; 270 was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0;
271 271
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 case CONNECTION_INFO_QUIC1_SPDY3: 407 case CONNECTION_INFO_QUIC1_SPDY3:
408 return "quic/1+spdy/3"; 408 return "quic/1+spdy/3";
409 case NUM_OF_CONNECTION_INFOS: 409 case NUM_OF_CONNECTION_INFOS:
410 break; 410 break;
411 } 411 }
412 NOTREACHED(); 412 NOTREACHED();
413 return ""; 413 return "";
414 } 414 }
415 415
416 } // namespace net 416 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_response_headers_unittest.cc ('k') | net/http/http_vary_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698