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

Side by Side Diff: net/cert_net/nss_ocsp.cc

Issue 1550853002: Make the OCSP Init Singleton Lazy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | no next file » | 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_net/nss_ocsp.h" 5 #include "net/cert_net/nss_ocsp.h"
6 6
7 #include <certt.h> 7 #include <certt.h>
8 #include <certdb.h> 8 #include <certdb.h>
9 #include <nspr.h> 9 #include <nspr.h>
10 #include <nss.h> 10 #include <nss.h>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 friend struct base::DefaultLazyInstanceTraits<OCSPNSSInitialization>; 164 friend struct base::DefaultLazyInstanceTraits<OCSPNSSInitialization>;
165 165
166 OCSPNSSInitialization(); 166 OCSPNSSInitialization();
167 ~OCSPNSSInitialization(); 167 ~OCSPNSSInitialization();
168 168
169 SEC_HttpClientFcn client_fcn_; 169 SEC_HttpClientFcn client_fcn_;
170 170
171 DISALLOW_COPY_AND_ASSIGN(OCSPNSSInitialization); 171 DISALLOW_COPY_AND_ASSIGN(OCSPNSSInitialization);
172 }; 172 };
173 173
174 base::LazyInstance<OCSPNSSInitialization> g_ocsp_nss_initialization = 174 base::LazyInstance<OCSPNSSInitialization>::Leaky g_ocsp_nss_initialization =
175 LAZY_INSTANCE_INITIALIZER; 175 LAZY_INSTANCE_INITIALIZER;
176 176
177 // Concrete class for SEC_HTTP_REQUEST_SESSION. 177 // Concrete class for SEC_HTTP_REQUEST_SESSION.
178 // Public methods except virtual methods of URLRequest::Delegate 178 // Public methods except virtual methods of URLRequest::Delegate
179 // (On* methods) run on certificate verifier thread (worker thread). 179 // (On* methods) run on certificate verifier thread (worker thread).
180 // Virtual methods of URLRequest::Delegate and private methods run 180 // Virtual methods of URLRequest::Delegate and private methods run
181 // on IO thread. 181 // on IO thread.
182 class OCSPRequestSession 182 class OCSPRequestSession
183 : public base::RefCountedThreadSafe<OCSPRequestSession>, 183 : public base::RefCountedThreadSafe<OCSPRequestSession>,
184 public URLRequest::Delegate { 184 public URLRequest::Delegate {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 status = CERT_RegisterAlternateOCSPAIAInfoCallBack( 587 status = CERT_RegisterAlternateOCSPAIAInfoCallBack(
588 GetAlternateOCSPAIAInfo, &old_callback); 588 GetAlternateOCSPAIAInfo, &old_callback);
589 if (status == SECSuccess) { 589 if (status == SECSuccess) {
590 DCHECK(!old_callback); 590 DCHECK(!old_callback);
591 } else { 591 } else {
592 NOTREACHED() << "Error initializing OCSP: " << PR_GetError(); 592 NOTREACHED() << "Error initializing OCSP: " << PR_GetError();
593 } 593 }
594 } 594 }
595 595
596 OCSPNSSInitialization::~OCSPNSSInitialization() { 596 OCSPNSSInitialization::~OCSPNSSInitialization() {
597 SECStatus status = CERT_RegisterAlternateOCSPAIAInfoCallBack(NULL, NULL);
598 if (status != SECSuccess) {
599 LOG(ERROR) << "Error unregistering OCSP: " << PR_GetError();
600 }
601 } 597 }
602 598
603 599
604 // OCSP Http Client functions. 600 // OCSP Http Client functions.
605 // Our Http Client functions operate in blocking mode. 601 // Our Http Client functions operate in blocking mode.
606 SECStatus OCSPCreateSession(const char* host, PRUint16 portnum, 602 SECStatus OCSPCreateSession(const char* host, PRUint16 portnum,
607 SEC_HTTP_SERVER_SESSION* pSession) { 603 SEC_HTTP_SERVER_SESSION* pSession) {
608 VLOG(1) << "OCSP create session: host=" << host << " port=" << portnum; 604 VLOG(1) << "OCSP create session: host=" << host << " port=" << portnum;
609 pthread_mutex_lock(&g_request_context_lock); 605 pthread_mutex_lock(&g_request_context_lock);
610 URLRequestContext* request_context = g_request_context; 606 URLRequestContext* request_context = g_request_context;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { 962 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) {
967 pthread_mutex_lock(&g_request_context_lock); 963 pthread_mutex_lock(&g_request_context_lock);
968 if (request_context) { 964 if (request_context) {
969 DCHECK(!g_request_context); 965 DCHECK(!g_request_context);
970 } 966 }
971 g_request_context = request_context; 967 g_request_context = request_context;
972 pthread_mutex_unlock(&g_request_context_lock); 968 pthread_mutex_unlock(&g_request_context_lock);
973 } 969 }
974 970
975 } // namespace net 971 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698