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

Side by Side Diff: chromeos/cert_loader.h

Issue 144423007: Make NSSCertDatabase::ListCerts work async on a worker thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: aa Created 6 years, 11 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/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 // Returns true if the global instance has been initialized. 57 // Returns true if the global instance has been initialized.
58 static bool IsInitialized(); 58 static bool IsInitialized();
59 59
60 static std::string GetPkcs11IdForCert(const net::X509Certificate& cert); 60 static std::string GetPkcs11IdForCert(const net::X509Certificate& cert);
61 61
62 // Starts the CertLoader with the NSS cert database. 62 // Starts the CertLoader with the NSS cert database.
63 // The CertLoader will _not_ take the ownership of the database. 63 // The CertLoader will _not_ take the ownership of the database.
64 void StartWithNSSDB(net::NSSCertDatabase* database); 64 void StartWithNSSDB(net::NSSCertDatabase* database);
65 65
66 // Sets the task runner that any slow calls will be made from, e.g. calls
67 // to the NSS database. If not set, uses base::WorkerPool.
68 void SetSlowTaskRunnerForTest(
69 const scoped_refptr<base::TaskRunner>& task_runner);
70
71 void AddObserver(CertLoader::Observer* observer); 66 void AddObserver(CertLoader::Observer* observer);
72 void RemoveObserver(CertLoader::Observer* observer); 67 void RemoveObserver(CertLoader::Observer* observer);
73 68
74 // Whether the certificate is hardware backed. Returns false if the CertLoader 69 // Whether the certificate is hardware backed. Returns false if the CertLoader
75 // was not yet started (both |CertificatesLoading()| and 70 // was not yet started (both |CertificatesLoading()| and
76 // |certificates_loaded()| are false). 71 // |certificates_loaded()| are false).
77 bool IsCertificateHardwareBacked(const net::X509Certificate* cert) const; 72 bool IsCertificateHardwareBacked(const net::X509Certificate* cert) const;
78 73
79 // Returns true when the certificate list has been requested but not loaded. 74 // Returns true when the certificate list has been requested but not loaded.
80 bool CertificatesLoading() const; 75 bool CertificatesLoading() const;
(...skipping 11 matching lines...) Expand all
92 87
93 private: 88 private:
94 CertLoader(); 89 CertLoader();
95 virtual ~CertLoader(); 90 virtual ~CertLoader();
96 91
97 // Trigger a certificate load. If a certificate loading task is already in 92 // Trigger a certificate load. If a certificate loading task is already in
98 // progress, will start a reload once the current task is finished. 93 // progress, will start a reload once the current task is finished.
99 void LoadCertificates(); 94 void LoadCertificates();
100 95
101 // Called if a certificate load task is finished. 96 // Called if a certificate load task is finished.
102 void UpdateCertificates(net::CertificateList* cert_list); 97 void UpdateCertificates(scoped_ptr<net::CertificateList> cert_list);
103 98
104 void NotifyCertificatesLoaded(bool initial_load); 99 void NotifyCertificatesLoaded(bool initial_load);
105 100
106 // net::CertDatabase::Observer 101 // net::CertDatabase::Observer
107 virtual void OnCACertChanged(const net::X509Certificate* cert) OVERRIDE; 102 virtual void OnCACertChanged(const net::X509Certificate* cert) OVERRIDE;
108 virtual void OnCertAdded(const net::X509Certificate* cert) OVERRIDE; 103 virtual void OnCertAdded(const net::X509Certificate* cert) OVERRIDE;
109 virtual void OnCertRemoved(const net::X509Certificate* cert) OVERRIDE; 104 virtual void OnCertRemoved(const net::X509Certificate* cert) OVERRIDE;
110 105
111 ObserverList<Observer> observers_; 106 ObserverList<Observer> observers_;
112 107
(...skipping 12 matching lines...) Expand all
125 120
126 // Whether |database_| is hardware backed. 121 // Whether |database_| is hardware backed.
127 bool is_hardware_backed_; 122 bool is_hardware_backed_;
128 bool hardware_backed_for_test_; 123 bool hardware_backed_for_test_;
129 124
130 // Cached Certificates loaded from the database. 125 // Cached Certificates loaded from the database.
131 net::CertificateList cert_list_; 126 net::CertificateList cert_list_;
132 127
133 base::ThreadChecker thread_checker_; 128 base::ThreadChecker thread_checker_;
134 129
135 // TaskRunner that, if set, replaces base::WorkerPool. Should only be set in
136 // tests.
137 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_;
138
139 base::WeakPtrFactory<CertLoader> weak_factory_; 130 base::WeakPtrFactory<CertLoader> weak_factory_;
140 131
141 DISALLOW_COPY_AND_ASSIGN(CertLoader); 132 DISALLOW_COPY_AND_ASSIGN(CertLoader);
142 }; 133 };
143 134
144 } // namespace chromeos 135 } // namespace chromeos
145 136
146 #endif // CHROMEOS_CERT_LOADER_H_ 137 #endif // CHROMEOS_CERT_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698