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

Side by Side Diff: net/ftp/ftp_auth_cache.cc

Issue 3040016: Net: Convert username and password to string16. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address comments Created 10 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/ftp/ftp_auth_cache.h ('k') | net/ftp/ftp_auth_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 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 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 "googleurl/src/gurl.h" 8 #include "googleurl/src/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* FtpAuthCache::Lookup(const GURL& origin) { 15 FtpAuthCache::Entry* FtpAuthCache::Lookup(const GURL& origin) {
16 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) { 16 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) {
17 if (it->origin == origin) 17 if (it->origin == origin)
18 return &(*it); 18 return &(*it);
19 } 19 }
20 return NULL; 20 return NULL;
21 } 21 }
22 22
23 void FtpAuthCache::Add(const GURL& origin, const std::wstring& username, 23 void FtpAuthCache::Add(const GURL& origin, const string16& username,
24 const std::wstring& password) { 24 const string16& password) {
25 DCHECK(origin.SchemeIs("ftp")); 25 DCHECK(origin.SchemeIs("ftp"));
26 DCHECK_EQ(origin.GetOrigin(), origin); 26 DCHECK_EQ(origin.GetOrigin(), origin);
27 27
28 Entry* entry = Lookup(origin); 28 Entry* entry = Lookup(origin);
29 if (entry) { 29 if (entry) {
30 entry->username = username; 30 entry->username = username;
31 entry->password = password; 31 entry->password = password;
32 } else { 32 } else {
33 entries_.push_front(Entry(origin, username, password)); 33 entries_.push_front(Entry(origin, username, password));
34 34
35 // Prevent unbound memory growth of the cache. 35 // Prevent unbound memory growth of the cache.
36 if (entries_.size() > kMaxEntries) 36 if (entries_.size() > kMaxEntries)
37 entries_.pop_back(); 37 entries_.pop_back();
38 } 38 }
39 } 39 }
40 40
41 void FtpAuthCache::Remove(const GURL& origin, const std::wstring& username, 41 void FtpAuthCache::Remove(const GURL& origin, const string16& username,
42 const std::wstring& password) { 42 const string16& password) {
43 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) { 43 for (EntryList::iterator it = entries_.begin(); it != entries_.end(); ++it) {
44 if (it->origin == origin && it->username == username && 44 if (it->origin == origin && it->username == username &&
45 it->password == password) { 45 it->password == password) {
46 entries_.erase(it); 46 entries_.erase(it);
47 DCHECK(!Lookup(origin)); 47 DCHECK(!Lookup(origin));
48 return; 48 return;
49 } 49 }
50 } 50 }
51 } 51 }
52 52
53 } // namespace net 53 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_auth_cache.h ('k') | net/ftp/ftp_auth_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698