summaryrefslogtreecommitdiffstats
path: root/net/ftp/ftp_auth_cache.h
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-15 06:43:48 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-15 06:43:48 +0000
commit515838ce76cb8bec7f51f6143cac74f113e247ad (patch)
tree71b70d594974310b35d1c8f7843aeda5717c044b /net/ftp/ftp_auth_cache.h
parent92352a66515fd9a01f538529356ad45870109f28 (diff)
downloadchromium_src-515838ce76cb8bec7f51f6143cac74f113e247ad.zip
chromium_src-515838ce76cb8bec7f51f6143cac74f113e247ad.tar.gz
chromium_src-515838ce76cb8bec7f51f6143cac74f113e247ad.tar.bz2
post-winhttp cleanup: refactor net/base/auth_cache into net/ftp/ftp_auth_cache.
Also moves AuthCache::HttpKey() --> GetSignonRealmKey(). Review URL: http://codereview.chromium.org/18218 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_auth_cache.h')
-rw-r--r--net/ftp/ftp_auth_cache.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/net/ftp/ftp_auth_cache.h b/net/ftp/ftp_auth_cache.h
new file mode 100644
index 0000000..752842c
--- /dev/null
+++ b/net/ftp/ftp_auth_cache.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_FTP_FTP_AUTH_CACHE_H_
+#define NET_FTP_FTP_AUTH_CACHE_H_
+
+#include <string>
+#include <map>
+
+#include "net/base/auth.h"
+
+class GURL;
+
+namespace net {
+
+// The FtpAuthCache class is a simple cache structure to store authentication
+// information for ftp. Provides lookup, insertion, and deletion of entries.
+// The parameter for doing lookups, insertions, and deletions is a GURL of the
+// server's address (not a full URL with path, since FTP auth isn't per path).
+// For example:
+// GURL("ftp://myserver") -- OK (implied port of 21)
+// GURL("ftp://myserver:21") -- OK
+// GURL("ftp://myserver/PATH") -- WRONG, paths not allowed
+class FtpAuthCache {
+ public:
+ FtpAuthCache() {}
+ ~FtpAuthCache() {}
+
+ // Check if we have authentication data for ftp server at |origin|.
+ // Returns the address of corresponding AuthData object (if found) or NULL
+ // (if not found).
+ AuthData* Lookup(const GURL& origin);
+
+ // Add an entry for |origin| to the cache. If there is already an
+ // entry for |origin|, it will be overwritten. Both parameters are IN only.
+ void Add(const GURL& origin, AuthData* value);
+
+ // Remove the entry for |origin| from the cache, if one exists.
+ void Remove(const GURL& origin);
+
+ private:
+ typedef std::string AuthCacheKey;
+ typedef scoped_refptr<AuthData> AuthCacheValue;
+ typedef std::map<AuthCacheKey,AuthCacheValue> AuthCacheMap;
+
+ // Get the key in hash table |cache_| where entries for ftp server |origin|
+ // should be saved.
+ static AuthCacheKey MakeKey(const GURL& origin);
+
+ // internal representation of cache, an STL map.
+ AuthCacheMap cache_;
+};
+
+} // namespace net
+
+#endif // NET_FTP_FTP_AUTH_CACHE_H_
+