Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 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 | |
Bob Beck | 5c7a2a0 | 2023-11-20 17:28:21 -0700 | [diff] [blame] | 15 | void MockSignatureVerifyCache::Store(const std::string &key, |
Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 16 | SignatureVerifyCache::Value value) { |
| 17 | cache_.insert_or_assign(key, value); |
| 18 | stores_++; |
| 19 | } |
| 20 | |
| 21 | SignatureVerifyCache::Value MockSignatureVerifyCache::Check( |
Bob Beck | 5c7a2a0 | 2023-11-20 17:28:21 -0700 | [diff] [blame] | 22 | const std::string &key) { |
Bob Beck | bc97b7a | 2023-04-18 08:35:15 -0600 | [diff] [blame] | 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 | |
Bob Beck | 5c7a2a0 | 2023-11-20 17:28:21 -0700 | [diff] [blame] | 32 | } // namespace bssl |