| OLD | NEW |
| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 ++pos->second.ref_count; | 151 ++pos->second.ref_count; |
| 152 *cert_handle = X509Certificate::DupOSCertHandle(pos->second.cert_handle); | 152 *cert_handle = X509Certificate::DupOSCertHandle(pos->second.cert_handle); |
| 153 } | 153 } |
| 154 // If the caller's handle was replaced with a cached handle, free the | 154 // If the caller's handle was replaced with a cached handle, free the |
| 155 // original handle now. This is done outside of the lock because | 155 // original handle now. This is done outside of the lock because |
| 156 // |old_handle| may be the only handle for this particular certificate, so | 156 // |old_handle| may be the only handle for this particular certificate, so |
| 157 // freeing it may be complex or resource-intensive and does not need to | 157 // freeing it may be complex or resource-intensive and does not need to |
| 158 // be guarded by the lock. | 158 // be guarded by the lock. |
| 159 if (old_handle) { | 159 if (old_handle) { |
| 160 X509Certificate::FreeOSCertHandle(old_handle); | 160 X509Certificate::FreeOSCertHandle(old_handle); |
| 161 DHISTOGRAM_COUNTS("X509CertificateReuseCount", 1); | 161 #ifndef NDEBUG |
| 162 LOCAL_HISTOGRAM_BOOLEAN("X509CertificateReuseCount", true); |
| 163 #endif |
| 162 } | 164 } |
| 163 } | 165 } |
| 164 | 166 |
| 165 void X509CertificateCache::Remove(X509Certificate::OSCertHandle cert_handle) { | 167 void X509CertificateCache::Remove(X509Certificate::OSCertHandle cert_handle) { |
| 166 SHA1HashValue fingerprint = | 168 SHA1HashValue fingerprint = |
| 167 X509Certificate::CalculateFingerprint(cert_handle); | 169 X509Certificate::CalculateFingerprint(cert_handle); |
| 168 base::AutoLock lock(lock_); | 170 base::AutoLock lock(lock_); |
| 169 | 171 |
| 170 CertMap::iterator pos = cache_.find(fingerprint); | 172 CertMap::iterator pos = cache_.find(fingerprint); |
| 171 if (pos == cache_.end()) | 173 if (pos == cache_.end()) |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 RemoveFromCache(cert_handle_); | 762 RemoveFromCache(cert_handle_); |
| 761 FreeOSCertHandle(cert_handle_); | 763 FreeOSCertHandle(cert_handle_); |
| 762 } | 764 } |
| 763 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) { | 765 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) { |
| 764 RemoveFromCache(intermediate_ca_certs_[i]); | 766 RemoveFromCache(intermediate_ca_certs_[i]); |
| 765 FreeOSCertHandle(intermediate_ca_certs_[i]); | 767 FreeOSCertHandle(intermediate_ca_certs_[i]); |
| 766 } | 768 } |
| 767 } | 769 } |
| 768 | 770 |
| 769 } // namespace net | 771 } // namespace net |
| OLD | NEW |