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

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

Issue 8340026: Use AuthCredentials throughout the network stack instead of username/password. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 9 years, 1 month 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
« no previous file with comments | « net/base/zap.cc ('k') | net/ftp/ftp_auth_cache.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) 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 #ifndef NET_FTP_FTP_AUTH_CACHE_H_ 5 #ifndef NET_FTP_FTP_AUTH_CACHE_H_
6 #define NET_FTP_FTP_AUTH_CACHE_H_ 6 #define NET_FTP_FTP_AUTH_CACHE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 10
11 #include "base/string16.h"
12 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "net/base/auth.h"
13 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 // The FtpAuthCache class is a simple cache structure to store authentication 17 // The FtpAuthCache class is a simple cache structure to store authentication
18 // information for ftp. Provides lookup, insertion, and deletion of entries. 18 // information for ftp. Provides lookup, insertion, and deletion of entries.
19 // The parameter for doing lookups, insertions, and deletions is a GURL of the 19 // The parameter for doing lookups, insertions, and deletions is a GURL of the
20 // server's address (not a full URL with path, since FTP auth isn't per path). 20 // server's address (not a full URL with path, since FTP auth isn't per path).
21 // For example: 21 // For example:
22 // GURL("ftp://myserver") -- OK (implied port of 21) 22 // GURL("ftp://myserver") -- OK (implied port of 21)
23 // GURL("ftp://myserver:21") -- OK 23 // GURL("ftp://myserver:21") -- OK
24 // GURL("ftp://myserver/PATH") -- WRONG, paths not allowed 24 // GURL("ftp://myserver/PATH") -- WRONG, paths not allowed
25 class NET_EXPORT_PRIVATE FtpAuthCache { 25 class NET_EXPORT_PRIVATE FtpAuthCache {
26 public: 26 public:
27 // Maximum number of entries we allow in the cache. 27 // Maximum number of entries we allow in the cache.
28 static const size_t kMaxEntries; 28 static const size_t kMaxEntries;
29 29
30 struct Entry { 30 struct Entry {
31 Entry(const GURL& origin, const string16& username, 31 Entry(const GURL& origin, const AuthCredentials& credentials);
32 const string16& password);
33 ~Entry(); 32 ~Entry();
34 33
35 const GURL origin; 34 const GURL origin;
36 string16 username; 35 AuthCredentials credentials;
37 string16 password;
38 }; 36 };
39 37
40 FtpAuthCache(); 38 FtpAuthCache();
41 ~FtpAuthCache(); 39 ~FtpAuthCache();
42 40
43 // Return Entry corresponding to given |origin| or NULL if not found. 41 // Return Entry corresponding to given |origin| or NULL if not found.
44 Entry* Lookup(const GURL& origin); 42 Entry* Lookup(const GURL& origin);
45 43
46 // Add an entry for |origin| to the cache (consisting of |username| and 44 // Add an entry for |origin| to the cache using |credentials|. If there is
47 // |password|). If there is already an entry for |origin|, it will be 45 // already an entry for |origin|, it will be overwritten.
48 // overwritten. 46 void Add(const GURL& origin, const AuthCredentials& credentials);
49 void Add(const GURL& origin, const string16& username,
50 const string16& password);
51 47
52 // Remove the entry for |origin| from the cache, if one exists and matches 48 // Remove the entry for |origin| from the cache, if one exists and matches
53 // |username| and |password|. 49 // |credentials|.
54 void Remove(const GURL& origin, const string16& username, 50 void Remove(const GURL& origin, const AuthCredentials& credentials);
55 const string16& password);
56 51
57 private: 52 private:
58 typedef std::list<Entry> EntryList; 53 typedef std::list<Entry> EntryList;
59 54
60 // Internal representation of cache, an STL list. This makes lookups O(n), 55 // Internal representation of cache, an STL list. This makes lookups O(n),
61 // but we expect n to be very low. 56 // but we expect n to be very low.
62 EntryList entries_; 57 EntryList entries_;
63 }; 58 };
64 59
65 } // namespace net 60 } // namespace net
66 61
67 #endif // NET_FTP_FTP_AUTH_CACHE_H_ 62 #endif // NET_FTP_FTP_AUTH_CACHE_H_
OLDNEW
« no previous file with comments | « net/base/zap.cc ('k') | net/ftp/ftp_auth_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698