Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Unified Diff: net/ftp/ftp_auth_cache.cc

Issue 201083: Cache login identity for NewFTP transactions. (Closed)
Patch Set: better Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/ftp/ftp_auth_cache.cc
diff --git a/net/ftp/ftp_auth_cache.cc b/net/ftp/ftp_auth_cache.cc
index c29146a1536db7c69b42399a313928615756e091..d3bff905a54e4dedf7a67a306a0cacd2ec8b9d4d 100644
--- a/net/ftp/ftp_auth_cache.cc
+++ b/net/ftp/ftp_auth_cache.cc
@@ -12,20 +12,25 @@ namespace net {
// static
const size_t FtpAuthCache::kMaxEntries = 10;
-AuthData* FtpAuthCache::Lookup(const GURL& origin) {
- Entry* entry = LookupEntry(origin);
- return (entry ? entry->auth_data : NULL);
+FtpAuthCache::Entry* FtpAuthCache::Lookup(const GURL& origin) {
+ for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) {
+ if (it->origin == origin)
+ return &(*it);
+ }
+ return NULL;
}
-void FtpAuthCache::Add(const GURL& origin, AuthData* auth_data) {
+void FtpAuthCache::Add(const GURL& origin, const std::wstring& username,
+ const std::wstring& password) {
DCHECK(origin.SchemeIs("ftp"));
DCHECK_EQ(origin.GetOrigin(), origin);
- Entry* entry = LookupEntry(origin);
+ Entry* entry = Lookup(origin);
if (entry) {
- entry->auth_data = auth_data;
+ entry->username = username;
+ entry->password = password;
} else {
- entries_.push_front(Entry(origin, auth_data));
+ entries_.push_front(Entry(origin, username, password));
// Prevent unbound memory growth of the cache.
if (entries_.size() > kMaxEntries)
@@ -33,22 +38,16 @@ void FtpAuthCache::Add(const GURL& origin, AuthData* auth_data) {
}
}
-void FtpAuthCache::Remove(const GURL& origin) {
+void FtpAuthCache::Remove(const GURL& origin, const std::wstring& username,
+ const std::wstring& password) {
for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) {
- if (it->origin == origin) {
+ if (it->origin == origin && it->username == username &&
+ it->password == password) {
entries_.erase(it);
- DCHECK(!LookupEntry(origin));
+ DCHECK(!Lookup(origin));
return;
}
}
}
-FtpAuthCache::Entry* FtpAuthCache::LookupEntry(const GURL& origin) {
- for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) {
- if (it->origin == origin)
- return &(*it);
- }
- return NULL;
-}
-
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698