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

Side by Side Diff: chromeos/cert_loader.h

Issue 20087002: Add migration from CaCert NSS nicknames to PEM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed indentation. Created 7 years, 4 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) 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 bool initial_load) = 0; 47 bool initial_load) = 0;
48 48
49 protected: 49 protected:
50 Observer() {} 50 Observer() {}
51 51
52 private: 52 private:
53 DISALLOW_COPY_AND_ASSIGN(Observer); 53 DISALLOW_COPY_AND_ASSIGN(Observer);
54 }; 54 };
55 55
56 // Sets the global instance. Must be called before any calls to Get(). 56 // Sets the global instance. Must be called before any calls to Get().
57 static void Initialize(); 57 // |task_runner| is the task runner that any slow calls will be made from,
58 // e.g. calls to the NSS database.
59 static void Initialize(const scoped_refptr<base::TaskRunner>& task_runner);
58 60
59 // Destroys the global instance. 61 // Destroys the global instance.
60 static void Shutdown(); 62 static void Shutdown();
61 63
62 // Gets the global instance. Initialize() must be called first. 64 // Gets the global instance. Initialize() must be called first.
63 static CertLoader* Get(); 65 static CertLoader* Get();
64 66
65 // Returns true if the global instance has been initialized. 67 // Returns true if the global instance has been initialized.
66 static bool IsInitialized(); 68 static bool IsInitialized();
67 69
68 // |crypto_task_runner| is the task runner that any synchronous crypto calls 70 // |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 71 // 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 72 // after the thread is started. Certificate loading will not happen unless
71 // this is set. 73 // this is set.
72 void SetCryptoTaskRunner( 74 void SetCryptoTaskRunner(
73 const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner); 75 const scoped_refptr<base::SequencedTaskRunner>& crypto_task_runner);
74 76
75 void AddObserver(CertLoader::Observer* observer); 77 void AddObserver(CertLoader::Observer* observer);
76 void RemoveObserver(CertLoader::Observer* observer); 78 void RemoveObserver(CertLoader::Observer* observer);
77 79
78 // Returns true when the certificate list has been requested but not loaded. 80 // Returns true when the certificate list has been requested but not loaded.
79 bool CertificatesLoading() const; 81 bool CertificatesLoading() const;
80 82
81 // Returns true if the TPM is available for hardware-backed certificates. 83 // Returns true if the TPM is available for hardware-backed certificates.
82 bool IsHardwareBacked() const; 84 bool IsHardwareBacked() const;
83 85
84 std::string GetPkcs11IdForCert(const net::X509Certificate& cert) const; 86 std::string GetPkcs11IdForCert(const net::X509Certificate& cert) const;
85 87
86 bool certificates_loaded() const { return certificates_loaded_; } 88 bool certificates_loaded() const { return certificates_loaded_; }
87 89
88 // TPM info is only valid once the TPM is available (IsHardwareBacked is 90 // TPM info is only valid once the TPM is available (IsHardwareBacked is
89 // true). Otherwise empty strings will be returned. 91 // true). Otherwise empty strings will be returned.
90 const std::string& tpm_token_name() const { return tpm_token_name_; } 92 const std::string& tpm_token_name() const { return tpm_token_name_; }
91 const std::string& tpm_token_slot() const { return tpm_token_slot_; } 93 const std::string& tpm_token_slot() const { return tpm_token_slot_; }
92 const std::string& tpm_user_pin() const { return tpm_user_pin_; } 94 const std::string& tpm_user_pin() const { return tpm_user_pin_; }
93 95
94 // This will be empty until certificates_loaded() is true. 96 // This will be empty until certificates_loaded() is true.
95 const net::CertificateList& cert_list() const { return cert_list_; } 97 const net::CertificateList& cert_list() const { return cert_list_; }
96 98
97 private: 99 private:
98 CertLoader(); 100 explicit CertLoader(const scoped_refptr<base::TaskRunner>& task_runner);
99 virtual ~CertLoader(); 101 virtual ~CertLoader();
100 102
101 void Init(); 103 void Init();
102 void MaybeRequestCertificates(); 104 void MaybeRequestCertificates();
103 105
104 // This is the cyclic chain of callbacks to initialize the TPM token and to 106 // This is the cyclic chain of callbacks to initialize the TPM token and to
105 // kick off the update of the certificate list. 107 // kick off the update of the certificate list.
106 void InitializeTokenAndLoadCertificates(); 108 void InitializeTokenAndLoadCertificates();
107 void RetryTokenInitializationLater(); 109 void RetryTokenInitializationLater();
108 void OnPersistentNSSDBOpened(); 110 void OnPersistentNSSDBOpened();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 std::string tpm_user_pin_; 162 std::string tpm_user_pin_;
161 163
162 // Cached Certificates. 164 // Cached Certificates.
163 net::CertificateList cert_list_; 165 net::CertificateList cert_list_;
164 166
165 base::ThreadChecker thread_checker_; 167 base::ThreadChecker thread_checker_;
166 168
167 // TaskRunner for crypto calls. 169 // TaskRunner for crypto calls.
168 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_; 170 scoped_refptr<base::SequencedTaskRunner> crypto_task_runner_;
169 171
172 // TaskRunner for slow tasks.
173 scoped_refptr<base::TaskRunner> worker_pool_task_runner_;
174
170 // This factory should be used only for callbacks during TPMToken 175 // This factory should be used only for callbacks during TPMToken
171 // initialization. 176 // initialization.
172 base::WeakPtrFactory<CertLoader> initialize_token_factory_; 177 base::WeakPtrFactory<CertLoader> initialize_token_factory_;
173 178
174 // This factory should be used only for callbacks during updating the 179 // This factory should be used only for callbacks during updating the
175 // certificate list. 180 // certificate list.
176 base::WeakPtrFactory<CertLoader> update_certificates_factory_; 181 base::WeakPtrFactory<CertLoader> update_certificates_factory_;
177 182
178 DISALLOW_COPY_AND_ASSIGN(CertLoader); 183 DISALLOW_COPY_AND_ASSIGN(CertLoader);
179 }; 184 };
180 185
181 } // namespace chromeos 186 } // namespace chromeos
182 187
183 #endif // CHROMEOS_CERT_LOADER_H_ 188 #endif // CHROMEOS_CERT_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698