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

Side by Side Diff: content/common/ssl_status_serialization.cc

Issue 9382037: Move ContextMenuParams struct from webkit/glue to content/public/common. The reasons are: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 10 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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.
4
5 #include "content/common/ssl_status_serialization.h"
6
7 #include "base/logging.h"
8 #include "base/pickle.h"
9
10 namespace content {
11
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());
22 }
23
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;
38 }
39
40 Pickle pickle(state.data(), static_cast<int>(state.size()));
41 void * iter = NULL;
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);
46 }
47
48 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698