diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 18:45:45 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 18:45:45 +0000 |
commit | 44d6da87c14860edf8350b4af5d66a3cf59dfda5 (patch) | |
tree | dff42211837600c4eb0af2eeecce02f278b4909a /net | |
parent | 84e8bdeaaf5c35c0e55dd9eca21422e7bfdc588f (diff) | |
download | chromium_src-44d6da87c14860edf8350b4af5d66a3cf59dfda5.zip chromium_src-44d6da87c14860edf8350b4af5d66a3cf59dfda5.tar.gz chromium_src-44d6da87c14860edf8350b4af5d66a3cf59dfda5.tar.bz2 |
Revert r42467: "Clear cookies, local storage and databases when an extension gets uninstalled."
It introduced a memory leak, causing a regression on valgrind test: unit.
TBR=jochen
Review URL: http://codereview.chromium.org/1295001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42499 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/cookie_monster.cc | 79 | ||||
-rw-r--r-- | net/base/cookie_monster.h | 7 |
2 files changed, 31 insertions, 55 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc index cd5d7f2..50ffcac 100644 --- a/net/base/cookie_monster.cc +++ b/net/base/cookie_monster.cc @@ -782,20 +782,6 @@ int CookieMonster::DeleteAllCreatedAfter(const Time& delete_begin, return DeleteAllCreatedBetween(delete_begin, Time(), sync_to_store); } -int CookieMonster::DeleteAllForURL(const GURL& url, - bool sync_to_store) { - AutoLock autolock(lock_); - InitIfNecessary(); - CookieList cookies = InternalGetAllCookiesForURL(url); - int num_deleted = 0; - for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) { - CookieMap::iterator curit = it; - ++it; - InternalDeleteCookie(curit, true); - } - return num_deleted; -} - bool CookieMonster::DeleteCookie(const std::string& domain, const CanonicalCookie& cookie, bool sync_to_store) { @@ -925,7 +911,37 @@ CookieMonster::CookieList CookieMonster::GetAllCookies() { CookieMonster::CookieList CookieMonster::GetAllCookiesForURL(const GURL& url) { AutoLock autolock(lock_); InitIfNecessary(); - return InternalGetAllCookiesForURL(url); + + // Do not return removed cookies. + GarbageCollectExpired(Time::Now(), + CookieMapItPair(cookies_.begin(), cookies_.end()), + NULL); + + CookieList cookie_list; + if (!HasCookieableScheme(url)) + return cookie_list; + + bool secure = url.SchemeIsSecure(); + + // Query for the full host, For example: 'a.c.blah.com'. + std::string key(url.host()); + FindRawCookies(key, secure, url.path(), &cookie_list); + + // See if we can search for domain cookies, i.e. if the host has a TLD + 1. + const std::string domain(GetEffectiveDomain(url.scheme(), key)); + if (domain.empty()) + return cookie_list; + + // Use same logic as in FindCookiesForHostAndDomain. + DCHECK_LE(domain.length(), key.length()); + DCHECK_EQ(0, key.compare(key.length() - domain.length(), domain.length(), + domain)); + for (key = "." + key; key.length() > domain.length(); ) { + FindRawCookies(key, secure, url.path(), &cookie_list); + const size_t next_dot = key.find('.', 1); // Skip over leading dot. + key.erase(0, next_dot); + } + return cookie_list; } void CookieMonster::FindCookiesForHostAndDomain( @@ -1014,39 +1030,6 @@ void CookieMonster::FindRawCookies(const std::string& key, } } -CookieMonster::CookieList CookieMonster::InternalGetAllCookiesForURL( - const GURL& url) { - // Do not return removed cookies. - GarbageCollectExpired(Time::Now(), - CookieMapItPair(cookies_.begin(), cookies_.end()), - NULL); - - CookieList cookie_list; - if (!HasCookieableScheme(url)) - return cookie_list; - - bool secure = url.SchemeIsSecure(); - - // Query for the full host, For example: 'a.c.blah.com'. - std::string key(url.host()); - FindRawCookies(key, secure, url.path(), &cookie_list); - - // See if we can search for domain cookies, i.e. if the host has a TLD + 1. - const std::string domain(GetEffectiveDomain(url.scheme(), key)); - if (domain.empty()) - return cookie_list; - - // Use same logic as in FindCookiesForHostAndDomain. - DCHECK_LE(domain.length(), key.length()); - DCHECK_EQ(0, key.compare(key.length() - domain.length(), domain.length(), - domain)); - for (key = "." + key; key.length() > domain.length(); ) { - FindRawCookies(key, secure, url.path(), &cookie_list); - const size_t next_dot = key.find('.', 1); // Skip over leading dot. - key.erase(0, next_dot); - } - return cookie_list; -} CookieMonster::ParsedCookie::ParsedCookie(const std::string& cookie_line) : is_valid_(false), diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h index a48c2d3..ccdae0b 100644 --- a/net/base/cookie_monster.h +++ b/net/base/cookie_monster.h @@ -112,9 +112,6 @@ class CookieMonster : public CookieStore { // one passed into the function via |delete_after|. int DeleteAllCreatedAfter(const base::Time& delete_begin, bool sync_to_store); - // Delete all cookies that match the given URL. - int DeleteAllForURL(const GURL& url, bool sync_to_store); - // Delete one specific cookie. bool DeleteCookie(const std::string& domain, const CanonicalCookie& cookie, @@ -179,10 +176,6 @@ class CookieMonster : public CookieStore { const std::string& path, CookieList* list); - // Internal helper returning all cookies for a given URL. The caller is - // assumed to hold lock_ and having called InitIfNecessary(). - CookieList InternalGetAllCookiesForURL(const GURL& url); - // Delete any cookies that are equivalent to |ecc| (same path, key, etc). // If |skip_httponly| is true, httponly cookies will not be deleted. The // return value with be true if |skip_httponly| skipped an httponly cookie. |