| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/ssl_client_auth_cache.h" | 5 #include "net/base/ssl_client_auth_cache.h" |
| 6 | 6 |
| 7 #include "base/logging.h" |
| 8 #include "net/base/x509_certificate.h" |
| 9 |
| 7 namespace net { | 10 namespace net { |
| 8 | 11 |
| 9 SSLClientAuthCache::SSLClientAuthCache() {} | 12 SSLClientAuthCache::SSLClientAuthCache() {} |
| 10 | 13 |
| 11 SSLClientAuthCache::~SSLClientAuthCache() {} | 14 SSLClientAuthCache::~SSLClientAuthCache() {} |
| 12 | 15 |
| 13 X509Certificate* SSLClientAuthCache::Lookup(const std::string& server) { | 16 bool SSLClientAuthCache::Lookup(const std::string& server, |
| 17 X509Certificate** certificate) { |
| 18 DCHECK(certificate); |
| 19 *certificate = NULL; |
| 20 |
| 14 AuthCacheMap::iterator iter = cache_.find(server); | 21 AuthCacheMap::iterator iter = cache_.find(server); |
| 15 return (iter == cache_.end()) ? NULL : iter->second; | 22 if (iter == cache_.end()) |
| 23 return false; |
| 24 |
| 25 *certificate = iter->second; |
| 26 return true; |
| 16 } | 27 } |
| 17 | 28 |
| 18 void SSLClientAuthCache::Add(const std::string& server, | 29 void SSLClientAuthCache::Add(const std::string& server, |
| 19 X509Certificate* value) { | 30 X509Certificate* value) { |
| 20 cache_[server] = value; | 31 cache_[server] = value; |
| 21 | 32 |
| 22 // TODO(wtc): enforce a maximum number of entries. | 33 // TODO(wtc): enforce a maximum number of entries. |
| 23 } | 34 } |
| 24 | 35 |
| 25 void SSLClientAuthCache::Remove(const std::string& server) { | 36 void SSLClientAuthCache::Remove(const std::string& server) { |
| 26 cache_.erase(server); | 37 cache_.erase(server); |
| 27 } | 38 } |
| 28 | 39 |
| 29 } // namespace net | 40 } // namespace net |
| OLD | NEW |