xref: /aosp_15_r20/external/cronet/third_party/boringssl/src/pki/mock_signature_verify_cache.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2022 The Chromium Authors
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 "mock_signature_verify_cache.h"
6 
7 #include <algorithm>
8 
9 namespace bssl {
10 
11 MockSignatureVerifyCache::MockSignatureVerifyCache() = default;
12 
13 MockSignatureVerifyCache::~MockSignatureVerifyCache() = default;
14 
Store(const std::string & key,SignatureVerifyCache::Value value)15 void MockSignatureVerifyCache::Store(const std::string &key,
16                                      SignatureVerifyCache::Value value) {
17   cache_.insert_or_assign(key, value);
18   stores_++;
19 }
20 
Check(const std::string & key)21 SignatureVerifyCache::Value MockSignatureVerifyCache::Check(
22     const std::string &key) {
23   auto iter = cache_.find(key);
24   if (iter == cache_.end()) {
25     misses_++;
26     return SignatureVerifyCache::Value::kUnknown;
27   }
28   hits_++;
29   return iter->second;
30 }
31 
32 }  // namespace bssl
33