diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc index 32681ae71dba4e..81c554b3025e3d 100644 --- a/content/browser/browser_context.cc +++ b/content/browser/browser_context.cc @@ -22,7 +22,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/site_instance.h" -#include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_store.h" #include "net/ssl/channel_id_service.h" #include "net/ssl/channel_id_store.h" @@ -78,8 +77,7 @@ void SaveSessionStateOnIOThread( const scoped_refptr& context_getter, AppCacheServiceImpl* appcache_service) { net::URLRequestContext* context = context_getter->GetURLRequestContext(); - context->cookie_store()->GetCookieMonster()-> - SetForceKeepSessionState(); + context->cookie_store()->SetForceKeepSessionState(); context->channel_id_service()->GetChannelIDStore()-> SetForceKeepSessionState(); appcache_service->set_force_keep_session_state(); diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc index fe5f13faa77ce1..9874610438e49d 100644 --- a/net/cookies/cookie_monster.cc +++ b/net/cookies/cookie_monster.cc @@ -934,6 +934,11 @@ void CookieMonster::FlushStore(const base::Closure& callback) { base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); } +void CookieMonster::SetForceKeepSessionState() { + if (store_) + store_->SetForceKeepSessionState(); +} + void CookieMonster::SetAllCookiesAsync(const CookieList& list, const SetCookiesCallback& callback) { scoped_refptr task = @@ -1047,12 +1052,6 @@ void CookieMonster::SetKeepExpiredCookies() { keep_expired_cookies_ = true; } -void CookieMonster::SetForceKeepSessionState() { - if (store_.get()) { - store_->SetForceKeepSessionState(); - } -} - // This function must be called before the CookieMonster is used. void CookieMonster::SetPersistSessionCookies(bool persist_session_cookies) { DCHECK(!initialized_); diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h index c29b3696de8d06..dd2b6eb87e52bb 100644 --- a/net/cookies/cookie_monster.h +++ b/net/cookies/cookie_monster.h @@ -200,6 +200,7 @@ class NET_EXPORT CookieMonster : public CookieStore { const DeleteCallback& callback) override; void DeleteSessionCookiesAsync(const DeleteCallback&) override; void FlushStore(const base::Closure& callback) override; + void SetForceKeepSessionState() override; CookieMonster* GetCookieMonster() override; @@ -213,9 +214,6 @@ class NET_EXPORT CookieMonster : public CookieStore { // arbitrary cookies. void SetKeepExpiredCookies(); - // Protects session cookies from deletion on shutdown. - void SetForceKeepSessionState(); - // Enables writing session cookies into the cookie database. If this this // method is called, it must be called before first use of the instance // (i.e. as part of the instance initialization process). diff --git a/net/cookies/cookie_store.cc b/net/cookies/cookie_store.cc index bf7b2902b869f8..64338e6c689085 100644 --- a/net/cookies/cookie_store.cc +++ b/net/cookies/cookie_store.cc @@ -16,4 +16,8 @@ void CookieStore::DeleteAllAsync(const DeleteCallback& callback) { DeleteAllCreatedBetweenAsync(base::Time(), base::Time::Max(), callback); } +void CookieStore::SetForceKeepSessionState() { + // By default, do nothing. +} + } // namespace net diff --git a/net/cookies/cookie_store.h b/net/cookies/cookie_store.h index 26db1fea83f91c..c54148f372c89f 100644 --- a/net/cookies/cookie_store.h +++ b/net/cookies/cookie_store.h @@ -155,6 +155,11 @@ class NET_EXPORT CookieStore : public base::RefCountedThreadSafe { // https://crbug.com/46185 virtual void FlushStore(const base::Closure& callback) = 0; + // Protects session cookies from deletion on shutdown, if the underlying + // CookieStore implemention is currently configured to store them to disk. + // Otherwise, does nothing. + virtual void SetForceKeepSessionState(); + // Returns the underlying CookieMonster. virtual CookieMonster* GetCookieMonster() = 0;