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

Side by Side Diff: net/base/default_origin_bound_cert_store.cc

Issue 8662036: Support EC certs in OriginBoundCertService and OriginBoundCertStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/default_origin_bound_cert_store.h" 5 #include "net/base/default_origin_bound_cert_store.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 8
9 namespace net { 9 namespace net {
10 10
11 // static 11 // static
12 const size_t DefaultOriginBoundCertStore::kMaxCerts = 3300; 12 const size_t DefaultOriginBoundCertStore::kMaxCerts = 3300;
13 13
14 DefaultOriginBoundCertStore::DefaultOriginBoundCertStore( 14 DefaultOriginBoundCertStore::DefaultOriginBoundCertStore(
15 PersistentStore* store) 15 PersistentStore* store)
16 : initialized_(false), 16 : initialized_(false),
17 store_(store) {} 17 store_(store) {}
18 18
19 void DefaultOriginBoundCertStore::FlushStore(Task* completion_task) { 19 void DefaultOriginBoundCertStore::FlushStore(Task* completion_task) {
20 base::AutoLock autolock(lock_); 20 base::AutoLock autolock(lock_);
21 21
22 if (initialized_ && store_) 22 if (initialized_ && store_)
23 store_->Flush(completion_task); 23 store_->Flush(completion_task);
24 else if (completion_task) 24 else if (completion_task)
25 MessageLoop::current()->PostTask(FROM_HERE, completion_task); 25 MessageLoop::current()->PostTask(FROM_HERE, completion_task);
26 } 26 }
27 27
28 bool DefaultOriginBoundCertStore::GetOriginBoundCert( 28 bool DefaultOriginBoundCertStore::GetOriginBoundCert(
29 const std::string& origin, 29 const std::string& origin,
30 OriginBoundCertType* type,
30 std::string* private_key_result, 31 std::string* private_key_result,
31 std::string* cert_result) { 32 std::string* cert_result) {
32 base::AutoLock autolock(lock_); 33 base::AutoLock autolock(lock_);
33 InitIfNecessary(); 34 InitIfNecessary();
34 35
35 OriginBoundCertMap::iterator it = origin_bound_certs_.find(origin); 36 OriginBoundCertMap::iterator it = origin_bound_certs_.find(origin);
36 37
37 if (it == origin_bound_certs_.end()) 38 if (it == origin_bound_certs_.end())
38 return false; 39 return false;
39 40
40 OriginBoundCert* cert = it->second; 41 OriginBoundCert* cert = it->second;
42 *type = cert->type();
41 *private_key_result = cert->private_key(); 43 *private_key_result = cert->private_key();
42 *cert_result = cert->cert(); 44 *cert_result = cert->cert();
43 45
44 return true; 46 return true;
45 } 47 }
46 48
47 void DefaultOriginBoundCertStore::SetOriginBoundCert( 49 void DefaultOriginBoundCertStore::SetOriginBoundCert(
48 const std::string& origin, 50 const std::string& origin,
51 OriginBoundCertType type,
49 const std::string& private_key, 52 const std::string& private_key,
50 const std::string& cert) { 53 const std::string& cert) {
51 base::AutoLock autolock(lock_); 54 base::AutoLock autolock(lock_);
52 InitIfNecessary(); 55 InitIfNecessary();
53 56
54 InternalDeleteOriginBoundCert(origin); 57 InternalDeleteOriginBoundCert(origin);
55 InternalInsertOriginBoundCert(origin, 58 InternalInsertOriginBoundCert(
56 new OriginBoundCert(origin, private_key, cert)); 59 origin, new OriginBoundCert(origin, type, private_key, cert));
57 } 60 }
58 61
59 void DefaultOriginBoundCertStore::DeleteOriginBoundCert( 62 void DefaultOriginBoundCertStore::DeleteOriginBoundCert(
60 const std::string& origin) { 63 const std::string& origin) {
61 base::AutoLock autolock(lock_); 64 base::AutoLock autolock(lock_);
62 InitIfNecessary(); 65 InitIfNecessary();
63 InternalDeleteOriginBoundCert(origin); 66 InternalDeleteOriginBoundCert(origin);
64 } 67 }
65 68
66 void DefaultOriginBoundCertStore::DeleteAll() { 69 void DefaultOriginBoundCertStore::DeleteAll() {
(...skipping 10 matching lines...) Expand all
77 } 80 }
78 81
79 void DefaultOriginBoundCertStore::GetAllOriginBoundCerts( 82 void DefaultOriginBoundCertStore::GetAllOriginBoundCerts(
80 std::vector<OriginBoundCertInfo>* origin_bound_certs) { 83 std::vector<OriginBoundCertInfo>* origin_bound_certs) {
81 base::AutoLock autolock(lock_); 84 base::AutoLock autolock(lock_);
82 InitIfNecessary(); 85 InitIfNecessary();
83 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin(); 86 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin();
84 it != origin_bound_certs_.end(); ++it) { 87 it != origin_bound_certs_.end(); ++it) {
85 OriginBoundCertInfo cert_info = { 88 OriginBoundCertInfo cert_info = {
86 it->second->origin(), 89 it->second->origin(),
90 it->second->type(),
87 it->second->private_key(), 91 it->second->private_key(),
88 it->second->cert() 92 it->second->cert()
89 }; 93 };
90 // TODO(rkn): Make changes so we can simply write 94 // TODO(rkn): Make changes so we can simply write
91 // origin_bound_certs->push_back(*it->second). This is probably best done 95 // origin_bound_certs->push_back(*it->second). This is probably best done
92 // by unnesting the OriginBoundCert class. 96 // by unnesting the OriginBoundCert class.
93 origin_bound_certs->push_back(cert_info); 97 origin_bound_certs->push_back(cert_info);
94 } 98 }
95 } 99 }
96 100
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 159
156 if (store_) 160 if (store_)
157 store_->AddOriginBoundCert(*cert); 161 store_->AddOriginBoundCert(*cert);
158 origin_bound_certs_[origin] = cert; 162 origin_bound_certs_[origin] = cert;
159 } 163 }
160 164
161 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert() {} 165 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert() {}
162 166
163 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert( 167 DefaultOriginBoundCertStore::OriginBoundCert::OriginBoundCert(
164 const std::string& origin, 168 const std::string& origin,
169 OriginBoundCertType type,
165 const std::string& private_key, 170 const std::string& private_key,
166 const std::string& cert) 171 const std::string& cert)
167 : origin_(origin), 172 : origin_(origin),
173 type_(type),
168 private_key_(private_key), 174 private_key_(private_key),
169 cert_(cert) {} 175 cert_(cert) {}
170 176
171 DefaultOriginBoundCertStore::PersistentStore::PersistentStore() {} 177 DefaultOriginBoundCertStore::PersistentStore::PersistentStore() {}
172 178
173 } // namespace net 179 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698