| Index: net/cert/internal/cert_issuer_source_test_helpers.cc
|
| diff --git a/net/cert/internal/cert_issuer_source_test_helpers.cc b/net/cert/internal/cert_issuer_source_test_helpers.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..621ff12261824987e447308a1a7c47c89349aa50
|
| --- /dev/null
|
| +++ b/net/cert/internal/cert_issuer_source_test_helpers.cc
|
| @@ -0,0 +1,81 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "net/cert/internal/cert_issuer_source_test_helpers.h"
|
| +
|
| +namespace net {
|
| +
|
| +namespace {
|
| +
|
| +class StaticAsyncRequest : public CertIssuerSource::Request {
|
| + public:
|
| + StaticAsyncRequest(const CertIssuerSource::IssuerCallback& issuers_callback,
|
| + ParsedCertificateList&& issuers)
|
| + : cancelable_closure_(base::Bind(&StaticAsyncRequest::RunCallback,
|
| + base::Unretained(this))),
|
| + issuers_callback_(issuers_callback) {
|
| + issuers_.swap(issuers);
|
| + issuers_iter_ = issuers_.begin();
|
| + }
|
| + ~StaticAsyncRequest() override {}
|
| +
|
| + CompletionStatus GetNext(
|
| + scoped_refptr<ParsedCertificate>* out_cert) override {
|
| + if (issuers_iter_ == issuers_.end())
|
| + *out_cert = nullptr;
|
| + else
|
| + *out_cert = std::move(*issuers_iter_++);
|
| + return CompletionStatus::SYNC;
|
| + }
|
| +
|
| + base::Closure callback() { return cancelable_closure_.callback(); }
|
| +
|
| + private:
|
| + void RunCallback() { issuers_callback_.Run(this); }
|
| +
|
| + base::CancelableClosure cancelable_closure_;
|
| + CertIssuerSource::IssuerCallback issuers_callback_;
|
| + ParsedCertificateList issuers_;
|
| + ParsedCertificateList::iterator issuers_iter_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(StaticAsyncRequest);
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +AsyncCertIssuerSourceStatic::AsyncCertIssuerSourceStatic() = default;
|
| +AsyncCertIssuerSourceStatic::~AsyncCertIssuerSourceStatic() = default;
|
| +
|
| +void AsyncCertIssuerSourceStatic::AddCert(
|
| + scoped_refptr<ParsedCertificate> cert) {
|
| + static_cert_issuer_source_.AddCert(std::move(cert));
|
| +}
|
| +void AsyncCertIssuerSourceStatic::AsyncGetIssuersOf(
|
| + scoped_refptr<ParsedCertificate> cert,
|
| + const IssuerCallback& issuers_callback,
|
| + std::unique_ptr<Request>* out_req) {
|
| + num_async_gets_++;
|
| + ParsedCertificateList issuers;
|
| + static_cert_issuer_source_.SyncGetIssuersOf(cert.get(), &issuers);
|
| + std::unique_ptr<StaticAsyncRequest> req(
|
| + new StaticAsyncRequest(issuers_callback, std::move(issuers)));
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, req->callback());
|
| + *out_req = std::move(req);
|
| +}
|
| +
|
| +MockCertIssuerSourceRequest::MockCertIssuerSourceRequest() = default;
|
| +MockCertIssuerSourceRequest::~MockCertIssuerSourceRequest() = default;
|
| +
|
| +MockCertIssuerSource::MockCertIssuerSource() = default;
|
| +MockCertIssuerSource::~MockCertIssuerSource() = default;
|
| +
|
| +CertIssuerSourceRequestMover::CertIssuerSourceRequestMover(
|
| + std::unique_ptr<CertIssuerSource::Request> req)
|
| + : request_(std::move(req)) {}
|
| +CertIssuerSourceRequestMover::~CertIssuerSourceRequestMover() = default;
|
| +
|
| +MockIssuerCallback::MockIssuerCallback() = default;
|
| +MockIssuerCallback::~MockIssuerCallback() = default;
|
| +
|
| +} // namespace net
|
|
|