| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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/ftp/ftp_auth_cache.h" | 5 #include "net/base/ssl_client_auth_cache.h" |
| 6 | |
| 7 #include "base/string_util.h" | |
| 8 #include "googleurl/src/gurl.h" | |
| 9 | 6 |
| 10 namespace net { | 7 namespace net { |
| 11 | 8 |
| 12 AuthData* FtpAuthCache::Lookup(const GURL& origin) { | 9 X509Certificate* SSLClientAuthCache::Lookup(const std::string& server) { |
| 13 AuthCacheMap::iterator iter = cache_.find(MakeKey(origin)); | 10 AuthCacheMap::iterator iter = cache_.find(server); |
| 14 return (iter == cache_.end()) ? NULL : iter->second; | 11 return (iter == cache_.end()) ? NULL : iter->second; |
| 15 } | 12 } |
| 16 | 13 |
| 17 void FtpAuthCache::Add(const GURL& origin, AuthData* value) { | 14 void SSLClientAuthCache::Add(const std::string& server, |
| 18 cache_[MakeKey(origin)] = value; | 15 X509Certificate* value) { |
| 16 cache_[server] = value; |
| 19 | 17 |
| 20 // TODO(eroman): enforce a maximum number of entries. | 18 // TODO(wtc): enforce a maximum number of entries. |
| 21 } | 19 } |
| 22 | 20 |
| 23 void FtpAuthCache::Remove(const GURL& origin) { | 21 void SSLClientAuthCache::Remove(const std::string& server) { |
| 24 cache_.erase(MakeKey(origin)); | 22 cache_.erase(server); |
| 25 } | |
| 26 | |
| 27 // static | |
| 28 FtpAuthCache::AuthCacheKey FtpAuthCache::MakeKey(const GURL& origin) { | |
| 29 DCHECK(origin.SchemeIs("ftp")); | |
| 30 DCHECK(origin.GetOrigin() == origin); | |
| 31 return origin.spec(); | |
| 32 } | 23 } |
| 33 | 24 |
| 34 } // namespace net | 25 } // namespace net |
| OLD | NEW |