Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 1701063002: CookieStore: Remove reference counting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@threadsafe
Patch Set: Fix leak Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/cookies/cookie_monster_unittest.cc
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc
index 4f64b2f00c23d9ff86a5526c2dffa8b40541a684..f2eb19225ccba687506fc9296410a1db72c9831f 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -71,8 +71,8 @@ const char kTopLevelDomainPlus3[] = "http://www.bourbaki.math.harvard.edu";
const char kOtherDomain[] = "http://www.mit.edu";
struct CookieMonsterTestTraits {
- static scoped_refptr<CookieStore> Create() {
- return new CookieMonster(NULL, NULL);
+ static scoped_ptr<CookieStore> Create() {
+ return make_scoped_ptr(new CookieMonster(nullptr, nullptr));
}
static const bool supports_http_only = true;
@@ -85,8 +85,8 @@ struct CookieMonsterTestTraits {
};
struct CookieMonsterEnforcingStrictSecure {
- static scoped_refptr<CookieStore> Create() {
- return new CookieMonster(NULL, NULL);
+ static scoped_ptr<CookieStore> Create() {
+ return make_scoped_ptr(new CookieMonster(nullptr, nullptr));
}
static const bool supports_http_only = true;
@@ -166,14 +166,14 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
// Helper for DeleteAllForHost test; repopulates CM with same layout
// each time.
- void PopulateCmForDeleteAllForHost(scoped_refptr<CookieMonster> cm) {
+ void PopulateCmForDeleteAllForHost(CookieMonster* cm) {
GURL url_top_level_domain_plus_1(kTopLevelDomainPlus1);
GURL url_top_level_domain_plus_2(kTopLevelDomainPlus2);
GURL url_top_level_domain_plus_2_secure(kTopLevelDomainPlus2Secure);
GURL url_top_level_domain_plus_3(kTopLevelDomainPlus3);
GURL url_other(kOtherDomain);
- this->DeleteAll(cm.get());
+ this->DeleteAll(cm);
// Static population for probe:
// * Three levels of domain cookie (.b.a, .c.b.a, .d.c.b.a)
@@ -186,75 +186,75 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
// Domain cookies
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_1, "dom_1", "X", ".harvard.edu",
- "/", base::Time(), base::Time(), base::Time(), false, false, false,
+ cm, url_top_level_domain_plus_1, "dom_1", "X", ".harvard.edu", "/",
+ base::Time(), base::Time(), base::Time(), false, false, false,
COOKIE_PRIORITY_DEFAULT));
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2, "dom_2", "X",
- ".math.harvard.edu", "/", base::Time(), base::Time(), base::Time(),
- false, false, false, COOKIE_PRIORITY_DEFAULT));
+ cm, url_top_level_domain_plus_2, "dom_2", "X", ".math.harvard.edu", "/",
+ base::Time(), base::Time(), base::Time(), false, false, false,
+ COOKIE_PRIORITY_DEFAULT));
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_3, "dom_3", "X",
+ cm, url_top_level_domain_plus_3, "dom_3", "X",
".bourbaki.math.harvard.edu", "/", base::Time(), base::Time(),
base::Time(), false, false, false, COOKIE_PRIORITY_DEFAULT));
// Host cookies
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_1, "host_1", "X", std::string(),
- "/", base::Time(), base::Time(), base::Time(), false, false, false,
+ cm, url_top_level_domain_plus_1, "host_1", "X", std::string(), "/",
+ base::Time(), base::Time(), base::Time(), false, false, false,
COOKIE_PRIORITY_DEFAULT));
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2, "host_2", "X", std::string(),
- "/", base::Time(), base::Time(), base::Time(), false, false, false,
+ cm, url_top_level_domain_plus_2, "host_2", "X", std::string(), "/",
+ base::Time(), base::Time(), base::Time(), false, false, false,
COOKIE_PRIORITY_DEFAULT));
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_3, "host_3", "X", std::string(),
- "/", base::Time(), base::Time(), base::Time(), false, false, false,
+ cm, url_top_level_domain_plus_3, "host_3", "X", std::string(), "/",
+ base::Time(), base::Time(), base::Time(), false, false, false,
COOKIE_PRIORITY_DEFAULT));
// http_only cookie
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2, "httpo_check", "x",
- std::string(), "/", base::Time(), base::Time(), base::Time(), false,
- true, false, COOKIE_PRIORITY_DEFAULT));
+ cm, url_top_level_domain_plus_2, "httpo_check", "x", std::string(), "/",
+ base::Time(), base::Time(), base::Time(), false, true, false,
+ COOKIE_PRIORITY_DEFAULT));
// same-site cookie
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2, "firstp_check", "x",
- std::string(), "/", base::Time(), base::Time(), base::Time(), false,
- false, true, COOKIE_PRIORITY_DEFAULT));
+ cm, url_top_level_domain_plus_2, "firstp_check", "x", std::string(),
+ "/", base::Time(), base::Time(), base::Time(), false, false, true,
+ COOKIE_PRIORITY_DEFAULT));
// Secure cookies
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2_secure, "sec_dom", "X",
+ cm, url_top_level_domain_plus_2_secure, "sec_dom", "X",
".math.harvard.edu", "/", base::Time(), base::Time(), base::Time(),
true, false, false, COOKIE_PRIORITY_DEFAULT));
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2_secure, "sec_host", "X",
- std::string(), "/", base::Time(), base::Time(), base::Time(), true,
- false, false, COOKIE_PRIORITY_DEFAULT));
+ cm, url_top_level_domain_plus_2_secure, "sec_host", "X", std::string(),
+ "/", base::Time(), base::Time(), base::Time(), true, false, false,
+ COOKIE_PRIORITY_DEFAULT));
// Domain path cookies
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2, "dom_path_1", "X",
- ".math.harvard.edu", "/dir1", base::Time(), base::Time(), base::Time(),
- false, false, false, COOKIE_PRIORITY_DEFAULT));
+ cm, url_top_level_domain_plus_2, "dom_path_1", "X", ".math.harvard.edu",
+ "/dir1", base::Time(), base::Time(), base::Time(), false, false, false,
+ COOKIE_PRIORITY_DEFAULT));
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2, "dom_path_2", "X",
- ".math.harvard.edu", "/dir1/dir2", base::Time(), base::Time(),
- base::Time(), false, false, false, COOKIE_PRIORITY_DEFAULT));
+ cm, url_top_level_domain_plus_2, "dom_path_2", "X", ".math.harvard.edu",
+ "/dir1/dir2", base::Time(), base::Time(), base::Time(), false, false,
+ false, COOKIE_PRIORITY_DEFAULT));
// Host path cookies
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2, "host_path_1", "X",
- std::string(), "/dir1", base::Time(), base::Time(), base::Time(), false,
- false, false, COOKIE_PRIORITY_DEFAULT));
+ cm, url_top_level_domain_plus_2, "host_path_1", "X", std::string(),
+ "/dir1", base::Time(), base::Time(), base::Time(), false, false, false,
+ COOKIE_PRIORITY_DEFAULT));
EXPECT_TRUE(this->SetCookieWithDetails(
- cm.get(), url_top_level_domain_plus_2, "host_path_2", "X",
- std::string(), "/dir1/dir2", base::Time(), base::Time(), base::Time(),
- false, false, false, COOKIE_PRIORITY_DEFAULT));
+ cm, url_top_level_domain_plus_2, "host_path_2", "X", std::string(),
+ "/dir1/dir2", base::Time(), base::Time(), base::Time(), false, false,
+ false, COOKIE_PRIORITY_DEFAULT));
- EXPECT_EQ(14U, this->GetAllCookies(cm.get()).size());
+ EXPECT_EQ(14U, this->GetAllCookies(cm).size());
}
Time GetFirstCookieAccessDate(CookieMonster* cm) {
@@ -283,7 +283,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
(domain_max_cookies + domain_purge_cookies) * 2;
// Add a bunch of cookies on a single host, should purge them.
{
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
for (int i = 0; i < more_than_enough_cookies; ++i) {
std::string cookie = base::StringPrintf("a%03d=b", i);
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), cookie));
@@ -301,7 +301,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
// between them. We shouldn't go above kDomainMaxCookies for both together.
GURL url_google_specific(http_www_google_.Format("http://www.gmail.%D"));
{
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
for (int i = 0; i < more_than_enough_cookies; ++i) {
std::string cookie_general = base::StringPrintf("a%03d=b", i);
EXPECT_TRUE(
@@ -477,10 +477,10 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
size_t expected_secure_cookies,
size_t expected_non_secure_cookies,
const AltHosts* alt_host_entries) {
- scoped_refptr<CookieMonster> cm;
+ scoped_ptr<CookieMonster> cm;
if (alt_host_entries == nullptr) {
- cm = new CookieMonster(nullptr, nullptr);
+ cm.reset(new CookieMonster(nullptr, nullptr));
} else {
// When generating all of these cookies on alternate hosts, they need to
// be all older than the max "safe" date for GC, which is currently 30
@@ -525,7 +525,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
DCHECK_EQ(150U, CookieMonster::kDomainMaxCookies -
CookieMonster::kDomainPurgeCookies);
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
// Each test case adds 181 cookies, so 31 cookies are evicted.
// Cookie same priority, repeated for each priority.
@@ -579,7 +579,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
DCHECK_EQ(150U, CookieMonster::kDomainMaxCookies -
CookieMonster::kDomainPurgeCookies);
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
// Each test case adds 181 cookies, so 31 cookies are evicted.
// Cookie same priority, repeated for each priority.
@@ -633,7 +633,7 @@ class CookieMonsterTestBase : public CookieStoreTest<T> {
DCHECK_EQ(150U, CookieMonster::kDomainMaxCookies -
CookieMonster::kDomainPurgeCookies);
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
// Each test case adds 180 secure cookies, and some non-secure cookie. The
// secure cookies take priority, so the non-secure cookie is removed, along
@@ -850,7 +850,7 @@ class DeferredCookieTaskTest : public CookieMonsterTest {
protected:
DeferredCookieTaskTest() : expect_load_called_(false) {
persistent_store_ = new NewMockPersistentCookieStore();
- cookie_monster_ = new CookieMonster(persistent_store_.get(), NULL);
+ cookie_monster_.reset(new CookieMonster(persistent_store_.get(), nullptr));
}
// Defines a cookie to be returned from PersistentCookieStore::Load
@@ -939,7 +939,7 @@ class DeferredCookieTaskTest : public CookieMonsterTest {
// Indicates whether ExpectLoadCall() has been called.
bool expect_load_called_;
// Stores the CookieMonster under test.
- scoped_refptr<CookieMonster> cookie_monster_;
+ scoped_ptr<CookieMonster> cookie_monster_;
// Stores the mock PersistentCookieStore.
scoped_refptr<NewMockPersistentCookieStore> persistent_store_;
};
@@ -1282,7 +1282,7 @@ TEST_F(DeferredCookieTaskTest, DeferredTaskOrder) {
TEST_F(CookieMonsterTest, TestCookieDeleteAll) {
scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
CookieOptions options;
options.set_include_httponly();
@@ -1315,7 +1315,7 @@ TEST_F(CookieMonsterTest, TestCookieDeleteAll) {
}
TEST_F(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
Time now = Time::Now();
// Nothing has been added so nothing should be deleted.
@@ -1357,8 +1357,8 @@ TEST_F(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps) {
static const int kAccessDelayMs = kLastAccessThresholdMilliseconds + 20;
TEST_F(CookieMonsterTest, TestLastAccess) {
- scoped_refptr<CookieMonster> cm(
- new CookieMonster(NULL, NULL, kLastAccessThresholdMilliseconds));
+ scoped_ptr<CookieMonster> cm(
+ new CookieMonster(nullptr, nullptr, kLastAccessThresholdMilliseconds));
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "A=B"));
const Time last_access_date(GetFirstCookieAccessDate(cm.get()));
@@ -1413,8 +1413,8 @@ TEST_F(CookieMonsterTest, TestPriorityAwareGarbageCollectionMixed) {
}
TEST_F(CookieMonsterTest, SetCookieableSchemes) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
- scoped_refptr<CookieMonster> cm_foo(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
+ scoped_ptr<CookieMonster> cm_foo(new CookieMonster(nullptr, nullptr));
// Only cm_foo should allow foo:// cookies.
std::vector<std::string> schemes;
@@ -1431,8 +1431,8 @@ TEST_F(CookieMonsterTest, SetCookieableSchemes) {
}
TEST_F(CookieMonsterTest, GetAllCookiesForURL) {
- scoped_refptr<CookieMonster> cm(
- new CookieMonster(NULL, NULL, kLastAccessThresholdMilliseconds));
+ scoped_ptr<CookieMonster> cm(
+ new CookieMonster(nullptr, nullptr, kLastAccessThresholdMilliseconds));
// Create an httponly cookie.
CookieOptions options;
@@ -1500,7 +1500,7 @@ TEST_F(CookieMonsterTest, GetAllCookiesForURL) {
}
TEST_F(CookieMonsterTest, GetAllCookiesForURLPathMatching) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
CookieOptions options;
EXPECT_TRUE(SetCookieWithOptions(cm.get(), www_google_foo_.url(),
@@ -1538,7 +1538,7 @@ TEST_F(CookieMonsterTest, GetAllCookiesForURLPathMatching) {
}
TEST_F(CookieMonsterTest, CookieSorting) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "B=B1; path=/"));
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "B=B2; path=/foo"));
@@ -1568,7 +1568,7 @@ TEST_F(CookieMonsterTest, CookieSorting) {
}
TEST_F(CookieMonsterTest, DeleteCookieByName) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "A=A1; path=/"));
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "A=A2; path=/foo"));
@@ -1644,7 +1644,7 @@ TEST_F(CookieMonsterTest, DontImportDuplicateCookies) {
// Inject our initial cookies into the mock PersistentCookieStore.
store->SetLoadExpectation(true, initial_cookies);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
// Verify that duplicates were not imported for path "/".
// (If this had failed, GetCookies() would have also returned X=1, X=2, X=4).
@@ -1692,7 +1692,7 @@ TEST_F(CookieMonsterTest, DontImportDuplicateCreationTimes) {
// Inject our initial cookies into the mock PersistentCookieStore.
store->SetLoadExpectation(true, initial_cookies);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
CookieList list(GetAllCookies(cm.get()));
EXPECT_EQ(2U, list.size());
@@ -1708,8 +1708,7 @@ TEST_F(CookieMonsterTest, CookieMonsterDelegate) {
scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
scoped_refptr<MockCookieMonsterDelegate> delegate(
new MockCookieMonsterDelegate);
- scoped_refptr<CookieMonster> cm(
- new CookieMonster(store.get(), delegate.get()));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), delegate.get()));
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "A=B"));
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "C=D"));
@@ -1788,7 +1787,7 @@ TEST_F(CookieMonsterTest, CookieMonsterDelegate) {
}
TEST_F(CookieMonsterTest, DeleteAllForHost) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
// Test probes:
// * Non-secure URL, mid-level (http://w.c.b.a)
@@ -1798,7 +1797,7 @@ TEST_F(CookieMonsterTest, DeleteAllForHost) {
// the http_only cookie, the host secure cookie, and the two host
// path cookies. http_only, secure, and paths are ignored by
// this call, and domain cookies arent touched.
- PopulateCmForDeleteAllForHost(cm);
+ PopulateCmForDeleteAllForHost(cm.get());
EXPECT_EQ("dom_1=X; dom_2=X; dom_3=X; host_3=X",
GetCookies(cm.get(), GURL(kTopLevelDomainPlus3)));
EXPECT_EQ("dom_1=X; dom_2=X; host_2=X; sec_dom=X; sec_host=X",
@@ -1826,7 +1825,7 @@ TEST_F(CookieMonsterTest, DeleteAllForHost) {
GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure +
std::string("/dir1/dir2/xxx"))));
- PopulateCmForDeleteAllForHost(cm);
+ PopulateCmForDeleteAllForHost(cm.get());
EXPECT_EQ(6, DeleteAllCreatedBetweenForHost(
cm.get(), base::Time(), base::Time::Now(),
GURL(kTopLevelDomainPlus2Secure)));
@@ -1842,7 +1841,7 @@ TEST_F(CookieMonsterTest, DeleteAllForHost) {
GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure +
std::string("/dir1/dir2/xxx"))));
- PopulateCmForDeleteAllForHost(cm);
+ PopulateCmForDeleteAllForHost(cm.get());
EXPECT_EQ(6,
DeleteAllCreatedBetweenForHost(
cm.get(), base::Time(), base::Time::Now(),
@@ -1861,7 +1860,7 @@ TEST_F(CookieMonsterTest, DeleteAllForHost) {
}
TEST_F(CookieMonsterTest, UniqueCreationTime) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
CookieOptions options;
// Add in three cookies through every public interface to the
@@ -1924,7 +1923,7 @@ TEST_F(CookieMonsterTest, UniqueCreationTime) {
// Mainly a test of GetEffectiveDomain, or more specifically, of the
// expected behavior of GetEffectiveDomain within the CookieMonster.
TEST_F(CookieMonsterTest, GetKey) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
// This test is really only interesting if GetKey() actually does something.
EXPECT_EQ("google.com", cm->GetKey("www.google.com"));
@@ -1990,7 +1989,7 @@ TEST_F(CookieMonsterTest, BackingStoreCommunication) {
// Create new cookies and flush them to the store.
{
- scoped_refptr<CookieMonster> cmout(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cmout(new CookieMonster(store.get(), nullptr));
for (const CookiesInputInfo* p = input_info;
p < &input_info[arraysize(input_info)]; p++) {
EXPECT_TRUE(SetCookieWithDetails(
@@ -2006,7 +2005,7 @@ TEST_F(CookieMonsterTest, BackingStoreCommunication) {
// Create a new cookie monster and make sure that everything is correct
{
- scoped_refptr<CookieMonster> cmin(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cmin(new CookieMonster(store.get(), nullptr));
CookieList cookies(GetAllCookies(cmin.get()));
ASSERT_EQ(2u, cookies.size());
// Ordering is path length, then creation time. So second cookie
@@ -2036,7 +2035,7 @@ TEST_F(CookieMonsterTest, BackingStoreCommunication) {
TEST_F(CookieMonsterTest, CookieListOrdering) {
// Put a random set of cookies into a monster and make sure
// they're returned in the right order.
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
EXPECT_TRUE(
SetCookie(cm.get(), GURL("http://d.c.b.a.google.com/aa/x.html"), "c=1"));
EXPECT_TRUE(SetCookie(cm.get(), GURL("http://b.a.google.com/aa/bb/cc/x.html"),
@@ -2093,7 +2092,7 @@ TEST_F(CookieMonsterTest, MAYBE_GarbageCollectionTriggers) {
// First we check to make sure that a whole lot of recent cookies
// doesn't get rid of anything after garbage collection is checked for.
{
- scoped_refptr<CookieMonster> cm(
+ scoped_ptr<CookieMonster> cm(
CreateMonsterForGC(CookieMonster::kMaxCookies * 2));
EXPECT_EQ(CookieMonster::kMaxCookies * 2, GetAllCookies(cm.get()).size());
SetCookie(cm.get(), GURL("http://newdomain.com"), "b=2");
@@ -2135,9 +2134,9 @@ TEST_F(CookieMonsterTest, MAYBE_GarbageCollectionTriggers) {
for (int ci = 0; ci < static_cast<int>(arraysize(test_cases)); ++ci) {
const TestCase* test_case = &test_cases[ci];
- scoped_refptr<CookieMonster> cm(CreateMonsterFromStoreForGC(
+ scoped_ptr<CookieMonster> cm = CreateMonsterFromStoreForGC(
test_case->num_cookies, test_case->num_old_cookies, 0, 0,
- CookieMonster::kSafeFromGlobalPurgeDays * 2));
+ CookieMonster::kSafeFromGlobalPurgeDays * 2);
EXPECT_EQ(test_case->expected_initial_cookies,
GetAllCookies(cm.get()).size())
<< "For test case " << ci;
@@ -2210,7 +2209,7 @@ class CallbackCounter : public base::RefCountedThreadSafe<CallbackCounter> {
TEST_F(CookieMonsterTest, FlushStore) {
scoped_refptr<CallbackCounter> counter(new CallbackCounter());
scoped_refptr<FlushablePersistentStore> store(new FlushablePersistentStore());
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
ASSERT_EQ(0, store->flush_count());
ASSERT_EQ(0, counter->callback_count());
@@ -2245,7 +2244,7 @@ TEST_F(CookieMonsterTest, FlushStore) {
ASSERT_EQ(2, counter->callback_count());
// If there's no backing store, FlushStore() is always a safe no-op.
- cm = new CookieMonster(NULL, NULL);
+ cm.reset(new CookieMonster(nullptr, nullptr));
GetAllCookies(cm.get()); // Force init.
cm->FlushStore(base::Closure());
base::MessageLoop::current()->RunUntilIdle();
@@ -2260,7 +2259,7 @@ TEST_F(CookieMonsterTest, FlushStore) {
TEST_F(CookieMonsterTest, SetAllCookies) {
scoped_refptr<FlushablePersistentStore> store(new FlushablePersistentStore());
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
cm->SetPersistSessionCookies(true);
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "U=V; path=/"));
@@ -2306,7 +2305,7 @@ TEST_F(CookieMonsterTest, SetAllCookies) {
}
TEST_F(CookieMonsterTest, ComputeCookieDiff) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
base::Time now = base::Time::Now();
base::Time creation_time = now - base::TimeDelta::FromSeconds(1);
@@ -2423,7 +2422,7 @@ TEST_F(CookieMonsterTest, ComputeCookieDiff) {
// works).
TEST_F(CookieMonsterTest, DeleteAll) {
scoped_refptr<FlushablePersistentStore> store(new FlushablePersistentStore());
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
cm->SetPersistSessionCookies(true);
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "X=Y; path=/"));
@@ -2434,7 +2433,7 @@ TEST_F(CookieMonsterTest, DeleteAll) {
}
TEST_F(CookieMonsterTest, HistogramCheck) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
// Should match call in InitializeHistograms, but doesn't really matter
// since the histogram should have been initialized by the CM construction
// above.
@@ -2473,7 +2472,7 @@ TEST_F(CookieMonsterTest, InvalidExpiryTime) {
// CookieStore if the "persist session cookies" option is on.
TEST_F(CookieMonsterTest, PersistSessionCookies) {
scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
cm->SetPersistSessionCookies(true);
// All cookies set with SetCookie are session cookies.
@@ -2509,7 +2508,7 @@ TEST_F(CookieMonsterTest, PersistSessionCookies) {
// Test the commands sent to the persistent cookie store.
TEST_F(CookieMonsterTest, PersisentCookieStorageTest) {
scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
// Add a cookie.
EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(),
@@ -2578,7 +2577,7 @@ TEST_F(CookieMonsterTest, ControlCharacterPurge) {
// Inject our initial cookies into the mock PersistentCookieStore.
store->SetLoadExpectation(true, initial_cookies);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
EXPECT_EQ("foo=bar; hello=world", GetCookies(cm.get(), url));
}
@@ -2589,7 +2588,7 @@ TEST_F(CookieMonsterTest, CookieSourceHistogram) {
const std::string cookie_source_histogram = "Cookie.CookieSourceScheme";
scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
histograms.ExpectTotalCount(cookie_source_histogram, 0);
@@ -2656,7 +2655,7 @@ TEST_F(CookieMonsterTest, CookieDeleteEquivalentHistogramTest) {
const std::string cookie_source_histogram = "Cookie.CookieDeleteEquivalent";
scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
// Set a secure cookie from a secure origin
EXPECT_TRUE(SetCookie(cm.get(), https_www_google_.url(), "A=B; Secure"));
@@ -2721,7 +2720,7 @@ TEST_F(CookieMonsterTest, CookieDeleteEquivalentHistogramTest) {
}
TEST_F(CookieMonsterStrictSecureTest, SetSecureCookies) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
GURL http_url("http://www.google.com");
GURL http_superdomain_url("http://google.com");
GURL https_url("https://www.google.com");
@@ -2916,7 +2915,7 @@ TEST_F(CookieMonsterStrictSecureTest, EvictSecureCookies) {
// Tests that strict secure cookies doesn't trip equivalent cookie checks
// accidentally. Regression test for https://crbug.com/569943.
TEST_F(CookieMonsterStrictSecureTest, EquivalentCookies) {
- scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(nullptr, nullptr));
GURL http_url("http://www.google.com");
GURL http_superdomain_url("http://google.com");
GURL https_url("https://www.google.com");
@@ -2941,7 +2940,7 @@ TEST_F(CookieMonsterStrictSecureTest, CookieDeleteEquivalentHistogramTest) {
const std::string cookie_source_histogram = "Cookie.CookieDeleteEquivalent";
scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
- scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+ scoped_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr));
// Set a secure cookie from a secure origin
EXPECT_TRUE(SetCookie(cm.get(), https_www_google_.url(), "A=B; Secure"));
@@ -3016,7 +3015,7 @@ class CookieMonsterNotificationTest : public CookieMonsterTest {
CookieMonsterNotificationTest()
: test_url_("http://www.google.com/foo"),
store_(new MockPersistentCookieStore),
- monster_(new CookieMonster(store_.get(), NULL)) {}
+ monster_(new CookieMonster(store_.get(), nullptr)) {}
~CookieMonsterNotificationTest() override {}
@@ -3027,7 +3026,7 @@ class CookieMonsterNotificationTest : public CookieMonsterTest {
private:
scoped_refptr<MockPersistentCookieStore> store_;
- scoped_refptr<CookieMonster> monster_;
+ scoped_ptr<CookieMonster> monster_;
};
void RecordCookieChanges(std::vector<CanonicalCookie>* out_cookies,

Powered by Google App Engine
This is Rietveld 408576698