| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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/base/keygen_handler.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace net { | |
| 10 | |
| 11 KeygenHandler::Cache* KeygenHandler::Cache::GetInstance() { | |
| 12 return Singleton<Cache>::get(); | |
| 13 } | |
| 14 | |
| 15 void KeygenHandler::Cache::Insert(const std::string& public_key_info, | |
| 16 const KeyLocation& location) { | |
| 17 AutoLock lock(lock_); | |
| 18 | |
| 19 DCHECK(!public_key_info.empty()) << "Only insert valid public key structures"; | |
| 20 cache_[public_key_info] = location; | |
| 21 } | |
| 22 | |
| 23 bool KeygenHandler::Cache::Find(const std::string& public_key_info, | |
| 24 KeyLocation* location) { | |
| 25 AutoLock lock(lock_); | |
| 26 | |
| 27 KeyLocationMap::iterator iter = cache_.find(public_key_info); | |
| 28 | |
| 29 if (iter == cache_.end()) | |
| 30 return false; | |
| 31 | |
| 32 *location = iter->second; | |
| 33 return true; | |
| 34 } | |
| 35 | |
| 36 } // namespace net | |
| OLD | NEW |