OLD | NEW |
---|---|
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 71 |
72 // Called from worker thread. | 72 // Called from worker thread. |
73 void PostTaskToIOLoop(const tracked_objects::Location& from_here, | 73 void PostTaskToIOLoop(const tracked_objects::Location& from_here, |
74 const base::Closure& task); | 74 const base::Closure& task); |
75 | 75 |
76 void EnsureIOLoop(); | 76 void EnsureIOLoop(); |
77 | 77 |
78 void AddRequest(OCSPRequestSession* request); | 78 void AddRequest(OCSPRequestSession* request); |
79 void RemoveRequest(OCSPRequestSession* request); | 79 void RemoveRequest(OCSPRequestSession* request); |
80 | 80 |
81 // Clears internal state and calls |StartUsing()|. Should be called only in | |
82 // the context of testing. | |
83 void ReuseForTesting() { | |
84 { | |
85 base::AutoLock autolock(lock_); | |
86 DCHECK(MessageLoopForIO::current()); | |
87 thread_checker_.DetachFromThread(); | |
88 thread_checker_.CalledOnValidThread(); | |
Nico
2013/11/05 03:01:30
As is, this is a no-op. You probably meant to DCHE
blundell
2013/11/05 16:01:33
This call is not a no-op: it associates |thread_ch
Nico
2013/11/05 16:29:54
Aha! This seems to be only place in the codebase w
| |
89 shutdown_ = false; | |
90 used_ = false; | |
91 } | |
92 StartUsing(); | |
93 } | |
94 | |
81 private: | 95 private: |
82 friend struct base::DefaultLazyInstanceTraits<OCSPIOLoop>; | 96 friend struct base::DefaultLazyInstanceTraits<OCSPIOLoop>; |
83 | 97 |
84 OCSPIOLoop(); | 98 OCSPIOLoop(); |
85 ~OCSPIOLoop(); | 99 ~OCSPIOLoop(); |
86 | 100 |
87 void CancelAllRequests(); | 101 void CancelAllRequests(); |
88 | 102 |
89 mutable base::Lock lock_; | 103 mutable base::Lock lock_; |
90 bool shutdown_; // Protected by |lock_|. | 104 bool shutdown_; // Protected by |lock_|. |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 | 941 |
928 void EnsureNSSHttpIOInit() { | 942 void EnsureNSSHttpIOInit() { |
929 g_ocsp_io_loop.Get().StartUsing(); | 943 g_ocsp_io_loop.Get().StartUsing(); |
930 g_ocsp_nss_initialization.Get(); | 944 g_ocsp_nss_initialization.Get(); |
931 } | 945 } |
932 | 946 |
933 void ShutdownNSSHttpIO() { | 947 void ShutdownNSSHttpIO() { |
934 g_ocsp_io_loop.Get().Shutdown(); | 948 g_ocsp_io_loop.Get().Shutdown(); |
935 } | 949 } |
936 | 950 |
951 void ResetNSSHttpIOForTesting() { | |
952 g_ocsp_io_loop.Get().ReuseForTesting(); | |
953 } | |
954 | |
937 // This function would be called before NSS initialization. | 955 // This function would be called before NSS initialization. |
938 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { | 956 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { |
939 pthread_mutex_lock(&g_request_context_lock); | 957 pthread_mutex_lock(&g_request_context_lock); |
940 if (request_context) { | 958 if (request_context) { |
941 DCHECK(!g_request_context); | 959 DCHECK(!g_request_context); |
942 } | 960 } |
943 g_request_context = request_context; | 961 g_request_context = request_context; |
944 pthread_mutex_unlock(&g_request_context_lock); | 962 pthread_mutex_unlock(&g_request_context_lock); |
945 } | 963 } |
946 | 964 |
947 } // namespace net | 965 } // namespace net |
OLD | NEW |