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

Side by Side Diff: net/cert/nss_cert_database.h

Issue 2603173002: Use TaskScheduler instead of WorkerPool in nss_cert_database.cc. (Closed)
Patch Set: Created 3 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
OLDNEW
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_NSS_CERT_DATABASE_H_ 5 #ifndef NET_CERT_NSS_CERT_DATABASE_H_
6 #define NET_CERT_NSS_CERT_DATABASE_H_ 6 #define NET_CERT_NSS_CERT_DATABASE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
19 #include "crypto/scoped_nss_types.h" 19 #include "crypto/scoped_nss_types.h"
20 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
21 #include "net/base/net_export.h" 21 #include "net/base/net_export.h"
22 #include "net/cert/cert_type.h" 22 #include "net/cert/cert_type.h"
23 #include "net/cert/x509_certificate.h" 23 #include "net/cert/x509_certificate.h"
24 24
25 namespace base { 25 namespace base {
26 template <class ObserverType> 26 template <class ObserverType>
27 class ObserverListThreadSafe; 27 class ObserverListThreadSafe;
28 class TaskRunner;
29 } 28 }
30 29
31 namespace net { 30 namespace net {
32 31
33 class CryptoModule; 32 class CryptoModule;
34 typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList; 33 typedef std::vector<scoped_refptr<CryptoModule> > CryptoModuleList;
35 34
36 // Provides functions to manipulate the NSS certificate stores. 35 // Provides functions to manipulate the NSS certificate stores.
37 // Forwards notifications about certificate changes to the global CertDatabase 36 // Forwards notifications about certificate changes to the global CertDatabase
38 // singleton. 37 // singleton.
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // thread. Never calls |callback| synchronously. 241 // thread. Never calls |callback| synchronously.
243 void DeleteCertAndKeyAsync(const scoped_refptr<X509Certificate>& cert, 242 void DeleteCertAndKeyAsync(const scoped_refptr<X509Certificate>& cert,
244 const DeleteCertCallback& callback); 243 const DeleteCertCallback& callback);
245 244
246 // Check whether cert is stored in a readonly slot. 245 // Check whether cert is stored in a readonly slot.
247 bool IsReadOnly(const X509Certificate* cert) const; 246 bool IsReadOnly(const X509Certificate* cert) const;
248 247
249 // Check whether cert is stored in a hardware slot. 248 // Check whether cert is stored in a hardware slot.
250 bool IsHardwareBacked(const X509Certificate* cert) const; 249 bool IsHardwareBacked(const X509Certificate* cert) const;
251 250
252 // Overrides task runner that's used for running slow tasks.
253 void SetSlowTaskRunnerForTest(
254 const scoped_refptr<base::TaskRunner>& task_runner);
255
256 protected: 251 protected:
257 // Certificate listing implementation used by |ListCerts*| and 252 // Certificate listing implementation used by |ListCerts*| and
258 // |ListCertsSync|. Static so it may safely be used on the worker thread. 253 // |ListCertsSync|. Static so it may safely be used on the worker thread.
259 // If |slot| is NULL, obtains the certs of all slots, otherwise only of 254 // If |slot| is NULL, obtains the certs of all slots, otherwise only of
260 // |slot|. 255 // |slot|.
261 static void ListCertsImpl(crypto::ScopedPK11Slot slot, 256 static void ListCertsImpl(crypto::ScopedPK11Slot slot,
262 CertificateList* certs); 257 CertificateList* certs);
263 258
264 // Gets task runner that should be used for slow tasks like certificate
265 // listing. Defaults to a base::WorkerPool runner, but may be overriden
266 // in tests (see SetSlowTaskRunnerForTest).
267 scoped_refptr<base::TaskRunner> GetSlowTaskRunner() const;
268
269 protected: 259 protected:
270 // Broadcasts notifications to all registered observers. 260 // Broadcasts notifications to all registered observers.
271 void NotifyObserversCertDBChanged(const X509Certificate* cert); 261 void NotifyObserversCertDBChanged(const X509Certificate* cert);
272 262
273 private: 263 private:
274 // Registers |observer| to receive notifications of certificate changes. The 264 // Registers |observer| to receive notifications of certificate changes. The
275 // thread on which this is called is the thread on which |observer| will be 265 // thread on which this is called is the thread on which |observer| will be
276 // called back with notifications. 266 // called back with notifications.
277 // NOTE: Observers registered here will only receive notifications generated 267 // NOTE: Observers registered here will only receive notifications generated
278 // directly through the NSSCertDatabase, but not those from the CertDatabase. 268 // directly through the NSSCertDatabase, but not those from the CertDatabase.
(...skipping 13 matching lines...) Expand all
292 // Certificate removal implementation used by |DeleteCertAndKey*|. Static so 282 // Certificate removal implementation used by |DeleteCertAndKey*|. Static so
293 // it may safely be used on the worker thread. 283 // it may safely be used on the worker thread.
294 static bool DeleteCertAndKeyImpl(scoped_refptr<X509Certificate> cert); 284 static bool DeleteCertAndKeyImpl(scoped_refptr<X509Certificate> cert);
295 285
296 crypto::ScopedPK11Slot public_slot_; 286 crypto::ScopedPK11Slot public_slot_;
297 crypto::ScopedPK11Slot private_slot_; 287 crypto::ScopedPK11Slot private_slot_;
298 288
299 // A helper observer that forwards events from this database to CertDatabase. 289 // A helper observer that forwards events from this database to CertDatabase.
300 std::unique_ptr<Observer> cert_notification_forwarder_; 290 std::unique_ptr<Observer> cert_notification_forwarder_;
301 291
302 // Task runner that should be used in tests if set.
303 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_;
304
305 const scoped_refptr<base::ObserverListThreadSafe<Observer>> observer_list_; 292 const scoped_refptr<base::ObserverListThreadSafe<Observer>> observer_list_;
306 293
307 base::WeakPtrFactory<NSSCertDatabase> weak_factory_; 294 base::WeakPtrFactory<NSSCertDatabase> weak_factory_;
308 295
309 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase); 296 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase);
310 }; 297 };
311 298
312 } // namespace net 299 } // namespace net
313 300
314 #endif // NET_CERT_NSS_CERT_DATABASE_H_ 301 #endif // NET_CERT_NSS_CERT_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698