From 515838ce76cb8bec7f51f6143cac74f113e247ad Mon Sep 17 00:00:00 2001 From: "ericroman@google.com" Date: Thu, 15 Jan 2009 06:43:48 +0000 Subject: 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 --- net/ftp/ftp_auth_cache.cc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 net/ftp/ftp_auth_cache.cc (limited to 'net/ftp/ftp_auth_cache.cc') diff --git a/net/ftp/ftp_auth_cache.cc b/net/ftp/ftp_auth_cache.cc new file mode 100644 index 0000000..8f1d18a --- /dev/null +++ b/net/ftp/ftp_auth_cache.cc @@ -0,0 +1,35 @@ +// 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. + +#include "net/ftp/ftp_auth_cache.h" + +#include "base/string_util.h" +#include "googleurl/src/gurl.h" + +namespace net { + +AuthData* FtpAuthCache::Lookup(const GURL& origin) { + AuthCacheMap::iterator iter = cache_.find(MakeKey(origin)); + return (iter == cache_.end()) ? NULL : iter->second; +} + +void FtpAuthCache::Add(const GURL& origin, AuthData* value) { + cache_[MakeKey(origin)] = value; + + // TODO(eroman): enforce a maximum number of entries. +} + +void FtpAuthCache::Remove(const GURL& origin) { + cache_.erase(MakeKey(origin)); +} + +// static +FtpAuthCache::AuthCacheKey FtpAuthCache::MakeKey(const GURL& origin) { + DCHECK(origin.SchemeIs("ftp")); + DCHECK(origin.GetOrigin() == origin); + return origin.spec(); +} + +} // namespace net + -- cgit v1.1