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

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

Issue 9663017: net: add OCSP tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 8 years, 9 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
« no previous file with comments | « net/data/ssl/certificates/ocsp-test-root.pem ('k') | net/test/base_test_server.h » ('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) 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/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>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 pthread_mutex_t g_request_context_lock = PTHREAD_MUTEX_INITIALIZER; 42 pthread_mutex_t g_request_context_lock = PTHREAD_MUTEX_INITIALIZER;
43 static net::URLRequestContext* g_request_context = NULL; 43 static net::URLRequestContext* g_request_context = NULL;
44 44
45 class OCSPRequestSession; 45 class OCSPRequestSession;
46 46
47 class OCSPIOLoop { 47 class OCSPIOLoop {
48 public: 48 public:
49 void StartUsing() { 49 void StartUsing() {
50 base::AutoLock autolock(lock_); 50 base::AutoLock autolock(lock_);
51 used_ = true; 51 used_ = true;
52 io_loop_ = MessageLoopForIO::current();
53 DCHECK(io_loop_);
52 } 54 }
53 55
54 // Called on IO loop. 56 // Called on IO loop.
55 void Shutdown(); 57 void Shutdown();
56 58
57 bool used() const { 59 bool used() const {
58 base::AutoLock autolock(lock_); 60 base::AutoLock autolock(lock_);
59 return used_; 61 return used_;
60 } 62 }
61 63
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 private: 451 private:
450 std::string host_; 452 std::string host_;
451 int port_; 453 int port_;
452 454
453 DISALLOW_COPY_AND_ASSIGN(OCSPServerSession); 455 DISALLOW_COPY_AND_ASSIGN(OCSPServerSession);
454 }; 456 };
455 457
456 OCSPIOLoop::OCSPIOLoop() 458 OCSPIOLoop::OCSPIOLoop()
457 : shutdown_(false), 459 : shutdown_(false),
458 used_(false), 460 used_(false),
459 io_loop_(MessageLoopForIO::current()) { 461 io_loop_(NULL) {
460 DCHECK(io_loop_);
461 } 462 }
462 463
463 OCSPIOLoop::~OCSPIOLoop() { 464 OCSPIOLoop::~OCSPIOLoop() {
464 // IO thread was already deleted before the singleton is deleted 465 // IO thread was already deleted before the singleton is deleted
465 // in AtExitManager. 466 // in AtExitManager.
466 { 467 {
467 base::AutoLock autolock(lock_); 468 base::AutoLock autolock(lock_);
468 DCHECK(!io_loop_); 469 DCHECK(!io_loop_);
469 DCHECK(!used_); 470 DCHECK(!used_);
470 DCHECK(shutdown_); 471 DCHECK(shutdown_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 base::AutoLock autolock(lock_); 506 base::AutoLock autolock(lock_);
506 DCHECK_EQ(MessageLoopForIO::current(), io_loop_); 507 DCHECK_EQ(MessageLoopForIO::current(), io_loop_);
507 } 508 }
508 509
509 void OCSPIOLoop::AddRequest(OCSPRequestSession* request) { 510 void OCSPIOLoop::AddRequest(OCSPRequestSession* request) {
510 DCHECK(!ContainsKey(requests_, request)); 511 DCHECK(!ContainsKey(requests_, request));
511 requests_.insert(request); 512 requests_.insert(request);
512 } 513 }
513 514
514 void OCSPIOLoop::RemoveRequest(OCSPRequestSession* request) { 515 void OCSPIOLoop::RemoveRequest(OCSPRequestSession* request) {
515 {
516 // Ignore if we've already shutdown.
517 base::AutoLock auto_lock(lock_);
518 if (shutdown_)
519 return;
520 }
521
522 DCHECK(ContainsKey(requests_, request)); 516 DCHECK(ContainsKey(requests_, request));
523 requests_.erase(request); 517 requests_.erase(request);
524 } 518 }
525 519
526 void OCSPIOLoop::CancelAllRequests() { 520 void OCSPIOLoop::CancelAllRequests() {
527 std::set<OCSPRequestSession*> requests; 521 std::set<OCSPRequestSession*> requests;
528 requests.swap(requests_); 522 requests.swap(requests_);
529 523
530 for (std::set<OCSPRequestSession*>::iterator it = requests.begin(); 524 for (std::set<OCSPRequestSession*>::iterator it = requests.begin();
531 it != requests.end(); ++it) 525 it != requests.end(); ++it)
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 void SetURLRequestContextForOCSP(URLRequestContext* request_context) { 932 void SetURLRequestContextForOCSP(URLRequestContext* request_context) {
939 pthread_mutex_lock(&g_request_context_lock); 933 pthread_mutex_lock(&g_request_context_lock);
940 if (request_context) { 934 if (request_context) {
941 DCHECK(!g_request_context); 935 DCHECK(!g_request_context);
942 } 936 }
943 g_request_context = request_context; 937 g_request_context = request_context;
944 pthread_mutex_unlock(&g_request_context_lock); 938 pthread_mutex_unlock(&g_request_context_lock);
945 } 939 }
946 940
947 } // namespace net 941 } // namespace net
OLDNEW
« no previous file with comments | « net/data/ssl/certificates/ocsp-test-root.pem ('k') | net/test/base_test_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698