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

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 e7fb6b0875ccb750c2fbf8358303e9b15eea2e83..5e25c957952815e4f23553a979cefbe1717951da 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -45,8 +45,9 @@ class NewMockPersistentCookieStore
: public CookieMonster::PersistentCookieStore {
public:
MOCK_METHOD1(Load, void(const LoadedCallback& loaded_callback));
- MOCK_METHOD2(LoadCookiesForKey, void(const std::string& key,
- const LoadedCallback& loaded_callback));
+ MOCK_METHOD2(LoadCookiesForKey,
+ void(const std::string& key,
+ const LoadedCallback& loaded_callback));
MOCK_METHOD1(AddCookie, void(const CanonicalCookie& cc));
MOCK_METHOD1(UpdateCookieAccessTime, void(const CanonicalCookie& cc));
MOCK_METHOD1(DeleteCookie, void(const CanonicalCookie& cc));
@@ -63,8 +64,7 @@ class NewMockPersistentCookieStore
const char* kTopLevelDomainPlus1 = "http://www.harvard.edu";
const char* kTopLevelDomainPlus2 = "http://www.math.harvard.edu";
const char* kTopLevelDomainPlus2Secure = "https://www.math.harvard.edu";
-const char* kTopLevelDomainPlus3 =
- "http://www.bourbaki.math.harvard.edu";
+const char* kTopLevelDomainPlus3 = "http://www.bourbaki.math.harvard.edu";
const char* kOtherDomain = "http://www.mit.edu";
const char kUrlGoogleSpecific[] = "http://www.gmail.google.izzle";
@@ -90,12 +90,12 @@ struct CookieMonsterTestTraits {
return new CookieMonster(NULL, NULL);
}
- static const bool is_cookie_monster = true;
- static const bool supports_http_only = true;
- static const bool supports_non_dotted_domains = true;
- static const bool supports_trailing_dots = true;
- static const bool filters_schemes = true;
- static const bool has_path_prefix_bug = false;
+ static const bool is_cookie_monster = true;
+ static const bool supports_http_only = true;
+ static const bool supports_non_dotted_domains = true;
+ static const bool supports_trailing_dots = true;
+ static const bool filters_schemes = true;
+ static const bool has_path_prefix_bug = false;
static const int creation_time_granularity_in_ms = 0;
};
@@ -109,25 +109,22 @@ INSTANTIATE_TYPED_TEST_CASE_P(CookieMonster,
class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
protected:
-
CookieList GetAllCookies(CookieMonster* cm) {
DCHECK(cm);
GetCookieListCallback callback;
cm->GetAllCookiesAsync(
- base::Bind(&GetCookieListCallback::Run,
- base::Unretained(&callback)));
+ base::Bind(&GetCookieListCallback::Run, base::Unretained(&callback)));
RunFor(kTimeout);
EXPECT_TRUE(callback.did_run());
return callback.cookies();
}
- CookieList GetAllCookiesForURL(CookieMonster* cm,
- const GURL& url) {
+ CookieList GetAllCookiesForURL(CookieMonster* cm, const GURL& url) {
DCHECK(cm);
GetCookieListCallback callback;
cm->GetAllCookiesForURLAsync(
- url, base::Bind(&GetCookieListCallback::Run,
- base::Unretained(&callback)));
+ url,
+ base::Bind(&GetCookieListCallback::Run, base::Unretained(&callback)));
RunFor(kTimeout);
EXPECT_TRUE(callback.did_run());
return callback.cookies();
@@ -139,8 +136,9 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
DCHECK(cm);
GetCookieListCallback callback;
cm->GetAllCookiesForURLWithOptionsAsync(
- url, options, base::Bind(&GetCookieListCallback::Run,
- base::Unretained(&callback)));
+ url,
+ options,
+ base::Bind(&GetCookieListCallback::Run, base::Unretained(&callback)));
RunFor(kTimeout);
EXPECT_TRUE(callback.did_run());
return callback.cookies();
@@ -159,38 +157,42 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
DCHECK(cm);
ResultSavingCookieCallback<bool> callback;
cm->SetCookieWithDetailsAsync(
- url, name, value, domain, path, expiration_time, secure, http_only,
+ url,
+ name,
+ value,
+ domain,
+ path,
+ expiration_time,
+ secure,
+ http_only,
priority,
- base::Bind(
- &ResultSavingCookieCallback<bool>::Run,
- base::Unretained(&callback)));
+ base::Bind(&ResultSavingCookieCallback<bool>::Run,
+ base::Unretained(&callback)));
RunFor(kTimeout);
EXPECT_TRUE(callback.did_run());
return callback.result();
}
- int DeleteAll(CookieMonster*cm) {
+ int DeleteAll(CookieMonster* cm) {
DCHECK(cm);
ResultSavingCookieCallback<int> callback;
- cm->DeleteAllAsync(
- base::Bind(
- &ResultSavingCookieCallback<int>::Run,
- base::Unretained(&callback)));
+ cm->DeleteAllAsync(base::Bind(&ResultSavingCookieCallback<int>::Run,
+ base::Unretained(&callback)));
RunFor(kTimeout);
EXPECT_TRUE(callback.did_run());
return callback.result();
}
- int DeleteAllCreatedBetween(CookieMonster*cm,
+ int DeleteAllCreatedBetween(CookieMonster* cm,
const base::Time& delete_begin,
const base::Time& delete_end) {
DCHECK(cm);
ResultSavingCookieCallback<int> callback;
cm->DeleteAllCreatedBetweenAsync(
- delete_begin, delete_end,
- base::Bind(
- &ResultSavingCookieCallback<int>::Run,
- base::Unretained(&callback)));
+ delete_begin,
+ delete_end,
+ base::Bind(&ResultSavingCookieCallback<int>::Run,
+ base::Unretained(&callback)));
RunFor(kTimeout);
EXPECT_TRUE(callback.did_run());
return callback.result();
@@ -203,22 +205,22 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
DCHECK(cm);
ResultSavingCookieCallback<int> callback;
cm->DeleteAllCreatedBetweenForHostAsync(
- delete_begin, delete_end, url,
- base::Bind(
- &ResultSavingCookieCallback<int>::Run,
- base::Unretained(&callback)));
+ delete_begin,
+ delete_end,
+ url,
+ base::Bind(&ResultSavingCookieCallback<int>::Run,
+ base::Unretained(&callback)));
RunFor(kTimeout);
EXPECT_TRUE(callback.did_run());
return callback.result();
}
- int DeleteAllForHost(CookieMonster* cm,
- const GURL& url) {
+ int DeleteAllForHost(CookieMonster* cm, const GURL& url) {
DCHECK(cm);
ResultSavingCookieCallback<int> callback;
- cm->DeleteAllForHostAsync(
- url, base::Bind(&ResultSavingCookieCallback<int>::Run,
- base::Unretained(&callback)));
+ cm->DeleteAllForHostAsync(url,
+ base::Bind(&ResultSavingCookieCallback<int>::Run,
+ base::Unretained(&callback)));
RunFor(kTimeout);
EXPECT_TRUE(callback.did_run());
return callback.result();
@@ -409,8 +411,7 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
const std::string& domain,
const std::string& name) {
CookieList cookies = this->GetAllCookies(cm);
- for (CookieList::iterator it = cookies.begin();
- it != cookies.end(); ++it)
+ for (CookieList::iterator it = cookies.begin(); it != cookies.end(); ++it)
if (it->Domain() == domain && it->Name() == name)
return this->DeleteCanonicalCookie(cm, *it);
return false;
@@ -510,7 +511,8 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
std::vector<std::string> priority_tok_list;
base::SplitString(coded_priority_str, ' ', &priority_tok_list);
for (std::vector<std::string>::iterator it = priority_tok_list.begin();
- it != priority_tok_list.end(); ++it) {
+ it != priority_tok_list.end();
+ ++it) {
size_t len = it->length();
DCHECK_NE(len, 0U);
// Take last character as priority.
@@ -540,7 +542,8 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
std::vector<std::string> cookie_tok_list;
base::SplitString(cookie_str, ';', &cookie_tok_list);
for (std::vector<std::string>::iterator it = cookie_tok_list.begin();
- it != cookie_tok_list.end(); ++it) {
+ it != cookie_tok_list.end();
+ ++it) {
// Assuming *it is "a#=b", so extract and parse "#" portion.
int id = -1;
bool result = base::StringToInt(
@@ -552,9 +555,8 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
}
// Validate each priority.
- size_t expected_count[3] = {
- expected_low_count, expected_medium_count, expected_high_count
- };
+ size_t expected_count[3] = {expected_low_count, expected_medium_count,
+ expected_high_count};
for (int i = 0; i < 3; ++i) {
DCHECK_LE(surviving_id_list[i].size(), id_list[i].size());
EXPECT_EQ(expected_count[i], surviving_id_list[i].size());
@@ -572,8 +574,9 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
void TestPriorityAwareGarbageCollectHelper() {
// Hard-coding limits in the test, but use DCHECK_EQ to enforce constraint.
DCHECK_EQ(180U, CookieMonster::kDomainMaxCookies);
- DCHECK_EQ(150U, CookieMonster::kDomainMaxCookies -
- CookieMonster::kDomainPurgeCookies);
+ DCHECK_EQ(
+ 150U,
+ CookieMonster::kDomainMaxCookies - CookieMonster::kDomainPurgeCookies);
DCHECK_EQ(30U, CookieMonster::kDomainCookiesQuotaLow);
DCHECK_EQ(50U, CookieMonster::kDomainCookiesQuotaMedium);
DCHECK_EQ(70U, CookieMonster::kDomainCookiesQuotaHigh);
@@ -632,7 +635,8 @@ class CookieMonsterTest : public CookieStoreTest<CookieMonsterTestTraits> {
// TODO(erikwright): Replace the other callbacks and synchronous helper methods
// in this test suite with these Mocks.
-template<typename T, typename C> class MockCookieCallback {
+template <typename T, typename C>
+class MockCookieCallback {
public:
C AsCallback() {
return base::Bind(&T::Invoke, base::Unretained(static_cast<T*>(this)));
@@ -640,42 +644,41 @@ template<typename T, typename C> class MockCookieCallback {
};
class MockGetCookiesCallback
- : public MockCookieCallback<MockGetCookiesCallback,
- CookieStore::GetCookiesCallback> {
+ : public MockCookieCallback<MockGetCookiesCallback,
+ CookieStore::GetCookiesCallback> {
public:
MOCK_METHOD1(Invoke, void(const std::string& cookies));
};
class MockSetCookiesCallback
- : public MockCookieCallback<MockSetCookiesCallback,
- CookieStore::SetCookiesCallback> {
+ : public MockCookieCallback<MockSetCookiesCallback,
+ CookieStore::SetCookiesCallback> {
public:
MOCK_METHOD1(Invoke, void(bool success));
};
-class MockClosure
- : public MockCookieCallback<MockClosure, base::Closure> {
+class MockClosure : public MockCookieCallback<MockClosure, base::Closure> {
public:
MOCK_METHOD0(Invoke, void(void));
};
class MockGetCookieListCallback
- : public MockCookieCallback<MockGetCookieListCallback,
- CookieMonster::GetCookieListCallback> {
+ : public MockCookieCallback<MockGetCookieListCallback,
+ CookieMonster::GetCookieListCallback> {
public:
MOCK_METHOD1(Invoke, void(const CookieList& cookies));
};
class MockDeleteCallback
- : public MockCookieCallback<MockDeleteCallback,
- CookieMonster::DeleteCallback> {
+ : public MockCookieCallback<MockDeleteCallback,
+ CookieMonster::DeleteCallback> {
public:
MOCK_METHOD1(Invoke, void(int num_deleted));
};
class MockDeleteCookieCallback
- : public MockCookieCallback<MockDeleteCookieCallback,
- CookieMonster::DeleteCookieCallback> {
+ : public MockCookieCallback<MockDeleteCookieCallback,
+ CookieMonster::DeleteCookieCallback> {
public:
MOCK_METHOD1(Invoke, void(bool success));
};
@@ -711,15 +714,24 @@ ACTION_P4(SetCookieAction, cookie_monster, url, cookie_line, callback) {
url, cookie_line, CookieOptions(), callback->AsCallback());
}
ACTION_P4(DeleteAllCreatedBetweenAction,
- cookie_monster, delete_begin, delete_end, callback) {
+ cookie_monster,
+ delete_begin,
+ delete_end,
+ callback) {
cookie_monster->DeleteAllCreatedBetweenAsync(
delete_begin, delete_end, callback->AsCallback());
}
ACTION_P3(SetCookieWithDetailsAction, cookie_monster, cc, callback) {
- cookie_monster->SetCookieWithDetailsAsync(
- cc.url, cc.name, cc.value, cc.domain, cc.path, cc.expiration_time,
- cc.secure, cc.http_only, cc.priority,
- callback->AsCallback());
+ cookie_monster->SetCookieWithDetailsAsync(cc.url,
+ cc.name,
+ cc.value,
+ cc.domain,
+ cc.path,
+ cc.expiration_time,
+ cc.secure,
+ cc.http_only,
+ cc.priority,
+ callback->AsCallback());
}
ACTION_P2(GetAllCookiesAction, cookie_monster, callback) {
@@ -833,8 +845,8 @@ class DeferredCookieTaskTest : public CookieMonsterTest {
if (quit_queue)
EXPECT_CALL(*persistent_store_.get(), LoadCookiesForKey(key, testing::_))
.WillOnce(
- testing::DoAll(PushCallbackAction(&loaded_for_key_callbacks_),
- QuitCurrentMessageLoop()));
+ testing::DoAll(PushCallbackAction(&loaded_for_key_callbacks_),
+ QuitCurrentMessageLoop()));
else
EXPECT_CALL(*persistent_store_.get(), LoadCookiesForKey(key, testing::_))
.WillOnce(PushCallbackAction(&loaded_for_key_callbacks_));
@@ -858,7 +870,7 @@ class DeferredCookieTaskTest : public CookieMonsterTest {
// Stores the callback passed from the CookieMonster to the
// PersistentCookieStore::LoadCookiesForKey
std::queue<CookieMonster::PersistentCookieStore::LoadedCallback>
- loaded_for_key_callbacks_;
+ loaded_for_key_callbacks_;
// Stores the CookieMonster under test.
scoped_refptr<CookieMonster> cookie_monster_;
@@ -873,15 +885,16 @@ TEST_F(DeferredCookieTaskTest, DeferredGetCookies) {
MockGetCookiesCallback get_cookies_callback;
- BeginWithForDomainKey("google.izzle", GetCookiesAction(
- &cookie_monster(), url_google_, &get_cookies_callback));
+ BeginWithForDomainKey(
+ "google.izzle",
+ GetCookiesAction(&cookie_monster(), url_google_, &get_cookies_callback));
WaitForLoadCall();
EXPECT_CALL(get_cookies_callback, Invoke("X=1")).WillOnce(
GetCookiesAction(&cookie_monster(), url_google_, &get_cookies_callback));
- EXPECT_CALL(get_cookies_callback, Invoke("X=1")).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(get_cookies_callback, Invoke("X=1"))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -889,16 +902,17 @@ TEST_F(DeferredCookieTaskTest, DeferredGetCookies) {
TEST_F(DeferredCookieTaskTest, DeferredSetCookie) {
MockSetCookiesCallback set_cookies_callback;
- BeginWithForDomainKey("google.izzle", SetCookieAction(
- &cookie_monster(), url_google_, "A=B", &set_cookies_callback));
+ BeginWithForDomainKey(
+ "google.izzle",
+ SetCookieAction(
+ &cookie_monster(), url_google_, "A=B", &set_cookies_callback));
WaitForLoadCall();
- EXPECT_CALL(set_cookies_callback, Invoke(true)).WillOnce(
- SetCookieAction(
- &cookie_monster(), url_google_, "X=Y", &set_cookies_callback));
- EXPECT_CALL(set_cookies_callback, Invoke(true)).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(set_cookies_callback, Invoke(true)).WillOnce(SetCookieAction(
+ &cookie_monster(), url_google_, "X=Y", &set_cookies_callback));
+ EXPECT_CALL(set_cookies_callback, Invoke(true))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -906,16 +920,17 @@ TEST_F(DeferredCookieTaskTest, DeferredSetCookie) {
TEST_F(DeferredCookieTaskTest, DeferredDeleteCookie) {
MockClosure delete_cookie_callback;
- BeginWithForDomainKey("google.izzle", DeleteCookieAction(
- &cookie_monster(), url_google_, "A", &delete_cookie_callback));
+ BeginWithForDomainKey(
+ "google.izzle",
+ DeleteCookieAction(
+ &cookie_monster(), url_google_, "A", &delete_cookie_callback));
WaitForLoadCall();
- EXPECT_CALL(delete_cookie_callback, Invoke()).WillOnce(
- DeleteCookieAction(
- &cookie_monster(), url_google_, "X", &delete_cookie_callback));
- EXPECT_CALL(delete_cookie_callback, Invoke()).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(delete_cookie_callback, Invoke()).WillOnce(DeleteCookieAction(
+ &cookie_monster(), url_google_, "X", &delete_cookie_callback));
+ EXPECT_CALL(delete_cookie_callback, Invoke())
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -924,23 +939,23 @@ TEST_F(DeferredCookieTaskTest, DeferredSetCookieWithDetails) {
MockSetCookiesCallback set_cookies_callback;
CookiesInputInfo cookie_info = {
- url_google_foo_, "A", "B", std::string(), "/foo",
- base::Time(), false, false, COOKIE_PRIORITY_DEFAULT
- };
- BeginWithForDomainKey("google.izzle", SetCookieWithDetailsAction(
- &cookie_monster(), cookie_info, &set_cookies_callback));
+ url_google_foo_, "A", "B", std::string(), "/foo",
+ base::Time(), false, false, COOKIE_PRIORITY_DEFAULT};
+ BeginWithForDomainKey(
+ "google.izzle",
+ SetCookieWithDetailsAction(
+ &cookie_monster(), cookie_info, &set_cookies_callback));
WaitForLoadCall();
CookiesInputInfo cookie_info_exp = {
- url_google_foo_, "A", "B", std::string(), "/foo",
- base::Time(), false, false, COOKIE_PRIORITY_DEFAULT
- };
- EXPECT_CALL(set_cookies_callback, Invoke(true)).WillOnce(
- SetCookieWithDetailsAction(
+ url_google_foo_, "A", "B", std::string(), "/foo",
+ base::Time(), false, false, COOKIE_PRIORITY_DEFAULT};
+ EXPECT_CALL(set_cookies_callback, Invoke(true))
+ .WillOnce(SetCookieWithDetailsAction(
&cookie_monster(), cookie_info_exp, &set_cookies_callback));
- EXPECT_CALL(set_cookies_callback, Invoke(true)).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(set_cookies_callback, Invoke(true))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -952,15 +967,14 @@ TEST_F(DeferredCookieTaskTest, DeferredGetAllCookies) {
MockGetCookieListCallback get_cookie_list_callback;
- BeginWith(GetAllCookiesAction(
- &cookie_monster(), &get_cookie_list_callback));
+ BeginWith(GetAllCookiesAction(&cookie_monster(), &get_cookie_list_callback));
WaitForLoadCall();
EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_)).WillOnce(
GetAllCookiesAction(&cookie_monster(), &get_cookie_list_callback));
- EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_)).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -972,16 +986,18 @@ TEST_F(DeferredCookieTaskTest, DeferredGetAllForUrlCookies) {
MockGetCookieListCallback get_cookie_list_callback;
- BeginWithForDomainKey("google.izzle", GetAllCookiesForUrlAction(
- &cookie_monster(), url_google_, &get_cookie_list_callback));
+ BeginWithForDomainKey(
+ "google.izzle",
+ GetAllCookiesForUrlAction(
+ &cookie_monster(), url_google_, &get_cookie_list_callback));
WaitForLoadCall();
- EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_)).WillOnce(
- GetAllCookiesForUrlAction(
+ EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_))
+ .WillOnce(GetAllCookiesForUrlAction(
&cookie_monster(), url_google_, &get_cookie_list_callback));
- EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_)).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -993,16 +1009,18 @@ TEST_F(DeferredCookieTaskTest, DeferredGetAllForUrlWithOptionsCookies) {
MockGetCookieListCallback get_cookie_list_callback;
- BeginWithForDomainKey("google.izzle", GetAllCookiesForUrlWithOptionsAction(
- &cookie_monster(), url_google_, &get_cookie_list_callback));
+ BeginWithForDomainKey(
+ "google.izzle",
+ GetAllCookiesForUrlWithOptionsAction(
+ &cookie_monster(), url_google_, &get_cookie_list_callback));
WaitForLoadCall();
- EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_)).WillOnce(
- GetAllCookiesForUrlWithOptionsAction(
+ EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_))
+ .WillOnce(GetAllCookiesForUrlWithOptionsAction(
&cookie_monster(), url_google_, &get_cookie_list_callback));
- EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_)).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(get_cookie_list_callback, Invoke(testing::_))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -1010,15 +1028,14 @@ TEST_F(DeferredCookieTaskTest, DeferredGetAllForUrlWithOptionsCookies) {
TEST_F(DeferredCookieTaskTest, DeferredDeleteAllCookies) {
MockDeleteCallback delete_callback;
- BeginWith(DeleteAllAction(
- &cookie_monster(), &delete_callback));
+ BeginWith(DeleteAllAction(&cookie_monster(), &delete_callback));
WaitForLoadCall();
- EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
- DeleteAllAction(&cookie_monster(), &delete_callback));
- EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(delete_callback, Invoke(false))
+ .WillOnce(DeleteAllAction(&cookie_monster(), &delete_callback));
+ EXPECT_CALL(delete_callback, Invoke(false))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -1031,12 +1048,13 @@ TEST_F(DeferredCookieTaskTest, DeferredDeleteAllCreatedBetweenCookies) {
WaitForLoadCall();
- EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
- DeleteAllCreatedBetweenAction(
- &cookie_monster(), base::Time(), base::Time::Now(),
- &delete_callback));
- EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(delete_callback, Invoke(false))
+ .WillOnce(DeleteAllCreatedBetweenAction(&cookie_monster(),
+ base::Time(),
+ base::Time::Now(),
+ &delete_callback));
+ EXPECT_CALL(delete_callback, Invoke(false))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -1044,24 +1062,24 @@ TEST_F(DeferredCookieTaskTest, DeferredDeleteAllCreatedBetweenCookies) {
TEST_F(DeferredCookieTaskTest, DeferredDeleteAllForHostCookies) {
MockDeleteCallback delete_callback;
- BeginWithForDomainKey("google.izzle", DeleteAllForHostAction(
- &cookie_monster(), url_google_, &delete_callback));
+ BeginWithForDomainKey(
+ "google.izzle",
+ DeleteAllForHostAction(&cookie_monster(), url_google_, &delete_callback));
WaitForLoadCall();
EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
- DeleteAllForHostAction(
- &cookie_monster(), url_google_, &delete_callback));
- EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
- QuitCurrentMessageLoop());
+ DeleteAllForHostAction(&cookie_monster(), url_google_, &delete_callback));
+ EXPECT_CALL(delete_callback, Invoke(false))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
TEST_F(DeferredCookieTaskTest, DeferredDeleteCanonicalCookie) {
std::vector<CanonicalCookie*> cookies;
- CanonicalCookie cookie = BuildCanonicalCookie(
- "www.google.com", "X=1; path=/", base::Time::Now());
+ CanonicalCookie cookie =
+ BuildCanonicalCookie("www.google.com", "X=1; path=/", base::Time::Now());
MockDeleteCookieCallback delete_cookie_callback;
@@ -1070,11 +1088,11 @@ TEST_F(DeferredCookieTaskTest, DeferredDeleteCanonicalCookie) {
WaitForLoadCall();
- EXPECT_CALL(delete_cookie_callback, Invoke(false)).WillOnce(
- DeleteCanonicalCookieAction(
- &cookie_monster(), cookie, &delete_cookie_callback));
- EXPECT_CALL(delete_cookie_callback, Invoke(false)).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(delete_cookie_callback, Invoke(false))
+ .WillOnce(DeleteCanonicalCookieAction(
+ &cookie_monster(), cookie, &delete_cookie_callback));
+ EXPECT_CALL(delete_cookie_callback, Invoke(false))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -1082,15 +1100,14 @@ TEST_F(DeferredCookieTaskTest, DeferredDeleteCanonicalCookie) {
TEST_F(DeferredCookieTaskTest, DeferredDeleteSessionCookies) {
MockDeleteCallback delete_callback;
- BeginWith(DeleteSessionCookiesAction(
- &cookie_monster(), &delete_callback));
+ BeginWith(DeleteSessionCookiesAction(&cookie_monster(), &delete_callback));
WaitForLoadCall();
EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
DeleteSessionCookiesAction(&cookie_monster(), &delete_callback));
- EXPECT_CALL(delete_callback, Invoke(false)).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(delete_callback, Invoke(false))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
@@ -1108,8 +1125,7 @@ TEST_F(DeferredCookieTaskTest, DeferredTaskOrder) {
MockGetCookiesCallback get_cookies_callback_deferred;
EXPECT_CALL(*this, Begin()).WillOnce(testing::DoAll(
- GetCookiesAction(
- &cookie_monster(), url_google_, &get_cookies_callback),
+ GetCookiesAction(&cookie_monster(), url_google_, &get_cookies_callback),
SetCookieAction(
&cookie_monster(), url_google_, "A=B", &set_cookies_callback)));
ExpectLoadCall();
@@ -1117,19 +1133,17 @@ TEST_F(DeferredCookieTaskTest, DeferredTaskOrder) {
Begin();
WaitForLoadCall();
- EXPECT_CALL(get_cookies_callback, Invoke("X=1")).WillOnce(
- GetCookiesAction(
- &cookie_monster(), url_google_, &get_cookies_callback_deferred));
+ EXPECT_CALL(get_cookies_callback, Invoke("X=1")).WillOnce(GetCookiesAction(
+ &cookie_monster(), url_google_, &get_cookies_callback_deferred));
EXPECT_CALL(set_cookies_callback, Invoke(true));
- EXPECT_CALL(get_cookies_callback_deferred, Invoke("A=B; X=1")).WillOnce(
- QuitCurrentMessageLoop());
+ EXPECT_CALL(get_cookies_callback_deferred, Invoke("A=B; X=1"))
+ .WillOnce(QuitCurrentMessageLoop());
CompleteLoadingAndWait();
}
TEST_F(CookieMonsterTest, TestCookieDeleteAll) {
- scoped_refptr<MockPersistentCookieStore> store(
- new MockPersistentCookieStore);
+ scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
CookieOptions options;
options.set_include_httponly();
@@ -1171,14 +1185,14 @@ TEST_F(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps) {
// Create 3 cookies with creation date of today, yesterday and the day before.
EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google_, "T-0=Now", now));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google_, "T-1=Yesterday",
- now - TimeDelta::FromDays(1)));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google_, "T-2=DayBefore",
- now - TimeDelta::FromDays(2)));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google_, "T-3=ThreeDays",
- now - TimeDelta::FromDays(3)));
- EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google_, "T-7=LastWeek",
- now - TimeDelta::FromDays(7)));
+ EXPECT_TRUE(cm->SetCookieWithCreationTime(
+ url_google_, "T-1=Yesterday", now - TimeDelta::FromDays(1)));
+ EXPECT_TRUE(cm->SetCookieWithCreationTime(
+ url_google_, "T-2=DayBefore", now - TimeDelta::FromDays(2)));
+ EXPECT_TRUE(cm->SetCookieWithCreationTime(
+ url_google_, "T-3=ThreeDays", now - TimeDelta::FromDays(3)));
+ EXPECT_TRUE(cm->SetCookieWithCreationTime(
+ url_google_, "T-7=LastWeek", now - TimeDelta::FromDays(7)));
// Try to delete threedays and the daybefore.
EXPECT_EQ(2,
@@ -1384,8 +1398,7 @@ TEST_F(CookieMonsterTest, DeleteCookieByName) {
CookieList cookies = GetAllCookies(cm.get());
size_t expected_size = 4;
EXPECT_EQ(expected_size, cookies.size());
- for (CookieList::iterator it = cookies.begin();
- it != cookies.end(); ++it) {
+ for (CookieList::iterator it = cookies.begin(); it != cookies.end(); ++it) {
EXPECT_NE("A1", it->Value());
EXPECT_NE("A2", it->Value());
}
@@ -1395,15 +1408,11 @@ TEST_F(CookieMonsterTest, InitializeFromCookieMonster) {
scoped_refptr<CookieMonster> cm_1(new CookieMonster(NULL, NULL));
CookieOptions options;
- EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_foo_,
- "A1=B; path=/foo;",
- options));
- EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_bar_,
- "A2=D; path=/bar;",
- options));
- EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_,
- "A3=F;",
- options));
+ EXPECT_TRUE(SetCookieWithOptions(
+ cm_1.get(), url_google_foo_, "A1=B; path=/foo;", options));
+ EXPECT_TRUE(SetCookieWithOptions(
+ cm_1.get(), url_google_bar_, "A2=D; path=/bar;", options));
+ EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_, "A3=F;", options));
CookieList cookies_1 = GetAllCookies(cm_1.get());
scoped_refptr<CookieMonster> cm_2(new CookieMonster(NULL, NULL));
@@ -1434,8 +1443,7 @@ TEST_F(CookieMonsterTest, InitializeFromCookieMonster) {
//
// This is a regression test for: http://crbug.com/17855.
TEST_F(CookieMonsterTest, DontImportDuplicateCookies) {
- scoped_refptr<MockPersistentCookieStore> store(
- new MockPersistentCookieStore);
+ scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
// We will fill some initial cookies into the PersistentCookieStore,
// to simulate a database with 4 duplicates. Note that we need to
@@ -1517,8 +1525,7 @@ TEST_F(CookieMonsterTest, DontImportDuplicateCookies) {
//
// This is a regression test for: http://crbug.com/43188.
TEST_F(CookieMonsterTest, DontImportDuplicateCreationTimes) {
- scoped_refptr<MockPersistentCookieStore> store(
- new MockPersistentCookieStore);
+ scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
Time now(Time::Now());
Time earlier(now - TimeDelta::FromDays(1));
@@ -1554,8 +1561,7 @@ TEST_F(CookieMonsterTest, DontImportDuplicateCreationTimes) {
}
TEST_F(CookieMonsterTest, CookieMonsterDelegate) {
- scoped_refptr<MockPersistentCookieStore> store(
- new MockPersistentCookieStore);
+ scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
scoped_refptr<MockCookieMonsterDelegate> delegate(
new MockCookieMonsterDelegate);
scoped_refptr<CookieMonster> cm(
@@ -1776,11 +1782,12 @@ TEST_F(CookieMonsterTest, DeleteAllForHost) {
GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure)));
EXPECT_EQ("dom_1=X; host_1=X",
GetCookies(cm.get(), GURL(kTopLevelDomainPlus1)));
- EXPECT_EQ("dom_path_2=X; host_path_2=X; dom_path_1=X; host_path_1=X; "
- "dom_1=X; dom_2=X; host_2=X; sec_dom=X; sec_host=X",
- GetCookies(cm.get(),
- GURL(kTopLevelDomainPlus2Secure +
- std::string("/dir1/dir2/xxx"))));
+ EXPECT_EQ(
+ "dom_path_2=X; host_path_2=X; dom_path_1=X; host_path_1=X; "
+ "dom_1=X; dom_2=X; host_2=X; sec_dom=X; sec_host=X",
+ GetCookies(
+ cm.get(),
+ GURL(kTopLevelDomainPlus2Secure + std::string("/dir1/dir2/xxx"))));
EXPECT_EQ(5, DeleteAllForHost(cm.get(), GURL(kTopLevelDomainPlus2)));
EXPECT_EQ(8U, GetAllCookies(cm.get()).size());
@@ -1891,10 +1898,11 @@ TEST_F(CookieMonsterTest, UniqueCreationTime) {
typedef std::map<int64, CanonicalCookie> TimeCookieMap;
TimeCookieMap check_map;
for (CookieList::const_iterator it = cookie_list.begin();
- it != cookie_list.end(); it++) {
+ it != cookie_list.end();
+ it++) {
const int64 creation_date = it->CreationDate().ToInternalValue();
- TimeCookieMap::const_iterator
- existing_cookie_it(check_map.find(creation_date));
+ TimeCookieMap::const_iterator existing_cookie_it(
+ check_map.find(creation_date));
EXPECT_TRUE(existing_cookie_it == check_map.end())
<< "Cookie " << it->Name() << " has same creation date ("
<< it->CreationDate().ToInternalValue()
@@ -1902,8 +1910,8 @@ TEST_F(CookieMonsterTest, UniqueCreationTime) {
<< existing_cookie_it->second.Name();
if (existing_cookie_it == check_map.end()) {
- check_map.insert(TimeCookieMap::value_type(
- it->CreationDate().ToInternalValue(), *it));
+ check_map.insert(
+ TimeCookieMap::value_type(it->CreationDate().ToInternalValue(), *it));
}
}
}
@@ -1943,15 +1951,14 @@ TEST_F(CookieMonsterTest, BackingStoreCommunication) {
base::Time expires(base::Time::Now() + base::TimeDelta::FromSeconds(100));
const CookiesInputInfo input_info[] = {
- {GURL("http://a.b.google.com"), "a", "1", "", "/path/to/cookie", expires,
- false, false, COOKIE_PRIORITY_DEFAULT},
- {GURL("https://www.google.com"), "b", "2", ".google.com",
- "/path/from/cookie", expires + TimeDelta::FromSeconds(10),
- true, true, COOKIE_PRIORITY_DEFAULT},
- {GURL("https://google.com"), "c", "3", "", "/another/path/to/cookie",
- base::Time::Now() + base::TimeDelta::FromSeconds(100),
- true, false, COOKIE_PRIORITY_DEFAULT}
- };
+ {GURL("http://a.b.google.com"), "a", "1", "", "/path/to/cookie", expires,
+ false, false, COOKIE_PRIORITY_DEFAULT},
+ {GURL("https://www.google.com"), "b", "2", ".google.com",
+ "/path/from/cookie", expires + TimeDelta::FromSeconds(10), true, true,
+ COOKIE_PRIORITY_DEFAULT},
+ {GURL("https://google.com"), "c", "3", "", "/another/path/to/cookie",
+ base::Time::Now() + base::TimeDelta::FromSeconds(100), true, false,
+ COOKIE_PRIORITY_DEFAULT}};
const int INPUT_DELETE = 1;
// Create new cookies and flush them to the store.
@@ -1971,8 +1978,9 @@ TEST_F(CookieMonsterTest, BackingStoreCommunication) {
p->http_only,
p->priority));
}
- GURL del_url(input_info[INPUT_DELETE].url.Resolve(
- input_info[INPUT_DELETE].path).spec());
+ GURL del_url(input_info[INPUT_DELETE]
+ .url.Resolve(input_info[INPUT_DELETE].path)
+ .spec());
DeleteCookie(cmout.get(), del_url, input_info[INPUT_DELETE].name);
}
@@ -2084,46 +2092,38 @@ TEST_F(CookieMonsterTest, MAYBE_GarbageCollectionTriggers) {
// Indexed by ExpiryAndKeyScheme
size_t expected_cookies_after_set;
} test_cases[] = {
- {
- // A whole lot of recent cookies; gc shouldn't happen.
- CookieMonster::kMaxCookies * 2,
- 0,
- CookieMonster::kMaxCookies * 2,
- CookieMonster::kMaxCookies * 2 + 1
- }, {
- // Some old cookies, but still overflowing max.
- CookieMonster::kMaxCookies * 2,
- CookieMonster::kMaxCookies / 2,
- CookieMonster::kMaxCookies * 2,
- CookieMonster::kMaxCookies * 2 - CookieMonster::kMaxCookies / 2 + 1
- }, {
- // Old cookies enough to bring us right down to our purge line.
- CookieMonster::kMaxCookies * 2,
- CookieMonster::kMaxCookies + CookieMonster::kPurgeCookies + 1,
- CookieMonster::kMaxCookies * 2,
- CookieMonster::kMaxCookies - CookieMonster::kPurgeCookies
- }, {
- // Old cookies enough to bring below our purge line (which we
- // shouldn't do).
- CookieMonster::kMaxCookies * 2,
- CookieMonster::kMaxCookies * 3 / 2,
- CookieMonster::kMaxCookies * 2,
- CookieMonster::kMaxCookies - CookieMonster::kPurgeCookies
- }
- };
+ {// A whole lot of recent cookies; gc shouldn't happen.
+ CookieMonster::kMaxCookies * 2, 0, CookieMonster::kMaxCookies * 2,
+ CookieMonster::kMaxCookies * 2 + 1},
+ {// Some old cookies, but still overflowing max.
+ CookieMonster::kMaxCookies * 2, CookieMonster::kMaxCookies / 2,
+ CookieMonster::kMaxCookies * 2,
+ CookieMonster::kMaxCookies * 2 - CookieMonster::kMaxCookies / 2 + 1},
+ {// Old cookies enough to bring us right down to our purge line.
+ CookieMonster::kMaxCookies * 2,
+ CookieMonster::kMaxCookies + CookieMonster::kPurgeCookies + 1,
+ CookieMonster::kMaxCookies * 2,
+ CookieMonster::kMaxCookies - CookieMonster::kPurgeCookies},
+ {// Old cookies enough to bring below our purge line (which we
+ // shouldn't do).
+ CookieMonster::kMaxCookies * 2, CookieMonster::kMaxCookies * 3 / 2,
+ CookieMonster::kMaxCookies * 2,
+ CookieMonster::kMaxCookies - CookieMonster::kPurgeCookies}};
for (int ci = 0; ci < static_cast<int>(ARRAYSIZE_UNSAFE(test_cases)); ++ci) {
- const TestCase *test_case = &test_cases[ci];
- scoped_refptr<CookieMonster> cm(
- CreateMonsterFromStoreForGC(
- test_case->num_cookies, test_case->num_old_cookies,
- CookieMonster::kSafeFromGlobalPurgeDays * 2));
+ const TestCase* test_case = &test_cases[ci];
+ scoped_refptr<CookieMonster> cm(CreateMonsterFromStoreForGC(
+ test_case->num_cookies,
+ test_case->num_old_cookies,
+ CookieMonster::kSafeFromGlobalPurgeDays * 2));
EXPECT_EQ(test_case->expected_initial_cookies,
- GetAllCookies(cm.get()).size()) << "For test case " << ci;
+ GetAllCookies(cm.get()).size())
+ << "For test case " << ci;
// Will trigger GC
SetCookie(cm.get(), GURL("http://newdomain.com"), "b=2");
EXPECT_EQ(test_case->expected_cookies_after_set,
- GetAllCookies(cm.get()).size()) << "For test case " << ci;
+ GetAllCookies(cm.get()).size())
+ << "For test case " << ci;
}
}
@@ -2190,9 +2190,7 @@ class FlushablePersistentStore : public CookieMonster::PersistentCookieStore {
callback.Run();
}
- int flush_count() {
- return flush_count_;
- }
+ int flush_count() { return flush_count_; }
private:
virtual ~FlushablePersistentStore() {}
@@ -2205,13 +2203,9 @@ class CallbackCounter : public base::RefCountedThreadSafe<CallbackCounter> {
public:
CallbackCounter() : callback_count_(0) {}
- void Callback() {
- ++callback_count_;
- }
+ void Callback() { ++callback_count_; }
- int callback_count() {
- return callback_count_;
- }
+ int callback_count() { return callback_count_; }
private:
friend class base::RefCountedThreadSafe<CallbackCounter>;
@@ -2280,9 +2274,11 @@ TEST_F(CookieMonsterTest, HistogramCheck) {
// since the histogram should have been initialized by the CM construction
// above.
base::HistogramBase* expired_histogram =
- base::Histogram::FactoryGet(
- "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50,
- base::Histogram::kUmaTargetedHistogramFlag);
+ base::Histogram::FactoryGet("Cookie.ExpirationDurationMinutes",
+ 1,
+ 10 * 365 * 24 * 60,
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
scoped_ptr<base::HistogramSamples> samples1(
expired_histogram->SnapshotSamples());
@@ -2319,8 +2315,7 @@ class MultiThreadedCookieMonsterTest : public CookieMonsterTest {
// Helper methods for calling the asynchronous CookieMonster methods
// from a different thread.
- void GetAllCookiesTask(CookieMonster* cm,
- GetCookieListCallback* callback) {
+ void GetAllCookiesTask(CookieMonster* cm, GetCookieListCallback* callback) {
cm->GetAllCookiesAsync(
base::Bind(&GetCookieListCallback::Run, base::Unretained(callback)));
}
@@ -2338,11 +2333,13 @@ class MultiThreadedCookieMonsterTest : public CookieMonsterTest {
const CookieOptions& options,
GetCookieListCallback* callback) {
cm->GetAllCookiesForURLWithOptionsAsync(
- url, options,
+ url,
+ options,
base::Bind(&GetCookieListCallback::Run, base::Unretained(callback)));
}
- void SetCookieWithDetailsTask(CookieMonster* cm, const GURL& url,
+ void SetCookieWithDetailsTask(CookieMonster* cm,
+ const GURL& url,
ResultSavingCookieCallback<bool>* callback) {
// Define the parameters here instead of in the calling fucntion.
// The maximum number of parameters for Bind function is 6.
@@ -2355,11 +2352,17 @@ class MultiThreadedCookieMonsterTest : public CookieMonsterTest {
bool http_only = false;
CookiePriority priority = COOKIE_PRIORITY_DEFAULT;
cm->SetCookieWithDetailsAsync(
- url, name, value, domain, path, expiration_time, secure, http_only,
+ url,
+ name,
+ value,
+ domain,
+ path,
+ expiration_time,
+ secure,
+ http_only,
priority,
- base::Bind(
- &ResultSavingCookieCallback<bool>::Run,
- base::Unretained(callback)));
+ base::Bind(&ResultSavingCookieCallback<bool>::Run,
+ base::Unretained(callback)));
}
void DeleteAllCreatedBetweenTask(CookieMonster* cm,
@@ -2367,18 +2370,18 @@ class MultiThreadedCookieMonsterTest : public CookieMonsterTest {
const base::Time& delete_end,
ResultSavingCookieCallback<int>* callback) {
cm->DeleteAllCreatedBetweenAsync(
- delete_begin, delete_end,
- base::Bind(
- &ResultSavingCookieCallback<int>::Run, base::Unretained(callback)));
+ delete_begin,
+ delete_end,
+ base::Bind(&ResultSavingCookieCallback<int>::Run,
+ base::Unretained(callback)));
}
void DeleteAllForHostTask(CookieMonster* cm,
const GURL& url,
ResultSavingCookieCallback<int>* callback) {
- cm->DeleteAllForHostAsync(
- url,
- base::Bind(
- &ResultSavingCookieCallback<int>::Run, base::Unretained(callback)));
+ cm->DeleteAllForHostAsync(url,
+ base::Bind(&ResultSavingCookieCallback<int>::Run,
+ base::Unretained(callback)));
}
void DeleteAllCreatedBetweenForHostTask(
@@ -2388,10 +2391,11 @@ class MultiThreadedCookieMonsterTest : public CookieMonsterTest {
const GURL& url,
ResultSavingCookieCallback<int>* callback) {
cm->DeleteAllCreatedBetweenForHostAsync(
- delete_begin, delete_end, url,
- base::Bind(
- &ResultSavingCookieCallback<int>::Run,
- base::Unretained(callback)));
+ delete_begin,
+ delete_end,
+ url,
+ base::Bind(&ResultSavingCookieCallback<int>::Run,
+ base::Unretained(callback)));
}
void DeleteCanonicalCookieTask(CookieMonster* cm,
@@ -2399,9 +2403,8 @@ class MultiThreadedCookieMonsterTest : public CookieMonsterTest {
ResultSavingCookieCallback<bool>* callback) {
cm->DeleteCanonicalCookieAsync(
cookie,
- base::Bind(
- &ResultSavingCookieCallback<bool>::Run,
- base::Unretained(callback)));
+ base::Bind(&ResultSavingCookieCallback<bool>::Run,
+ base::Unretained(callback)));
}
protected:
@@ -2430,7 +2433,8 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckGetAllCookies) {
base::Closure task =
base::Bind(&net::MultiThreadedCookieMonsterTest::GetAllCookiesTask,
base::Unretained(this),
- cm, &callback);
+ cm,
+ &callback);
RunOnOtherThread(task);
EXPECT_TRUE(callback.did_run());
it = callback.cookies().begin();
@@ -2453,7 +2457,9 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckGetAllCookiesForURL) {
base::Closure task =
base::Bind(&net::MultiThreadedCookieMonsterTest::GetAllCookiesForURLTask,
base::Unretained(this),
- cm, url_google_, &callback);
+ cm,
+ url_google_,
+ &callback);
RunOnOtherThread(task);
EXPECT_TRUE(callback.did_run());
it = callback.cookies().begin();
@@ -2478,7 +2484,10 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckGetAllCookiesForURLWithOpt) {
base::Closure task = base::Bind(
&net::MultiThreadedCookieMonsterTest::GetAllCookiesForURLWithOptionsTask,
base::Unretained(this),
- cm, url_google_, options, &callback);
+ cm,
+ url_google_,
+ options,
+ &callback);
RunOnOtherThread(task);
EXPECT_TRUE(callback.did_run());
it = callback.cookies().begin();
@@ -2501,10 +2510,12 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckSetCookieWithDetails) {
false,
COOKIE_PRIORITY_DEFAULT));
ResultSavingCookieCallback<bool> callback(&other_thread_);
- base::Closure task = base::Bind(
- &net::MultiThreadedCookieMonsterTest::SetCookieWithDetailsTask,
- base::Unretained(this),
- cm, url_google_foo_, &callback);
+ base::Closure task =
+ base::Bind(&net::MultiThreadedCookieMonsterTest::SetCookieWithDetailsTask,
+ base::Unretained(this),
+ cm,
+ url_google_foo_,
+ &callback);
RunOnOtherThread(task);
EXPECT_TRUE(callback.did_run());
EXPECT_TRUE(callback.result());
@@ -2523,8 +2534,10 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteAllCreatedBetween) {
base::Closure task = base::Bind(
&net::MultiThreadedCookieMonsterTest::DeleteAllCreatedBetweenTask,
base::Unretained(this),
- cm, now - TimeDelta::FromDays(99),
- Time(), &callback);
+ cm,
+ now - TimeDelta::FromDays(99),
+ Time(),
+ &callback);
RunOnOtherThread(task);
EXPECT_TRUE(callback.did_run());
EXPECT_EQ(1, callback.result());
@@ -2537,10 +2550,12 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteAllForHost) {
EXPECT_EQ(1, DeleteAllForHost(cm.get(), url_google_));
EXPECT_TRUE(SetCookieWithOptions(cm.get(), url_google_, "A=B", options));
ResultSavingCookieCallback<int> callback(&other_thread_);
- base::Closure task = base::Bind(
- &net::MultiThreadedCookieMonsterTest::DeleteAllForHostTask,
- base::Unretained(this),
- cm, url_google_, &callback);
+ base::Closure task =
+ base::Bind(&net::MultiThreadedCookieMonsterTest::DeleteAllForHostTask,
+ base::Unretained(this),
+ cm,
+ url_google_,
+ &callback);
RunOnOtherThread(task);
EXPECT_TRUE(callback.did_run());
EXPECT_EQ(1, callback.result());
@@ -2573,8 +2588,7 @@ TEST_F(MultiThreadedCookieMonsterTest,
// 1. First set of deletions.
EXPECT_EQ(
3, // Deletes A=B, C=D, Y=Z
- DeleteAllCreatedBetweenForHost(
- cm.get(), ago3, Time::Max(), url_google_));
+ DeleteAllCreatedBetweenForHost(cm.get(), ago3, Time::Max(), url_google_));
EXPECT_TRUE(SetCookieWithOptions(cm.get(), url_google_, "A=B", options));
ResultSavingCookieCallback<int> callback(&other_thread_);
@@ -2583,7 +2597,10 @@ TEST_F(MultiThreadedCookieMonsterTest,
base::Closure task = base::Bind(
&net::MultiThreadedCookieMonsterTest::DeleteAllCreatedBetweenForHostTask,
base::Unretained(this),
- cm, ago1, Time(), url_google_,
+ cm,
+ ago1,
+ Time(),
+ url_google_,
&callback);
RunOnOtherThread(task);
EXPECT_TRUE(callback.did_run());
@@ -2605,7 +2622,9 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteCanonicalCookie) {
base::Closure task = base::Bind(
&net::MultiThreadedCookieMonsterTest::DeleteCanonicalCookieTask,
base::Unretained(this),
- cm, *it, &callback);
+ cm,
+ *it,
+ &callback);
RunOnOtherThread(task);
EXPECT_TRUE(callback.did_run());
EXPECT_TRUE(callback.result());
@@ -2614,17 +2633,15 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteCanonicalCookie) {
TEST_F(CookieMonsterTest, InvalidExpiryTime) {
std::string cookie_line =
std::string(kValidCookieLine) + "; expires=Blarg arg arg";
- scoped_ptr<CanonicalCookie> cookie(
- CanonicalCookie::Create(url_google_, cookie_line, Time::Now(),
- CookieOptions()));
+ scoped_ptr<CanonicalCookie> cookie(CanonicalCookie::Create(
+ url_google_, cookie_line, Time::Now(), CookieOptions()));
ASSERT_FALSE(cookie->IsPersistent());
}
// Test that CookieMonster writes session cookies into the underlying
// CookieStore if the "persist session cookies" option is on.
TEST_F(CookieMonsterTest, PersistSessionCookies) {
- scoped_refptr<MockPersistentCookieStore> store(
- new MockPersistentCookieStore);
+ scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
cm->SetPersistSessionCookies(true);
@@ -2660,8 +2677,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<MockPersistentCookieStore> store(new MockPersistentCookieStore);
scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
// Add a cookie.
@@ -2708,27 +2724,29 @@ TEST_F(CookieMonsterTest, ControlCharacterPurge) {
const std::string domain("host");
const std::string path("/path");
- scoped_refptr<MockPersistentCookieStore> store(
- new MockPersistentCookieStore);
+ scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
std::vector<CanonicalCookie*> initial_cookies;
- AddCookieToList(domain,
- "foo=bar; path=" + path,
- now1,
- &initial_cookies);
+ AddCookieToList(domain, "foo=bar; path=" + path, now1, &initial_cookies);
// We have to manually build this cookie because it contains a control
// character, and our cookie line parser rejects control characters.
- CanonicalCookie *cc = new CanonicalCookie(url, "baz", "\x05" "boo", domain,
- path, now2, later, now2, false,
- false, COOKIE_PRIORITY_DEFAULT);
+ CanonicalCookie* cc = new CanonicalCookie(url,
+ "baz",
+ "\x05"
+ "boo",
+ domain,
+ path,
+ now2,
+ later,
+ now2,
+ false,
+ false,
+ COOKIE_PRIORITY_DEFAULT);
initial_cookies.push_back(cc);
- AddCookieToList(domain,
- "hello=world; path=" + path,
- now3,
- &initial_cookies);
+ AddCookieToList(domain, "hello=world; path=" + path, now3, &initial_cookies);
// Inject our initial cookies into the mock PersistentCookieStore.
store->SetLoadExpectation(true, initial_cookies);

Powered by Google App Engine
This is Rietveld 408576698