| Index: net/cert/nss_cert_database_chromeos.cc
|
| diff --git a/net/cert/nss_cert_database_chromeos.cc b/net/cert/nss_cert_database_chromeos.cc
|
| index 936287c2204fa75f5b350540d4363d910952760e..ab387ea0311bfac9eb39f86c1f8b4b36f0d07394 100644
|
| --- a/net/cert/nss_cert_database_chromeos.cc
|
| +++ b/net/cert/nss_cert_database_chromeos.cc
|
| @@ -7,6 +7,10 @@
|
| #include <cert.h>
|
| #include <pk11pub.h>
|
|
|
| +#include "base/bind.h"
|
| +#include "base/callback.h"
|
| +#include "base/location.h"
|
| +#include "base/task_runner.h"
|
| #include "net/base/crypto_module.h"
|
| #include "net/cert/x509_certificate.h"
|
|
|
| @@ -16,24 +20,28 @@ NSSCertDatabaseChromeOS::NSSCertDatabaseChromeOS(
|
| crypto::ScopedPK11Slot public_slot,
|
| crypto::ScopedPK11Slot private_slot)
|
| : public_slot_(public_slot.Pass()),
|
| - private_slot_(private_slot.Pass()) {
|
| - profile_filter_.Init(GetPublicSlot(), GetPrivateSlot());
|
| + private_slot_(private_slot.Pass()),
|
| + profile_filter_(new NSSProfileFilterChromeOS) {
|
| + profile_filter_->Init(GetPublicSlot(), GetPrivateSlot());
|
| }
|
|
|
| NSSCertDatabaseChromeOS::~NSSCertDatabaseChromeOS() {}
|
|
|
| -void NSSCertDatabaseChromeOS::ListCerts(CertificateList* certs) {
|
| - NSSCertDatabase::ListCerts(certs);
|
| +void NSSCertDatabaseChromeOS::ListCertsSync(CertificateList* certs) {
|
| + ListCertsImpl(profile_filter_, certs);
|
| +}
|
|
|
| - size_t pre_size = certs->size();
|
| - certs->erase(std::remove_if(
|
| - certs->begin(),
|
| - certs->end(),
|
| - NSSProfileFilterChromeOS::CertNotAllowedForProfilePredicate(
|
| - profile_filter_)),
|
| - certs->end());
|
| - DVLOG(1) << "filtered " << pre_size - certs->size() << " of " << pre_size
|
| - << " certs";
|
| +void NSSCertDatabaseChromeOS::ListCerts(
|
| + const base::Callback<void(scoped_ptr<CertificateList> certs)>& callback) {
|
| + scoped_ptr<CertificateList> certs(new CertificateList());
|
| + CertificateList* raw_certs = certs.get();
|
| +
|
| + GetSlowTaskRunner()->PostTaskAndReply(
|
| + FROM_HERE,
|
| + base::Bind(&NSSCertDatabaseChromeOS::ListCertsImpl,
|
| + profile_filter_,
|
| + base::Unretained(raw_certs)),
|
| + base::Bind(callback, base::Passed(&certs)));
|
| }
|
|
|
| crypto::ScopedPK11Slot NSSCertDatabaseChromeOS::GetPublicSlot() const {
|
| @@ -62,4 +70,20 @@ void NSSCertDatabaseChromeOS::ListModules(CryptoModuleList* modules,
|
| << " modules";
|
| }
|
|
|
| +void NSSCertDatabaseChromeOS::ListCertsImpl(
|
| + const scoped_refptr<NSSProfileFilterChromeOS> profile_filter,
|
| + CertificateList* certs) {
|
| + NSSCertDatabase::ListCertsImpl(certs);
|
| +
|
| + size_t pre_size = certs->size();
|
| + certs->erase(std::remove_if(
|
| + certs->begin(),
|
| + certs->end(),
|
| + NSSProfileFilterChromeOS::CertNotAllowedForProfilePredicate(
|
| + profile_filter)),
|
| + certs->end());
|
| + DVLOG(1) << "filtered " << pre_size - certs->size() << " of " << pre_size
|
| + << " certs";
|
| +}
|
| +
|
| } // namespace net
|
|
|