| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ftp/ftp_auth_cache.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 const size_t FtpAuthCache::kMaxEntries = 10; | 13 const size_t FtpAuthCache::kMaxEntries = 10; |
| 14 | 14 |
| 15 FtpAuthCache::Entry::Entry(const GURL& origin, | 15 FtpAuthCache::Entry::Entry(const GURL& origin, |
| 16 const AuthCredentials& credentials) | 16 const AuthCredentials& credentials) |
| 17 : origin(origin), | 17 : origin(origin), credentials(credentials) { |
| 18 credentials(credentials) { | |
| 19 } | 18 } |
| 20 | 19 |
| 21 FtpAuthCache::Entry::~Entry() {} | 20 FtpAuthCache::Entry::~Entry() { |
| 21 } |
| 22 | 22 |
| 23 FtpAuthCache::FtpAuthCache() {} | 23 FtpAuthCache::FtpAuthCache() { |
| 24 } |
| 24 | 25 |
| 25 FtpAuthCache::~FtpAuthCache() {} | 26 FtpAuthCache::~FtpAuthCache() { |
| 27 } |
| 26 | 28 |
| 27 FtpAuthCache::Entry* FtpAuthCache::Lookup(const GURL& origin) { | 29 FtpAuthCache::Entry* FtpAuthCache::Lookup(const GURL& origin) { |
| 28 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) { | 30 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) { |
| 29 if (it->origin == origin) | 31 if (it->origin == origin) |
| 30 return &(*it); | 32 return &(*it); |
| 31 } | 33 } |
| 32 return NULL; | 34 return NULL; |
| 33 } | 35 } |
| 34 | 36 |
| 35 void FtpAuthCache::Add(const GURL& origin, const AuthCredentials& credentials) { | 37 void FtpAuthCache::Add(const GURL& origin, const AuthCredentials& credentials) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 53 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) { | 55 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) { |
| 54 if (it->origin == origin && it->credentials.Equals(credentials)) { | 56 if (it->origin == origin && it->credentials.Equals(credentials)) { |
| 55 entries_.erase(it); | 57 entries_.erase(it); |
| 56 DCHECK(!Lookup(origin)); | 58 DCHECK(!Lookup(origin)); |
| 57 return; | 59 return; |
| 58 } | 60 } |
| 59 } | 61 } |
| 60 } | 62 } |
| 61 | 63 |
| 62 } // namespace net | 64 } // namespace net |
| OLD | NEW |