OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROMEOS_CERT_LOADER_H_ | 5 #ifndef CHROMEOS_CERT_LOADER_H_ |
6 #define CHROMEOS_CERT_LOADER_H_ | 6 #define CHROMEOS_CERT_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Destroys the global instance. | 59 // Destroys the global instance. |
60 static void Shutdown(); | 60 static void Shutdown(); |
61 | 61 |
62 // Gets the global instance. Initialize() must be called first. | 62 // Gets the global instance. Initialize() must be called first. |
63 static CertLoader* Get(); | 63 static CertLoader* Get(); |
64 | 64 |
65 // Returns true if the global instance has been initialized. | 65 // Returns true if the global instance has been initialized. |
66 static bool IsInitialized(); | 66 static bool IsInitialized(); |
67 | 67 |
68 // |crypto_task_runner| is the task runner that any synchronous crypto calls | 68 // |crypto_task_runner| is the task runner that any synchronous crypto calls |
69 // should be made from. e.g. in Chrome this is the IO thread. Must be called | 69 // should be made from, e.g. in Chrome this is the IO thread. Must be called |
70 // after the thread is started. Certificate loading will not happen unless | 70 // after the thread is started. Certificate loading will not happen unless |
71 // this is set. | 71 // this is set. |
72 void SetCryptoTaskRunner( | 72 void SetCryptoTaskRunner( |
73 const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner); | 73 const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner); |
74 | 74 |
| 75 // Sets the task runner that any slow calls will be made from, e.g. calls |
| 76 // to the NSS database. If not set, uses base::WorkerPool. |
| 77 void SetSlowTaskRunnerForTest( |
| 78 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| 79 |
75 void AddObserver(CertLoader::Observer* observer); | 80 void AddObserver(CertLoader::Observer* observer); |
76 void RemoveObserver(CertLoader::Observer* observer); | 81 void RemoveObserver(CertLoader::Observer* observer); |
77 | 82 |
78 // Returns true when the certificate list has been requested but not loaded. | 83 // Returns true when the certificate list has been requested but not loaded. |
79 bool CertificatesLoading() const; | 84 bool CertificatesLoading() const; |
80 | 85 |
81 // Returns true if the TPM is available for hardware-backed certificates. | 86 // Returns true if the TPM is available for hardware-backed certificates. |
82 bool IsHardwareBacked() const; | 87 bool IsHardwareBacked() const; |
83 | 88 |
84 std::string GetPkcs11IdForCert(const net::X509Certificate& cert) const; | 89 std::string GetPkcs11IdForCert(const net::X509Certificate& cert) const; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 std::string tpm_user_pin_; | 165 std::string tpm_user_pin_; |
161 | 166 |
162 // Cached Certificates. | 167 // Cached Certificates. |
163 net::CertificateList cert_list_; | 168 net::CertificateList cert_list_; |
164 | 169 |
165 base::ThreadChecker thread_checker_; | 170 base::ThreadChecker thread_checker_; |
166 | 171 |
167 // TaskRunner for crypto calls. | 172 // TaskRunner for crypto calls. |
168 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_; | 173 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_; |
169 | 174 |
| 175 // TaskRunner for other slow tasks. May be set in tests. |
| 176 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; |
| 177 |
170 // This factory should be used only for callbacks during TPMToken | 178 // This factory should be used only for callbacks during TPMToken |
171 // initialization. | 179 // initialization. |
172 base::WeakPtrFactory<CertLoader> initialize_token_factory_; | 180 base::WeakPtrFactory<CertLoader> initialize_token_factory_; |
173 | 181 |
174 // This factory should be used only for callbacks during updating the | 182 // This factory should be used only for callbacks during updating the |
175 // certificate list. | 183 // certificate list. |
176 base::WeakPtrFactory<CertLoader> update_certificates_factory_; | 184 base::WeakPtrFactory<CertLoader> update_certificates_factory_; |
177 | 185 |
178 DISALLOW_COPY_AND_ASSIGN(CertLoader); | 186 DISALLOW_COPY_AND_ASSIGN(CertLoader); |
179 }; | 187 }; |
180 | 188 |
181 } // namespace chromeos | 189 } // namespace chromeos |
182 | 190 |
183 #endif // CHROMEOS_CERT_LOADER_H_ | 191 #endif // CHROMEOS_CERT_LOADER_H_ |
OLD | NEW |