| Index: net/cert/multi_threaded_cert_verifier.cc
|
| diff --git a/net/cert/multi_threaded_cert_verifier.cc b/net/cert/multi_threaded_cert_verifier.cc
|
| index 8312d413933473f0cd3345b79a527734223d7db3..be213d02b399f0895191da741aedfb891390ec16 100644
|
| --- a/net/cert/multi_threaded_cert_verifier.cc
|
| +++ b/net/cert/multi_threaded_cert_verifier.cc
|
| @@ -18,7 +18,7 @@
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/profiler/scoped_tracker.h"
|
| #include "base/sha1.h"
|
| -#include "base/threading/worker_pool.h"
|
| +#include "base/task_scheduler/post_task.h"
|
| #include "base/time/time.h"
|
| #include "base/trace_event/trace_event.h"
|
| #include "base/values.h"
|
| @@ -179,18 +179,18 @@ class CertVerifierRequest : public base::LinkNode<CertVerifierRequest>,
|
| const NetLogWithSource net_log_;
|
| };
|
|
|
| -// DoVerifyOnWorkerThread runs the verification synchronously on a worker
|
| -// thread. The output parameters (error and result) must remain alive.
|
| -void DoVerifyOnWorkerThread(const scoped_refptr<CertVerifyProc>& verify_proc,
|
| - const scoped_refptr<X509Certificate>& cert,
|
| - const std::string& hostname,
|
| - const std::string& ocsp_response,
|
| - int flags,
|
| - const scoped_refptr<CRLSet>& crl_set,
|
| - const CertificateList& additional_trust_anchors,
|
| - int* error,
|
| - CertVerifyResult* result) {
|
| - TRACE_EVENT0(kNetTracingCategory, "DoVerifyOnWorkerThread");
|
| +// DoVerifyAsync runs the verification in TaskScheduler. The output parameters
|
| +// (error and result) must remain alive.
|
| +void DoVerifyAsync(const scoped_refptr<CertVerifyProc>& verify_proc,
|
| + const scoped_refptr<X509Certificate>& cert,
|
| + const std::string& hostname,
|
| + const std::string& ocsp_response,
|
| + int flags,
|
| + const scoped_refptr<CRLSet>& crl_set,
|
| + const CertificateList& additional_trust_anchors,
|
| + int* error,
|
| + CertVerifyResult* result) {
|
| + TRACE_EVENT0(kNetTracingCategory, "DoVerifyAsync");
|
| *error = verify_proc->Verify(cert.get(), hostname, ocsp_response, flags,
|
| crl_set.get(), additional_trust_anchors, result);
|
|
|
| @@ -233,7 +233,7 @@ class CertVerifierJob {
|
| // Posts a task to the worker pool to do the verification. Once the
|
| // verification has completed on the worker thread, it will call
|
| // OnJobCompleted() on the origin thread.
|
| - bool Start(const scoped_refptr<CertVerifyProc>& verify_proc,
|
| + void Start(const scoped_refptr<CertVerifyProc>& verify_proc,
|
| const scoped_refptr<CRLSet>& crl_set) {
|
| // Owned by the bound reply callback.
|
| std::unique_ptr<ResultHelper> owned_result(new ResultHelper());
|
| @@ -242,15 +242,19 @@ class CertVerifierJob {
|
| // is gotten before calling base::Passed().
|
| auto* result = owned_result.get();
|
|
|
| - return base::WorkerPool::PostTaskAndReply(
|
| - FROM_HERE,
|
| - base::Bind(&DoVerifyOnWorkerThread, verify_proc, key_.certificate(),
|
| + base::PostTaskWithTraitsAndReply(
|
| + FROM_HERE, base::TaskTraits()
|
| + .WithShutdownBehavior(
|
| + base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
|
| + .MayBlock()
|
| + .WithBaseSyncPrimitives(),
|
| + base::Bind(&DoVerifyAsync, verify_proc, key_.certificate(),
|
| key_.hostname(), key_.ocsp_response(), key_.flags(), crl_set,
|
| key_.additional_trust_anchors(), &result->error,
|
| &result->result),
|
| base::Bind(&CertVerifierJob::OnJobCompleted,
|
| - weak_ptr_factory_.GetWeakPtr(), base::Passed(&owned_result)),
|
| - true /* task is slow */);
|
| + weak_ptr_factory_.GetWeakPtr(),
|
| + base::Passed(&owned_result)));
|
| }
|
|
|
| ~CertVerifierJob() {
|
| @@ -372,12 +376,7 @@ int MultiThreadedCertVerifier::Verify(const RequestParams& params,
|
| // Need to make a new job.
|
| std::unique_ptr<CertVerifierJob> new_job =
|
| base::MakeUnique<CertVerifierJob>(params, net_log.net_log(), this);
|
| -
|
| - if (!new_job->Start(verify_proc_, crl_set)) {
|
| - // TODO(wtc): log to the NetLog.
|
| - LOG(ERROR) << "CertVerifierJob couldn't be started.";
|
| - return ERR_INSUFFICIENT_RESOURCES; // Just a guess.
|
| - }
|
| + new_job->Start(verify_proc_, crl_set);
|
|
|
| job = new_job.get();
|
| inflight_[job] = std::move(new_job);
|
|
|