Disable InstantExtendedTest.UpdateSearchQueryOnBackNavigation, InstantExtendedTest...
[chromium-blink-merge.git] / content / common / ssl_status_serialization.cc
blob87593a595a2589e4b2d962dbb968b998e097af96
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
3 // found in the LICENSE file.
5 #include "content/common/ssl_status_serialization.h"
7 #include "base/logging.h"
8 #include "base/pickle.h"
10 namespace content {
12 std::string SerializeSecurityInfo(int cert_id,
13 net::CertStatus cert_status,
14 int security_bits,
15 int ssl_connection_status) {
16 Pickle pickle;
17 pickle.WriteInt(cert_id);
18 pickle.WriteUInt32(cert_status);
19 pickle.WriteInt(security_bits);
20 pickle.WriteInt(ssl_connection_status);
21 return std::string(static_cast<const char*>(pickle.data()), pickle.size());
24 bool DeserializeSecurityInfo(const std::string& state,
25 int* cert_id,
26 net::CertStatus* cert_status,
27 int* security_bits,
28 int* ssl_connection_status) {
29 DCHECK(cert_id && cert_status && security_bits && ssl_connection_status);
30 if (state.empty()) {
31 // No SSL used.
32 *cert_id = 0;
33 // The following are not applicable and are set to the default values.
34 *cert_status = 0;
35 *security_bits = -1;
36 *ssl_connection_status = 0;
37 return false;
40 Pickle pickle(state.data(), static_cast<int>(state.size()));
41 PickleIterator iter(pickle);
42 return pickle.ReadInt(&iter, cert_id) &&
43 pickle.ReadUInt32(&iter, cert_status) &&
44 pickle.ReadInt(&iter, security_bits) &&
45 pickle.ReadInt(&iter, ssl_connection_status);
48 } // namespace content