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

Unified Diff: net/base/cookie_monster.cc

Issue 8533013: SessionRestore: Store session cookies and restore them if chrome crashes or auto-restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 9 years 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
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/cookie_monster.cc
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index 03061c6851041bf6b9e2a6ab707a52b57f076fde..fd11926843a368ff98aebed2d212c3daa010df8f 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -370,7 +370,8 @@ CookieMonster::CookieMonster(PersistentCookieStore* store, Delegate* delegate)
TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)),
delegate_(delegate),
last_statistic_record_time_(Time::Now()),
- keep_expired_cookies_(false) {
+ keep_expired_cookies_(false),
+ persist_session_cookies_(false) {
InitializeHistograms();
SetDefaultCookieableSchemes();
}
@@ -386,7 +387,8 @@ CookieMonster::CookieMonster(PersistentCookieStore* store,
last_access_threshold_milliseconds)),
delegate_(delegate),
last_statistic_record_time_(base::Time::Now()),
- keep_expired_cookies_(false) {
+ keep_expired_cookies_(false),
+ persist_session_cookies_(false) {
InitializeHistograms();
SetDefaultCookieableSchemes();
}
@@ -1399,6 +1401,18 @@ CookieMonster* CookieMonster::GetCookieMonster() {
return this;
}
+void CookieMonster::SetPersistSessionCookies(bool persist_session_cookies) {
+ // This function must be called before the CookieMonster is used.
+ DCHECK(!initialized_);
+ persist_session_cookies_ = persist_session_cookies;
+}
+
+void CookieMonster::SaveSessionCookies() {
+ if (store_) {
+ store_->SetClearLocalStateOnExit(false);
+ }
+}
+
CookieMonster::~CookieMonster() {
DeleteAll(false);
}
@@ -1774,7 +1788,8 @@ void CookieMonster::InternalInsertCookie(const std::string& key,
bool sync_to_store) {
lock_.AssertAcquired();
- if (cc->IsPersistent() && store_ && sync_to_store)
+ if ((cc->IsPersistent() || persist_session_cookies_) &&
+ store_ && sync_to_store)
store_->AddCookie(*cc);
cookies_.insert(CookieMap::value_type(key, cc));
if (delegate_.get()) {
@@ -1891,7 +1906,7 @@ void CookieMonster::InternalUpdateCookieAccessTime(CanonicalCookie* cc,
(current - cc->LastAccessDate()).InMinutes());
cc->SetLastAccessDate(current);
- if (cc->IsPersistent() && store_)
+ if ((cc->IsPersistent() || persist_session_cookies_) && store_)
store_->UpdateCookieAccessTime(*cc);
}
@@ -1913,7 +1928,8 @@ void CookieMonster::InternalDeleteCookie(CookieMap::iterator it,
CanonicalCookie* cc = it->second;
VLOG(kVlogSetCookies) << "InternalDeleteCookie() cc: " << cc->DebugString();
- if (cc->IsPersistent() && store_ && sync_to_store)
+ if ((cc->IsPersistent() || persist_session_cookies_)
+ && store_ && sync_to_store)
store_->DeleteCookie(*cc);
if (delegate_.get()) {
ChangeCausePair mapping = ChangeCauseMapping[deletion_cause];
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698