// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "net/cert/mock_cert_net_fetcher.h" #include "net/cert/x509_util.h" namespace net { MockCertNetFetcher::MockCertNetFetcher() = default; MockCertNetFetcher::~MockCertNetFetcher() = default; MockCertNetFetcherRequest::MockCertNetFetcherRequest(Error error, std::vector bytes) : error_(error), bytes_(std::move(bytes)) {} MockCertNetFetcherRequest::~MockCertNetFetcherRequest() = default; // static std::unique_ptr MockCertNetFetcherRequest::Create( Error error) { return std::make_unique(error, std::vector()); } // static std::unique_ptr MockCertNetFetcherRequest::Create( std::vector bytes) { return std::make_unique(OK, std::move(bytes)); } // static std::unique_ptr MockCertNetFetcherRequest::Create( const CRYPTO_BUFFER* buffer) { auto bytes = x509_util::CryptoBufferAsSpan(buffer); return Create(std::vector(bytes.begin(), bytes.end())); } void MockCertNetFetcherRequest::WaitForResult(Error* error, std::vector* bytes) { DCHECK(!did_consume_result_); *error = error_; *bytes = std::move(bytes_); did_consume_result_ = true; } } // namespace net