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

Side by Side Diff: net/cert/x509_certificate.cc

Issue 1082123003: Rename USE_NSS to USE_NSS_CERTS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-nss-certs
Patch Set: rebase Created 5 years, 8 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
« no previous file with comments | « net/cert/x509_certificate.h ('k') | net/cert/x509_certificate_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/cert/x509_certificate.h" 5 #include "net/cert/x509_certificate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 28 matching lines...) Expand all
39 const X509Certificate::Format kFormatDecodePriority[] = { 39 const X509Certificate::Format kFormatDecodePriority[] = {
40 X509Certificate::FORMAT_SINGLE_CERTIFICATE, 40 X509Certificate::FORMAT_SINGLE_CERTIFICATE,
41 X509Certificate::FORMAT_PKCS7 41 X509Certificate::FORMAT_PKCS7
42 }; 42 };
43 43
44 // The PEM block header used for DER certificates 44 // The PEM block header used for DER certificates
45 const char kCertificateHeader[] = "CERTIFICATE"; 45 const char kCertificateHeader[] = "CERTIFICATE";
46 // The PEM block header used for PKCS#7 data 46 // The PEM block header used for PKCS#7 data
47 const char kPKCS7Header[] = "PKCS7"; 47 const char kPKCS7Header[] = "PKCS7";
48 48
49 #if !defined(USE_NSS) 49 #if !defined(USE_NSS_CERTS)
50 // A thread-safe cache for OS certificate handles. 50 // A thread-safe cache for OS certificate handles.
51 // 51 //
52 // Within each of the supported underlying crypto libraries, a certificate 52 // Within each of the supported underlying crypto libraries, a certificate
53 // handle is represented as a ref-counted object that contains the parsed 53 // handle is represented as a ref-counted object that contains the parsed
54 // data for the certificate. In addition, the underlying OS handle may also 54 // data for the certificate. In addition, the underlying OS handle may also
55 // contain a copy of the original ASN.1 DER used to constructed the handle. 55 // contain a copy of the original ASN.1 DER used to constructed the handle.
56 // 56 //
57 // In order to reduce the memory usage when multiple SSL connections exist, 57 // In order to reduce the memory usage when multiple SSL connections exist,
58 // with each connection storing the server's identity certificate plus any 58 // with each connection storing the server's identity certificate plus any
59 // intermediates supplied, the certificate handles are cached. Any two 59 // intermediates supplied, the certificate handles are cached. Any two
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return; // A hash collision where the winning cert is still around. 180 return; // A hash collision where the winning cert is still around.
181 181
182 if (--pos->second.ref_count == 0) { 182 if (--pos->second.ref_count == 0) {
183 // The last reference to |cert_handle| has been removed, so release the 183 // The last reference to |cert_handle| has been removed, so release the
184 // Entry's OS handle and remove the Entry. The caller still holds a 184 // Entry's OS handle and remove the Entry. The caller still holds a
185 // reference to |cert_handle| and is responsible for freeing it. 185 // reference to |cert_handle| and is responsible for freeing it.
186 X509Certificate::FreeOSCertHandle(pos->second.cert_handle); 186 X509Certificate::FreeOSCertHandle(pos->second.cert_handle);
187 cache_.erase(pos); 187 cache_.erase(pos);
188 } 188 }
189 } 189 }
190 #endif // !defined(USE_NSS) 190 #endif // !defined(USE_NSS_CERTS)
191 191
192 // See X509CertificateCache::InsertOrUpdate. NSS has a built-in cache, so there 192 // See X509CertificateCache::InsertOrUpdate. NSS has a built-in cache, so there
193 // is no point in wrapping another cache around it. 193 // is no point in wrapping another cache around it.
194 void InsertOrUpdateCache(X509Certificate::OSCertHandle* cert_handle) { 194 void InsertOrUpdateCache(X509Certificate::OSCertHandle* cert_handle) {
195 #if !defined(USE_NSS) 195 #if !defined(USE_NSS_CERTS)
196 g_x509_certificate_cache.Pointer()->InsertOrUpdate(cert_handle); 196 g_x509_certificate_cache.Pointer()->InsertOrUpdate(cert_handle);
197 #endif 197 #endif
198 } 198 }
199 199
200 // See X509CertificateCache::Remove. 200 // See X509CertificateCache::Remove.
201 void RemoveFromCache(X509Certificate::OSCertHandle cert_handle) { 201 void RemoveFromCache(X509Certificate::OSCertHandle cert_handle) {
202 #if !defined(USE_NSS) 202 #if !defined(USE_NSS_CERTS)
203 g_x509_certificate_cache.Pointer()->Remove(cert_handle); 203 g_x509_certificate_cache.Pointer()->Remove(cert_handle);
204 #endif 204 #endif
205 } 205 }
206 206
207 // Utility to split |src| on the first occurrence of |c|, if any. |right| will 207 // Utility to split |src| on the first occurrence of |c|, if any. |right| will
208 // either be empty if |c| was not found, or will contain the remainder of the 208 // either be empty if |c| was not found, or will contain the remainder of the
209 // string including the split character itself. 209 // string including the split character itself.
210 void SplitOnChar(const base::StringPiece& src, 210 void SplitOnChar(const base::StringPiece& src,
211 char c, 211 char c,
212 base::StringPiece* left, 212 base::StringPiece* left,
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 RemoveFromCache(cert_handle_); 756 RemoveFromCache(cert_handle_);
757 FreeOSCertHandle(cert_handle_); 757 FreeOSCertHandle(cert_handle_);
758 } 758 }
759 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) { 759 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) {
760 RemoveFromCache(intermediate_ca_certs_[i]); 760 RemoveFromCache(intermediate_ca_certs_[i]);
761 FreeOSCertHandle(intermediate_ca_certs_[i]); 761 FreeOSCertHandle(intermediate_ca_certs_[i]);
762 } 762 }
763 } 763 }
764 764
765 } // namespace net 765 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_certificate.h ('k') | net/cert/x509_certificate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698