1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/cert/internal/cert_issuer_source_static.h"
6 
7 namespace net {
8 
9 CertIssuerSourceStatic::CertIssuerSourceStatic() = default;
10 CertIssuerSourceStatic::~CertIssuerSourceStatic() = default;
11 
AddCert(scoped_refptr<ParsedCertificate> cert)12 void CertIssuerSourceStatic::AddCert(scoped_refptr<ParsedCertificate> cert) {
13   intermediates_.insert(std::make_pair(
14       cert->normalized_subject().AsStringPiece(), std::move(cert)));
15 }
16 
SyncGetIssuersOf(const ParsedCertificate * cert,ParsedCertificateList * issuers)17 void CertIssuerSourceStatic::SyncGetIssuersOf(const ParsedCertificate* cert,
18                                               ParsedCertificateList* issuers) {
19   auto range =
20       intermediates_.equal_range(cert->normalized_issuer().AsStringPiece());
21   for (auto it = range.first; it != range.second; ++it)
22     issuers->push_back(it->second);
23 }
24 
AsyncGetIssuersOf(const ParsedCertificate * cert,std::unique_ptr<Request> * out_req)25 void CertIssuerSourceStatic::AsyncGetIssuersOf(
26     const ParsedCertificate* cert,
27     std::unique_ptr<Request>* out_req) {
28   // CertIssuerSourceStatic never returns asynchronous results.
29   out_req->reset();
30 }
31 
32 }  // namespace net
33