| 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/x509_certificate.h" | 5 #include "net/base/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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 base::Lock lock_; | 105 base::Lock lock_; |
| 106 | 106 |
| 107 // The certificate cache. You must acquire |lock_| before using |cache_|. | 107 // The certificate cache. You must acquire |lock_| before using |cache_|. |
| 108 CertMap cache_; | 108 CertMap cache_; |
| 109 | 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(X509CertificateCache); | 110 DISALLOW_COPY_AND_ASSIGN(X509CertificateCache); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 base::LazyInstance<X509CertificateCache, | 113 base::LazyInstance<X509CertificateCache, |
| 114 base::LeakyLazyInstanceTraits<X509CertificateCache> > | 114 base::LeakyLazyInstanceTraits<X509CertificateCache> > |
| 115 g_x509_certificate_cache(base::LINKER_INITIALIZED); | 115 g_x509_certificate_cache = LAZY_INSTANCE_INITIALIZER; |
| 116 | 116 |
| 117 void X509CertificateCache::InsertOrUpdate( | 117 void X509CertificateCache::InsertOrUpdate( |
| 118 X509Certificate::OSCertHandle* cert_handle) { | 118 X509Certificate::OSCertHandle* cert_handle) { |
| 119 DCHECK(cert_handle); | 119 DCHECK(cert_handle); |
| 120 SHA1Fingerprint fingerprint = | 120 SHA1Fingerprint fingerprint = |
| 121 X509Certificate::CalculateFingerprint(*cert_handle); | 121 X509Certificate::CalculateFingerprint(*cert_handle); |
| 122 | 122 |
| 123 X509Certificate::OSCertHandle old_handle = NULL; | 123 X509Certificate::OSCertHandle old_handle = NULL; |
| 124 { | 124 { |
| 125 base::AutoLock lock(lock_); | 125 base::AutoLock lock(lock_); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, | 798 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, |
| 799 const uint8* array, | 799 const uint8* array, |
| 800 size_t array_byte_len) { | 800 size_t array_byte_len) { |
| 801 DCHECK_EQ(0u, array_byte_len % base::kSHA1Length); | 801 DCHECK_EQ(0u, array_byte_len % base::kSHA1Length); |
| 802 const size_t arraylen = array_byte_len / base::kSHA1Length; | 802 const size_t arraylen = array_byte_len / base::kSHA1Length; |
| 803 return NULL != bsearch(hash.data, array, arraylen, base::kSHA1Length, | 803 return NULL != bsearch(hash.data, array, arraylen, base::kSHA1Length, |
| 804 CompareSHA1Hashes); | 804 CompareSHA1Hashes); |
| 805 } | 805 } |
| 806 | 806 |
| 807 } // namespace net | 807 } // namespace net |
| OLD | NEW |