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 #ifndef NET_CERT_TEST_ROOT_CERTS_H_ | 5 #ifndef NET_CERT_TEST_ROOT_CERTS_H_ |
6 #define NET_CERT_TEST_ROOT_CERTS_H_ | 6 #define NET_CERT_TEST_ROOT_CERTS_H_ |
7 | 7 |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 bool empty_; | 143 bool empty_; |
144 #endif | 144 #endif |
145 | 145 |
146 DISALLOW_COPY_AND_ASSIGN(TestRootCerts); | 146 DISALLOW_COPY_AND_ASSIGN(TestRootCerts); |
147 }; | 147 }; |
148 | 148 |
149 // Scoped helper for unittests to handle safely managing trusted roots. | 149 // Scoped helper for unittests to handle safely managing trusted roots. |
150 class NET_EXPORT_PRIVATE ScopedTestRoot { | 150 class NET_EXPORT_PRIVATE ScopedTestRoot { |
151 public: | 151 public: |
152 ScopedTestRoot(); | 152 ScopedTestRoot(); |
153 // Creates a ScopedTestRoot that will adds|cert| to the TestRootCerts store. | 153 // Creates a ScopedTestRoot that will add |cert| to the TestRootCerts store. |
154 explicit ScopedTestRoot(X509Certificate* cert); | 154 explicit ScopedTestRoot(X509Certificate* cert); |
155 ~ScopedTestRoot(); | 155 ~ScopedTestRoot(); |
156 | 156 |
157 // Assigns |cert| to be the new test root cert. If |cert| is NULL, undoes | 157 // Assigns |cert| to be the new test root cert. If |cert| is NULL, undoes |
158 // any work the ScopedTestRoot may have previously done. | 158 // any work the ScopedTestRoot may have previously done. |
159 // If |cert_| contains a certificate (due to a prior call to Reset or due to | 159 // If |cert_| contains a certificate (due to a prior call to Reset or due to |
160 // a cert being passed at construction), the existing TestRootCerts store is | 160 // a cert being passed at construction), the existing TestRootCerts store is |
161 // cleared. | 161 // cleared. |
162 void Reset(X509Certificate* cert); | 162 void Reset(X509Certificate* cert); |
163 | 163 |
164 private: | 164 private: |
165 scoped_refptr<X509Certificate> cert_; | 165 scoped_refptr<X509Certificate> cert_; |
166 | 166 |
167 DISALLOW_COPY_AND_ASSIGN(ScopedTestRoot); | 167 DISALLOW_COPY_AND_ASSIGN(ScopedTestRoot); |
168 }; | 168 }; |
169 | 169 |
170 } // namespace net | 170 } // namespace net |
171 | 171 |
172 #endif // NET_CERT_TEST_ROOT_CERTS_H_ | 172 #endif // NET_CERT_TEST_ROOT_CERTS_H_ |
OLD | NEW |