Skip to content

Commit

Permalink
Promote SetForceKeepSessionState from CookieMonster to CookieStore
Browse files Browse the repository at this point in the history
Calling it on other CookieStore implementations does nothing,
but this removes the need for GetCookieMonster.

BUG=579653

Review URL: https://codereview.chromium.org/1670653002

Cr-Commit-Position: refs/heads/master@{#374019}
  • Loading branch information
mmenke authored and Commit bot committed Feb 6, 2016
1 parent 7c948e2 commit ded79da
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 1 addition & 3 deletions content/browser/browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -78,8 +77,7 @@ void SaveSessionStateOnIOThread(
const scoped_refptr<net::URLRequestContextGetter>& 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();
Expand Down
11 changes: 5 additions & 6 deletions net/cookies/cookie_monster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<SetAllCookiesTask> task =
Expand Down Expand Up @@ -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_);
Expand Down
4 changes: 1 addition & 3 deletions net/cookies/cookie_monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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).
Expand Down
4 changes: 4 additions & 0 deletions net/cookies/cookie_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions net/cookies/cookie_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> {
// 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;

Expand Down

0 comments on commit ded79da

Please sign in to comment.