diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 15:02:14 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 15:02:14 +0000 |
commit | dc9f5a5595433b23854691687a4da5b50255f2ad (patch) | |
tree | 2436737115b3109ff1d87ea1cc2ed71e493ce298 /net | |
parent | 097f48d2f2ca4d24d5468d571c07e2e71749320a (diff) | |
download | chromium_src-dc9f5a5595433b23854691687a4da5b50255f2ad.zip chromium_src-dc9f5a5595433b23854691687a4da5b50255f2ad.tar.gz chromium_src-dc9f5a5595433b23854691687a4da5b50255f2ad.tar.bz2 |
Reverting 30578.
TBR=yurys
Review URL: http://codereview.chromium.org/342057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/cookie_monster.cc | 27 | ||||
-rw-r--r-- | net/base/cookie_monster_unittest.cc | 40 |
2 files changed, 6 insertions, 61 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc index 01b68a1..2c2f21d 100644 --- a/net/base/cookie_monster.cc +++ b/net/base/cookie_monster.cc @@ -792,27 +792,12 @@ void CookieMonster::DeleteCookie(const GURL& url, if (!HasCookieableScheme(url)) return; - CookieOptions options; - options.set_include_httponly(); - // Get the cookies for this host and its domain(s). - std::vector<CanonicalCookie*> cookies; - FindCookiesForHostAndDomain(url, options, &cookies); - std::set<CanonicalCookie*> matching_cookies; - - for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); - it != cookies.end(); ++it) { - if ((*it)->Name() != cookie_name) - continue; - if (url.path().find((*it)->Path())) - continue; - matching_cookies.insert(*it); - } - - for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) { - CookieMap::iterator curit = it; - ++it; - if (matching_cookies.find(curit->second) != matching_cookies.end()) - InternalDeleteCookie(curit, true); + for (CookieMapItPair its = cookies_.equal_range(url.host()); + its.first != its.second; ++its.first) { + if (its.first->second->Name() == cookie_name) { + InternalDeleteCookie(its.first, true); + return; + } } } diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc index bb45b68..8fda8db 100644 --- a/net/base/cookie_monster_unittest.cc +++ b/net/base/cookie_monster_unittest.cc @@ -961,44 +961,4 @@ TEST(CookieMonsterTest, SetCookieableSchemes) { EXPECT_FALSE(cm_foo->SetCookie(http_url, "x=1")); } -TEST(CookieMonsterTest, GetRawCookies) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster); - GURL url_google(kUrlGoogle); - - net::CookieOptions options; - options.set_include_httponly(); - - // Create a httponly cookie. - EXPECT_TRUE(cm->SetCookieWithOptions(url_google, "A=B; httponly", options)); - - // Get raw cookies. - std::vector<net::CookieMonster::CanonicalCookie> raw_cookies; - cm->GetRawCookies(url_google, &raw_cookies); - EXPECT_TRUE(raw_cookies.begin() != raw_cookies.end()); - net::CookieMonster::CanonicalCookie cookie = *raw_cookies.begin(); - EXPECT_EQ("A", cookie.Name()); -} - -TEST(CookieMonsterTest, DeleteCookieByName) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster); - GURL url_google(kUrlGoogle); - - EXPECT_TRUE(cm->SetCookie(url_google, "A=A1; path=/")); - EXPECT_TRUE(cm->SetCookie(url_google, "A=A2; path=/foo")); - EXPECT_TRUE(cm->SetCookie(url_google, "A=A3; path=/bar")); - EXPECT_TRUE(cm->SetCookie(url_google, "B=B1; path=/")); - EXPECT_TRUE(cm->SetCookie(url_google, "B=B2; path=/foo")); - EXPECT_TRUE(cm->SetCookie(url_google, "B=B3; path=/bar")); - - cm->DeleteCookie(GURL(std::string(kUrlGoogle) + "/foo/bar"), "A"); - - net::CookieMonster::CookieList cookies = cm->GetAllCookies(); - EXPECT_EQ(4, cookies.size()); - for (net::CookieMonster::CookieList::iterator it = cookies.begin(); - it != cookies.end(); ++it) { - EXPECT_NE("A1", it->second.Value()); - EXPECT_NE("A2", it->second.Value()); - } -} - // TODO test overwrite cookie |