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"
12 std::string
SerializeSecurityInfo(int cert_id
,
13 net::CertStatus cert_status
,
15 int ssl_connection_status
) {
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
,
26 net::CertStatus
* cert_status
,
28 int* ssl_connection_status
) {
29 DCHECK(cert_id
&& cert_status
&& security_bits
&& ssl_connection_status
);
33 // The following are not applicable and are set to the default values.
36 *ssl_connection_status
= 0;
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