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

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

Issue 6338002: net: Remove typedef net::URLRequestContext URLRequestContext; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for real Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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/ocsp/nss_ocsp.h" 5 #include "net/ocsp/nss_ocsp.h"
6 6
7 #include <certt.h> 7 #include <certt.h>
8 #include <certdb.h> 8 #include <certdb.h>
9 #include <ocsp.h> 9 #include <ocsp.h>
10 #include <nspr.h> 10 #include <nspr.h>
11 #include <nss.h> 11 #include <nss.h>
(...skipping 20 matching lines...) Expand all
32 #include "net/base/load_flags.h" 32 #include "net/base/load_flags.h"
33 #include "net/http/http_request_headers.h" 33 #include "net/http/http_request_headers.h"
34 #include "net/http/http_response_headers.h" 34 #include "net/http/http_response_headers.h"
35 #include "net/url_request/url_request.h" 35 #include "net/url_request/url_request.h"
36 #include "net/url_request/url_request_context.h" 36 #include "net/url_request/url_request_context.h"
37 37
38 namespace { 38 namespace {
39 39
40 // Protects |g_request_context|. 40 // Protects |g_request_context|.
41 pthread_mutex_t g_request_context_lock = PTHREAD_MUTEX_INITIALIZER; 41 pthread_mutex_t g_request_context_lock = PTHREAD_MUTEX_INITIALIZER;
42 static URLRequestContext* g_request_context = NULL; 42 static net::URLRequestContext* g_request_context = NULL;
43 43
44 class OCSPRequestSession; 44 class OCSPRequestSession;
45 45
46 class OCSPIOLoop { 46 class OCSPIOLoop {
47 public: 47 public:
48 void StartUsing() { 48 void StartUsing() {
49 base::AutoLock autolock(lock_); 49 base::AutoLock autolock(lock_);
50 used_ = true; 50 used_ = true;
51 } 51 }
52 52
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 FROM_HERE, 342 FROM_HERE,
343 NewRunnableMethod(this, &OCSPRequestSession::CancelURLRequest)); 343 NewRunnableMethod(this, &OCSPRequestSession::CancelURLRequest));
344 } 344 }
345 } 345 }
346 346
347 // Runs on |g_ocsp_io_loop|'s IO loop. 347 // Runs on |g_ocsp_io_loop|'s IO loop.
348 void StartURLRequest() { 348 void StartURLRequest() {
349 DCHECK(!request_); 349 DCHECK(!request_);
350 350
351 pthread_mutex_lock(&g_request_context_lock); 351 pthread_mutex_lock(&g_request_context_lock);
352 URLRequestContext* url_request_context = g_request_context; 352 net::URLRequestContext* url_request_context = g_request_context;
353 pthread_mutex_unlock(&g_request_context_lock); 353 pthread_mutex_unlock(&g_request_context_lock);
354 354
355 if (url_request_context == NULL) 355 if (url_request_context == NULL)
356 return; 356 return;
357 357
358 { 358 {
359 base::AutoLock autolock(lock_); 359 base::AutoLock autolock(lock_);
360 DCHECK(!io_loop_); 360 DCHECK(!io_loop_);
361 io_loop_ = MessageLoopForIO::current(); 361 io_loop_ = MessageLoopForIO::current();
362 g_ocsp_io_loop.Get().AddRequest(this); 362 g_ocsp_io_loop.Get().AddRequest(this);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 568
569 OCSPNSSInitialization::~OCSPNSSInitialization() {} 569 OCSPNSSInitialization::~OCSPNSSInitialization() {}
570 570
571 571
572 // OCSP Http Client functions. 572 // OCSP Http Client functions.
573 // Our Http Client functions operate in blocking mode. 573 // Our Http Client functions operate in blocking mode.
574 SECStatus OCSPCreateSession(const char* host, PRUint16 portnum, 574 SECStatus OCSPCreateSession(const char* host, PRUint16 portnum,
575 SEC_HTTP_SERVER_SESSION* pSession) { 575 SEC_HTTP_SERVER_SESSION* pSession) {
576 VLOG(1) << "OCSP create session: host=" << host << " port=" << portnum; 576 VLOG(1) << "OCSP create session: host=" << host << " port=" << portnum;
577 pthread_mutex_lock(&g_request_context_lock); 577 pthread_mutex_lock(&g_request_context_lock);
578 URLRequestContext* request_context = g_request_context; 578 net::URLRequestContext* request_context = g_request_context;
579 pthread_mutex_unlock(&g_request_context_lock); 579 pthread_mutex_unlock(&g_request_context_lock);
580 if (request_context == NULL) { 580 if (request_context == NULL) {
581 LOG(ERROR) << "No URLRequestContext for OCSP handler."; 581 LOG(ERROR) << "No URLRequestContext for OCSP handler.";
582 // The application failed to call SetURLRequestContextForOCSP, so we 582 // The application failed to call SetURLRequestContextForOCSP, so we
583 // can't create and use net::URLRequest. PR_NOT_IMPLEMENTED_ERROR is not an 583 // can't create and use net::URLRequest. PR_NOT_IMPLEMENTED_ERROR is not an
584 // accurate error code for this error condition, but is close enough. 584 // accurate error code for this error condition, but is close enough.
585 PORT_SetError(PR_NOT_IMPLEMENTED_ERROR); 585 PORT_SetError(PR_NOT_IMPLEMENTED_ERROR);
586 return SECFailure; 586 return SECFailure;
587 } 587 }
588 *pSession = new OCSPServerSession(host, portnum); 588 *pSession = new OCSPServerSession(host, portnum);
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 909
910 URLRequestContext* GetURLRequestContextForOCSP() { 910 URLRequestContext* GetURLRequestContextForOCSP() {
911 pthread_mutex_lock(&g_request_context_lock); 911 pthread_mutex_lock(&g_request_context_lock);
912 URLRequestContext* request_context = g_request_context; 912 URLRequestContext* request_context = g_request_context;
913 pthread_mutex_unlock(&g_request_context_lock); 913 pthread_mutex_unlock(&g_request_context_lock);
914 DCHECK(!request_context || request_context->is_main()); 914 DCHECK(!request_context || request_context->is_main());
915 return request_context; 915 return request_context;
916 } 916 }
917 917
918 } // namespace net 918 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698