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

Unified Diff: net/cert/nss_cert_database.cc

Issue 2603173002: Use TaskScheduler instead of WorkerPool in nss_cert_database.cc. (Closed)
Patch Set: self-review Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/nss_cert_database.h ('k') | net/cert/nss_cert_database_chromeos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/nss_cert_database.cc
diff --git a/net/cert/nss_cert_database.cc b/net/cert/nss_cert_database.cc
index fc2ae61557ad92eaf53bee47188a9ca1d134c721..33440b3d7fb7522611ad737ce732d1d26eb3a220 100644
--- a/net/cert/nss_cert_database.cc
+++ b/net/cert/nss_cert_database.cc
@@ -18,9 +18,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/observer_list_threadsafe.h"
-#include "base/task_runner.h"
-#include "base/task_runner_util.h"
-#include "base/threading/worker_pool.h"
+#include "base/task_scheduler/post_task.h"
#include "crypto/scoped_nss_types.h"
#include "net/base/crypto_module.h"
#include "net/base/net_errors.h"
@@ -104,8 +102,11 @@ void NSSCertDatabase::ListCerts(
// base::Passed will NULL out |certs|, so cache the underlying pointer here.
CertificateList* raw_certs = certs.get();
- GetSlowTaskRunner()->PostTaskAndReply(
- FROM_HERE,
+ 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)),
@@ -119,8 +120,11 @@ void NSSCertDatabase::ListCertsInSlot(const ListCertsCallback& callback,
// base::Passed will NULL out |certs|, so cache the underlying pointer here.
CertificateList* raw_certs = certs.get();
- GetSlowTaskRunner()->PostTaskAndReply(
- FROM_HERE,
+ base::PostTaskWithTraitsAndReply(
+ FROM_HERE, base::TaskTraits()
+ .WithShutdownBehavior(
+ base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
+ .MayBlock(),
base::Bind(&NSSCertDatabase::ListCertsImpl,
base::Passed(crypto::ScopedPK11Slot(PK11_ReferenceSlot(slot))),
base::Unretained(raw_certs)),
@@ -379,14 +383,14 @@ bool NSSCertDatabase::DeleteCertAndKey(X509Certificate* cert) {
void NSSCertDatabase::DeleteCertAndKeyAsync(
const scoped_refptr<X509Certificate>& cert,
const DeleteCertCallback& callback) {
- base::PostTaskAndReplyWithResult(
- GetSlowTaskRunner().get(),
- FROM_HERE,
+ base::PostTaskWithTraitsAndReplyWithResult(
+ FROM_HERE, base::TaskTraits()
+ .WithShutdownBehavior(
+ base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
+ .MayBlock(),
base::Bind(&NSSCertDatabase::DeleteCertAndKeyImpl, cert),
base::Bind(&NSSCertDatabase::NotifyCertRemovalAndCallBack,
- weak_factory_.GetWeakPtr(),
- cert,
- callback));
+ weak_factory_.GetWeakPtr(), cert, callback));
}
bool NSSCertDatabase::IsReadOnly(const X509Certificate* cert) const {
@@ -407,11 +411,6 @@ 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) {
@@ -432,12 +431,6 @@ 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(
scoped_refptr<X509Certificate> cert,
const DeleteCertCallback& callback,
« no previous file with comments | « net/cert/nss_cert_database.h ('k') | net/cert/nss_cert_database_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698