Remove ENABLE_PERSISTENT_SESSION_COOKIES

This isn't needed anymore now that CookieMonster::SetPersistSessionCookies
exists.

BUG=115372


Review URL: https://chromiumcodereview.appspot.com/10831117

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149708 0039d316-1c4b-4281-b951-d872f2087c98
parent d5e08558
...@@ -60,10 +60,6 @@ namespace net { ...@@ -60,10 +60,6 @@ namespace net {
namespace { namespace {
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
const int kPersistentSessionCookieExpiryInDays = 14;
#endif
// Determine the cookie domain to use for setting the specified cookie. // Determine the cookie domain to use for setting the specified cookie.
bool GetCookieDomain(const GURL& url, bool GetCookieDomain(const GURL& url,
const ParsedCookie& pc, const ParsedCookie& pc,
...@@ -109,7 +105,6 @@ std::string CanonPathWithString(const GURL& url, ...@@ -109,7 +105,6 @@ std::string CanonPathWithString(const GURL& url,
CanonicalCookie::CanonicalCookie() CanonicalCookie::CanonicalCookie()
: secure_(false), : secure_(false),
httponly_(false) { httponly_(false) {
SetSessionCookieExpiryTime();
} }
CanonicalCookie::CanonicalCookie( CanonicalCookie::CanonicalCookie(
...@@ -130,8 +125,6 @@ CanonicalCookie::CanonicalCookie( ...@@ -130,8 +125,6 @@ CanonicalCookie::CanonicalCookie(
last_access_date_(last_access), last_access_date_(last_access),
secure_(secure), secure_(secure),
httponly_(httponly) { httponly_(httponly) {
if (expiration.is_null())
SetSessionCookieExpiryTime();
} }
CanonicalCookie::CanonicalCookie(const GURL& url, const ParsedCookie& pc) CanonicalCookie::CanonicalCookie(const GURL& url, const ParsedCookie& pc)
...@@ -147,8 +140,6 @@ CanonicalCookie::CanonicalCookie(const GURL& url, const ParsedCookie& pc) ...@@ -147,8 +140,6 @@ CanonicalCookie::CanonicalCookie(const GURL& url, const ParsedCookie& pc)
httponly_(pc.IsHttpOnly()) { httponly_(pc.IsHttpOnly()) {
if (pc.HasExpires()) if (pc.HasExpires())
expiry_date_ = CanonExpiration(pc, creation_date_, creation_date_); expiry_date_ = CanonExpiration(pc, creation_date_, creation_date_);
else
SetSessionCookieExpiryTime();
// Do the best we can with the domain. // Do the best we can with the domain.
std::string cookie_domain; std::string cookie_domain;
...@@ -214,15 +205,6 @@ Time CanonicalCookie::CanonExpiration(const ParsedCookie& pc, ...@@ -214,15 +205,6 @@ Time CanonicalCookie::CanonExpiration(const ParsedCookie& pc,
return Time(); return Time();
} }
void CanonicalCookie::SetSessionCookieExpiryTime() {
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
// Mobile apps can sometimes be shut down without any warning, so the session
// cookie has to be persistent and given a default expiration time.
expiry_date_ = base::Time::Now() +
base::TimeDelta::FromDays(kPersistentSessionCookieExpiryInDays);
#endif
}
CanonicalCookie* CanonicalCookie::Create(const GURL& url, CanonicalCookie* CanonicalCookie::Create(const GURL& url,
const ParsedCookie& pc) { const ParsedCookie& pc) {
if (!pc.IsValid()) { if (!pc.IsValid()) {
......
...@@ -121,9 +121,6 @@ class NET_EXPORT CanonicalCookie { ...@@ -121,9 +121,6 @@ class NET_EXPORT CanonicalCookie {
const base::Time& server_time); const base::Time& server_time);
private: private:
// Gives the session cookie an expiration time if needed
void SetSessionCookieExpiryTime();
// The source member of a canonical cookie is the origin of the URL that tried // The source member of a canonical cookie is the origin of the URL that tried
// to set this cookie, minus the port number if any. This field is not // to set this cookie, minus the port number if any. This field is not
// persistent though; its only used in the in-tab cookies dialog to show the // persistent though; its only used in the in-tab cookies dialog to show the
......
...@@ -894,34 +894,18 @@ TEST_F(CookieMonsterTest, TestCookieDeleteAll) { ...@@ -894,34 +894,18 @@ TEST_F(CookieMonsterTest, TestCookieDeleteAll) {
EXPECT_EQ(2, DeleteAll(cm)); EXPECT_EQ(2, DeleteAll(cm));
EXPECT_EQ("", GetCookiesWithOptions(cm, url_google_, options)); EXPECT_EQ("", GetCookiesWithOptions(cm, url_google_, options));
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
// If a cookie is persistent then its commands will be recorded.
// Each above cookie has 2 commands: 1 for add and 1 for delete.
EXPECT_EQ(4u, store->commands().size());
#else
EXPECT_EQ(0u, store->commands().size()); EXPECT_EQ(0u, store->commands().size());
#endif
// Create a persistent cookie. // Create a persistent cookie.
EXPECT_TRUE(SetCookie(cm, url_google_, EXPECT_TRUE(SetCookie(cm, url_google_,
std::string(kValidCookieLine) + std::string(kValidCookieLine) +
"; expires=Mon, 18-Apr-22 22:50:13 GMT")); "; expires=Mon, 18-Apr-22 22:50:13 GMT"));
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
ASSERT_EQ(5u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[4].type);
#else
ASSERT_EQ(1u, store->commands().size()); ASSERT_EQ(1u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[0].type); EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[0].type);
#endif
EXPECT_EQ(1, DeleteAll(cm)); // sync_to_store = true. EXPECT_EQ(1, DeleteAll(cm)); // sync_to_store = true.
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
ASSERT_EQ(6u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[5].type);
#else
ASSERT_EQ(2u, store->commands().size()); ASSERT_EQ(2u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[1].type); EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[1].type);
#endif
EXPECT_EQ("", GetCookiesWithOptions(cm, url_google_, options)); EXPECT_EQ("", GetCookiesWithOptions(cm, url_google_, options));
} }
...@@ -1356,13 +1340,8 @@ TEST_F(CookieMonsterTest, Delegate) { ...@@ -1356,13 +1340,8 @@ TEST_F(CookieMonsterTest, Delegate) {
EXPECT_TRUE( EXPECT_TRUE(
SetCookie(cm, url_google_, "a=val1; path=/path1; " SetCookie(cm, url_google_, "a=val1; path=/path1; "
"expires=Mon, 18-Apr-22 22:50:13 GMT")); "expires=Mon, 18-Apr-22 22:50:13 GMT"));
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
ASSERT_EQ(5u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[4].type);
#else
ASSERT_EQ(1u, store->commands().size()); ASSERT_EQ(1u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[0].type); EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[0].type);
#endif
ASSERT_EQ(1u, delegate->changes().size()); ASSERT_EQ(1u, delegate->changes().size());
EXPECT_FALSE(delegate->changes()[0].second); EXPECT_FALSE(delegate->changes()[0].second);
EXPECT_EQ(url_google_.host(), delegate->changes()[0].first.Domain()); EXPECT_EQ(url_google_.host(), delegate->changes()[0].first.Domain());
...@@ -1379,15 +1358,9 @@ TEST_F(CookieMonsterTest, Delegate) { ...@@ -1379,15 +1358,9 @@ TEST_F(CookieMonsterTest, Delegate) {
"a=val2; path=/path1; httponly; " "a=val2; path=/path1; httponly; "
"expires=Mon, 18-Apr-22 22:50:14 GMT", "expires=Mon, 18-Apr-22 22:50:14 GMT",
allow_httponly)); allow_httponly));
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
ASSERT_EQ(7u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[5].type);
EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[6].type);
#else
ASSERT_EQ(3u, store->commands().size()); ASSERT_EQ(3u, store->commands().size());
EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[1].type); EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[1].type);
EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[2].type); EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[2].type);
#endif
ASSERT_EQ(2u, delegate->changes().size()); ASSERT_EQ(2u, delegate->changes().size());
EXPECT_EQ(url_google_.host(), delegate->changes()[0].first.Domain()); EXPECT_EQ(url_google_.host(), delegate->changes()[0].first.Domain());
EXPECT_TRUE(delegate->changes()[0].second); EXPECT_TRUE(delegate->changes()[0].second);
...@@ -1438,11 +1411,7 @@ TEST_F(CookieMonsterTest, SetCookieWithDetails) { ...@@ -1438,11 +1411,7 @@ TEST_F(CookieMonsterTest, SetCookieWithDetails) {
EXPECT_EQ("B", it->Value()); EXPECT_EQ("B", it->Value());
EXPECT_EQ("www.google.izzle", it->Domain()); EXPECT_EQ("www.google.izzle", it->Domain());
EXPECT_EQ("/foo", it->Path()); EXPECT_EQ("/foo", it->Path());
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
EXPECT_TRUE(it->IsPersistent());
#else
EXPECT_FALSE(it->IsPersistent()); EXPECT_FALSE(it->IsPersistent());
#endif
EXPECT_FALSE(it->IsSecure()); EXPECT_FALSE(it->IsSecure());
EXPECT_FALSE(it->IsHttpOnly()); EXPECT_FALSE(it->IsHttpOnly());
...@@ -1974,13 +1943,8 @@ TEST_F(CookieMonsterTest, HistogramCheck) { ...@@ -1974,13 +1943,8 @@ TEST_F(CookieMonsterTest, HistogramCheck) {
// kValidCookieLine creates a session cookie. // kValidCookieLine creates a session cookie.
ASSERT_TRUE(SetCookie(cm, url_google_, kValidCookieLine)); ASSERT_TRUE(SetCookie(cm, url_google_, kValidCookieLine));
expired_histogram->SnapshotSample(&histogram_set_1); expired_histogram->SnapshotSample(&histogram_set_1);
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
EXPECT_EQ(histogram_set_2.TotalCount() + 1,
histogram_set_1.TotalCount());
#else
EXPECT_EQ(histogram_set_2.TotalCount(), EXPECT_EQ(histogram_set_2.TotalCount(),
histogram_set_1.TotalCount()); histogram_set_1.TotalCount());
#endif
} }
namespace { namespace {
...@@ -2217,12 +2181,7 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteCanonicalCookie) { ...@@ -2217,12 +2181,7 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteCanonicalCookie) {
TEST_F(CookieMonsterTest, InvalidExpiryTime) { TEST_F(CookieMonsterTest, InvalidExpiryTime) {
ParsedCookie pc(std::string(kValidCookieLine) + "; expires=Blarg arg arg"); ParsedCookie pc(std::string(kValidCookieLine) + "; expires=Blarg arg arg");
scoped_ptr<CanonicalCookie> cookie(CanonicalCookie::Create(url_google_, pc)); scoped_ptr<CanonicalCookie> cookie(CanonicalCookie::Create(url_google_, pc));
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
ASSERT_TRUE(cookie->IsPersistent());
#else
ASSERT_FALSE(cookie->IsPersistent()); ASSERT_FALSE(cookie->IsPersistent());
#endif
} }
// Test that CookieMonster writes session cookies into the underlying // Test that CookieMonster writes session cookies into the underlying
...@@ -2299,11 +2258,7 @@ TEST_F(CookieMonsterTest, PersisentCookieStorageTest) { ...@@ -2299,11 +2258,7 @@ TEST_F(CookieMonsterTest, PersisentCookieStorageTest) {
// persistent storage. // persistent storage.
EXPECT_TRUE(SetCookie(cm, url_google_, "B=Bar")); EXPECT_TRUE(SetCookie(cm, url_google_, "B=Bar"));
this->MatchCookieLines("A=Foo; B=Bar", GetCookies(cm, url_google_)); this->MatchCookieLines("A=Foo; B=Bar", GetCookies(cm, url_google_));
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
EXPECT_EQ(6u, store->commands().size());
#else
EXPECT_EQ(5u, store->commands().size()); EXPECT_EQ(5u, store->commands().size());
#endif
} }
} // namespace net } // namespace net
...@@ -1095,15 +1095,8 @@ TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) { ...@@ -1095,15 +1095,8 @@ TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) {
"A=B", options)); "A=B", options));
EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_,
"B=C; expires=Mon, 18-Apr-22 22:50:13 GMT", options)); "B=C; expires=Mon, 18-Apr-22 22:50:13 GMT", options));
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
EXPECT_EQ(0, this->DeleteSessionCookies(cs));
#else
EXPECT_EQ(1, this->DeleteSessionCookies(cs)); EXPECT_EQ(1, this->DeleteSessionCookies(cs));
#endif
EXPECT_EQ(0, this->DeleteSessionCookies(cs)); EXPECT_EQ(0, this->DeleteSessionCookies(cs));
EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_, EXPECT_TRUE(this->SetCookieWithOptions(cs, this->url_google_,
"A=B", options)); "A=B", options));
DeleteCallback callback(&this->other_thread_); DeleteCallback callback(&this->other_thread_);
...@@ -1113,12 +1106,7 @@ TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) { ...@@ -1113,12 +1106,7 @@ TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) {
cs, &callback); cs, &callback);
this->RunOnOtherThread(task); this->RunOnOtherThread(task);
EXPECT_TRUE(callback.did_run()); EXPECT_TRUE(callback.did_run());
#if defined(ENABLE_PERSISTENT_SESSION_COOKIES)
EXPECT_EQ(0, callback.num_deleted());
#else
EXPECT_EQ(1, callback.num_deleted()); EXPECT_EQ(1, callback.num_deleted());
#endif
} }
REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest, REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest,
......
...@@ -1067,11 +1067,6 @@ ...@@ -1067,11 +1067,6 @@
}, },
], ],
[ 'OS == "android"', { [ 'OS == "android"', {
'defines': [
# Android can shut down the app at any time, so the cookies must
# be saved to permanent storage.
'ENABLE_PERSISTENT_SESSION_COOKIES'
],
'dependencies': [ 'dependencies': [
'../third_party/openssl/openssl.gyp:openssl', '../third_party/openssl/openssl.gyp:openssl',
'net_jni_headers', 'net_jni_headers',
...@@ -1479,10 +1474,6 @@ ...@@ -1479,10 +1474,6 @@
}, },
], ],
[ 'OS == "android"', { [ 'OS == "android"', {
'defines': [
# Android can shut down our app at any time, so we persist session cookies.
'ENABLE_PERSISTENT_SESSION_COOKIES'
],
'dependencies': [ 'dependencies': [
'../third_party/openssl/openssl.gyp:openssl', '../third_party/openssl/openssl.gyp:openssl',
], ],
......
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