OLD | NEW |
---|---|
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 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 base::AutoLock autolock(lock_); | 51 base::AutoLock autolock(lock_); |
52 InitIfNecessary(); | 52 InitIfNecessary(); |
53 | 53 |
54 InternalDeleteOriginBoundCert(origin); | 54 InternalDeleteOriginBoundCert(origin); |
55 InternalInsertOriginBoundCert(origin, | 55 InternalInsertOriginBoundCert(origin, |
56 new OriginBoundCert(origin, private_key, cert)); | 56 new OriginBoundCert(origin, private_key, cert)); |
57 | 57 |
58 return true; | 58 return true; |
59 } | 59 } |
60 | 60 |
61 void DefaultOriginBoundCertStore::DeleteOriginBoundCert( | |
62 const std::string& origin) { | |
63 base::AutoLock autolock(lock_); | |
64 InitIfNecessary(); | |
65 InternalDeleteOriginBoundCert(origin); | |
66 } | |
67 | |
68 void DefaultOriginBoundCertStore::DeleteAll() { | |
69 base::AutoLock autolock(lock_); | |
70 InitIfNecessary(); | |
71 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin(); | |
72 it != origin_bound_certs_.end(); ++it) { | |
73 InternalDeleteOriginBoundCert(it->second->origin()); | |
74 } | |
75 } | |
76 | |
77 void DefaultOriginBoundCertStore::GetAllOriginBoundCerts( | |
78 std::vector<OriginBoundCertInfo>* origin_bound_certs) { | |
79 base::AutoLock autolock(lock_); | |
80 InitIfNecessary(); | |
81 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin(); | |
82 it != origin_bound_certs_.end(); ++it) { | |
83 struct OriginBoundCertInfo cert_info = { | |
wtc
2011/08/10 21:35:59
Remove "struct".
We should be able to just do
o
| |
84 it->second->origin(), | |
85 it->second->private_key(), | |
86 it->second->cert() | |
87 }; | |
88 origin_bound_certs->push_back(cert_info); | |
89 } | |
90 } | |
91 | |
61 int DefaultOriginBoundCertStore::GetCertCount() { | 92 int DefaultOriginBoundCertStore::GetCertCount() { |
62 base::AutoLock autolock(lock_); | 93 base::AutoLock autolock(lock_); |
63 InitIfNecessary(); | 94 InitIfNecessary(); |
64 | 95 |
65 return origin_bound_certs_.size(); | 96 return origin_bound_certs_.size(); |
66 } | 97 } |
67 | 98 |
68 DefaultOriginBoundCertStore::~DefaultOriginBoundCertStore() { | 99 DefaultOriginBoundCertStore::~DefaultOriginBoundCertStore() { |
69 DeleteAll(); | 100 DeleteAllInMemory(); |
70 } | 101 } |
71 | 102 |
72 void DefaultOriginBoundCertStore::DeleteAll() { | 103 void DefaultOriginBoundCertStore::DeleteAllInMemory() { |
73 base::AutoLock autolock(lock_); | 104 base::AutoLock autolock(lock_); |
74 | 105 |
75 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin(); | 106 for (OriginBoundCertMap::iterator it = origin_bound_certs_.begin(); |
76 it != origin_bound_certs_.end(); it++) { | 107 it != origin_bound_certs_.end(); ++it) { |
77 delete it->second; | 108 delete it->second; |
78 } | 109 } |
79 origin_bound_certs_.clear(); | 110 origin_bound_certs_.clear(); |
80 } | 111 } |
81 | 112 |
82 void DefaultOriginBoundCertStore::InitStore() { | 113 void DefaultOriginBoundCertStore::InitStore() { |
83 lock_.AssertAcquired(); | 114 lock_.AssertAcquired(); |
84 | 115 |
85 DCHECK(store_) << "Store must exist to initialize"; | 116 DCHECK(store_) << "Store must exist to initialize"; |
86 | 117 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 const std::string& origin, | 159 const std::string& origin, |
129 const std::string& private_key, | 160 const std::string& private_key, |
130 const std::string& cert) | 161 const std::string& cert) |
131 : origin_(origin), | 162 : origin_(origin), |
132 private_key_(private_key), | 163 private_key_(private_key), |
133 cert_(cert) {} | 164 cert_(cert) {} |
134 | 165 |
135 DefaultOriginBoundCertStore::PersistentStore::PersistentStore() {} | 166 DefaultOriginBoundCertStore::PersistentStore::PersistentStore() {} |
136 | 167 |
137 } // namespace net | 168 } // namespace net |
OLD | NEW |