1 // Copyright 2022 The Chromium Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include "mock_signature_verify_cache.h" 16 17 #include <algorithm> 18 19 BSSL_NAMESPACE_BEGIN 20 21 MockSignatureVerifyCache::MockSignatureVerifyCache() = default; 22 23 MockSignatureVerifyCache::~MockSignatureVerifyCache() = default; 24 Store(const std::string & key,SignatureVerifyCache::Value value)25void MockSignatureVerifyCache::Store(const std::string &key, 26 SignatureVerifyCache::Value value) { 27 cache_.insert_or_assign(key, value); 28 stores_++; 29 } 30 Check(const std::string & key)31SignatureVerifyCache::Value MockSignatureVerifyCache::Check( 32 const std::string &key) { 33 auto iter = cache_.find(key); 34 if (iter == cache_.end()) { 35 misses_++; 36 return SignatureVerifyCache::Value::kUnknown; 37 } 38 hits_++; 39 return iter->second; 40 } 41 42 BSSL_NAMESPACE_END 43