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

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

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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
« no previous file with comments | « net/base/winsock_init.cc ('k') | net/base/x509_certificate_win.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) 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
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
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
OLDNEW
« no previous file with comments | « net/base/winsock_init.cc ('k') | net/base/x509_certificate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698