Index: net/cert/nss_cert_database.cc |
diff --git a/net/cert/nss_cert_database.cc b/net/cert/nss_cert_database.cc |
index 14aa891ed6244d883dfcc5ea6b848857ae5813b3..98f6882543cd6b9c8e980b032ab20ce69dadc8f5 100644 |
--- a/net/cert/nss_cert_database.cc |
+++ b/net/cert/nss_cert_database.cc |
@@ -18,7 +18,9 @@ |
#include "base/logging.h" |
#include "base/macros.h" |
#include "base/observer_list_threadsafe.h" |
-#include "base/task_scheduler/post_task.h" |
+#include "base/task_runner.h" |
+#include "base/task_runner_util.h" |
+#include "base/threading/worker_pool.h" |
#include "crypto/scoped_nss_types.h" |
#include "net/base/crypto_module.h" |
#include "net/base/net_errors.h" |
@@ -100,14 +102,10 @@ void NSSCertDatabase::ListCerts( |
// base::Passed will NULL out |certs|, so cache the underlying pointer here. |
CertificateList* raw_certs = certs.get(); |
- base::PostTaskWithTraitsAndReply( |
- FROM_HERE, base::TaskTraits() |
- .WithShutdownBehavior( |
- base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
- .MayBlock(), |
- base::Bind(&NSSCertDatabase::ListCertsImpl, |
- base::Passed(crypto::ScopedPK11Slot()), |
- base::Unretained(raw_certs)), |
+ GetSlowTaskRunner()->PostTaskAndReply( |
+ FROM_HERE, base::Bind(&NSSCertDatabase::ListCertsImpl, |
+ base::Passed(crypto::ScopedPK11Slot()), |
+ base::Unretained(raw_certs)), |
base::Bind(callback, base::Passed(&certs))); |
} |
@@ -118,11 +116,8 @@ void NSSCertDatabase::ListCertsInSlot(const ListCertsCallback& callback, |
// base::Passed will NULL out |certs|, so cache the underlying pointer here. |
CertificateList* raw_certs = certs.get(); |
- base::PostTaskWithTraitsAndReply( |
- FROM_HERE, base::TaskTraits() |
- .WithShutdownBehavior( |
- base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
- .MayBlock(), |
+ GetSlowTaskRunner()->PostTaskAndReply( |
+ FROM_HERE, |
base::Bind(&NSSCertDatabase::ListCertsImpl, |
base::Passed(crypto::ScopedPK11Slot(PK11_ReferenceSlot(slot))), |
base::Unretained(raw_certs)), |
@@ -381,11 +376,8 @@ bool NSSCertDatabase::DeleteCertAndKey(X509Certificate* cert) { |
void NSSCertDatabase::DeleteCertAndKeyAsync( |
const scoped_refptr<X509Certificate>& cert, |
const DeleteCertCallback& callback) { |
- base::PostTaskWithTraitsAndReplyWithResult( |
- FROM_HERE, base::TaskTraits() |
- .WithShutdownBehavior( |
- base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
- .MayBlock(), |
+ base::PostTaskAndReplyWithResult( |
+ GetSlowTaskRunner().get(), FROM_HERE, |
base::Bind(&NSSCertDatabase::DeleteCertAndKeyImpl, cert), |
base::Bind(&NSSCertDatabase::NotifyCertRemovalAndCallBack, |
weak_factory_.GetWeakPtr(), callback)); |
@@ -409,6 +401,11 @@ void NSSCertDatabase::RemoveObserver(Observer* observer) { |
observer_list_->RemoveObserver(observer); |
} |
+void NSSCertDatabase::SetSlowTaskRunnerForTest( |
+ const scoped_refptr<base::TaskRunner>& task_runner) { |
+ slow_task_runner_for_test_ = task_runner; |
+} |
+ |
// static |
void NSSCertDatabase::ListCertsImpl(crypto::ScopedPK11Slot slot, |
CertificateList* certs) { |
@@ -429,6 +426,12 @@ void NSSCertDatabase::ListCertsImpl(crypto::ScopedPK11Slot slot, |
CERT_DestroyCertList(cert_list); |
} |
+scoped_refptr<base::TaskRunner> NSSCertDatabase::GetSlowTaskRunner() const { |
+ if (slow_task_runner_for_test_.get()) |
+ return slow_task_runner_for_test_; |
+ return base::WorkerPool::GetTaskRunner(true /*task is slow*/); |
+} |
+ |
void NSSCertDatabase::NotifyCertRemovalAndCallBack( |
const DeleteCertCallback& callback, |
bool success) { |