Commit 61ceb531 authored by mmenke's avatar mmenke Committed by Commit bot

Replace TestingProfile::GetCookieMonster with GetCookieStore.

I'm trying to remove CookieStore::GetCookieMonster, since it's
weird and ugly to have most consumers of a class have hard
dependencies on it being a particular subclass of that class.

Also make a test using the method no longer hold onto references
to the CookieStore, in preparation for de-reference-counting the
class.

BUG=579653

Review URL: https://codereview.chromium.org/1613473002

Cr-Commit-Position: refs/heads/master@{#370779}
parent cbc1e379
...@@ -110,23 +110,21 @@ class BrowsingDataCookieHelperTest : public testing::Test { ...@@ -110,23 +110,21 @@ class BrowsingDataCookieHelperTest : public testing::Test {
} }
void CreateCookiesForTest() { void CreateCookiesForTest() {
scoped_refptr<net::CookieMonster> cookie_monster = net::CookieStore* cookie_store = testing_profile_->GetCookieStore();
testing_profile_->GetCookieMonster(); cookie_store->SetCookieWithOptionsAsync(
cookie_monster->SetCookieWithOptionsAsync(
GURL("http://www.google.com"), "A=1", net::CookieOptions(), GURL("http://www.google.com"), "A=1", net::CookieOptions(),
net::CookieMonster::SetCookiesCallback()); net::CookieMonster::SetCookiesCallback());
cookie_monster->SetCookieWithOptionsAsync( cookie_store->SetCookieWithOptionsAsync(
GURL("http://www.gmail.google.com"), "B=1", net::CookieOptions(), GURL("http://www.gmail.google.com"), "B=1", net::CookieOptions(),
net::CookieMonster::SetCookiesCallback()); net::CookieMonster::SetCookiesCallback());
} }
void CreateCookiesForDomainCookieTest() { void CreateCookiesForDomainCookieTest() {
scoped_refptr<net::CookieMonster> cookie_monster = net::CookieStore* cookie_store = testing_profile_->GetCookieStore();
testing_profile_->GetCookieMonster(); cookie_store->SetCookieWithOptionsAsync(
cookie_monster->SetCookieWithOptionsAsync(
GURL("http://www.google.com"), "A=1", net::CookieOptions(), GURL("http://www.google.com"), "A=1", net::CookieOptions(),
net::CookieMonster::SetCookiesCallback()); net::CookieMonster::SetCookiesCallback());
cookie_monster->SetCookieWithOptionsAsync( cookie_store->SetCookieWithOptionsAsync(
GURL("http://www.google.com"), "A=2; Domain=.www.google.com ", GURL("http://www.google.com"), "A=2; Domain=.www.google.com ",
net::CookieOptions(), net::CookieMonster::SetCookiesCallback()); net::CookieOptions(), net::CookieMonster::SetCookiesCallback());
} }
......
...@@ -733,11 +733,10 @@ TestingProfile::GetExtensionSpecialStoragePolicy() { ...@@ -733,11 +733,10 @@ TestingProfile::GetExtensionSpecialStoragePolicy() {
#endif #endif
} }
net::CookieMonster* TestingProfile::GetCookieMonster() { net::CookieStore* TestingProfile::GetCookieStore() {
if (!GetRequestContext()) if (!GetRequestContext())
return NULL; return NULL;
return GetRequestContext()->GetURLRequestContext()->cookie_store()-> return GetRequestContext()->GetURLRequestContext()->cookie_store();
GetCookieMonster();
} }
void TestingProfile::CreateTestingPrefService() { void TestingProfile::CreateTestingPrefService() {
......
...@@ -29,7 +29,7 @@ class ZoomLevelDelegate; ...@@ -29,7 +29,7 @@ class ZoomLevelDelegate;
} }
namespace net { namespace net {
class CookieMonster; class CookieStore;
class URLRequestContextGetter; class URLRequestContextGetter;
} }
...@@ -269,7 +269,7 @@ class TestingProfile : public Profile { ...@@ -269,7 +269,7 @@ class TestingProfile : public Profile {
// TODO(ajwong): Remove this API in favor of directly retrieving the // TODO(ajwong): Remove this API in favor of directly retrieving the
// CookieStore from the StoragePartition after ExtensionURLRequestContext // CookieStore from the StoragePartition after ExtensionURLRequestContext
// has been removed. // has been removed.
net::CookieMonster* GetCookieMonster(); net::CookieStore* GetCookieStore();
PrefService* GetPrefs() override; PrefService* GetPrefs() override;
const PrefService* GetPrefs() const override; const PrefService* GetPrefs() const override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment