summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 08:31:43 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 08:31:43 +0000
commitbf510ed89ae0469951d8a9d39ca40e6c171db663 (patch)
tree781235082dd354a4731d32ac9322aff8ff30c73f
parent52d213e0e78f33a43364913c1328cac0bac42299 (diff)
downloadchromium_src-bf510ed89ae0469951d8a9d39ca40e6c171db663.zip
chromium_src-bf510ed89ae0469951d8a9d39ca40e6c171db663.tar.gz
chromium_src-bf510ed89ae0469951d8a9d39ca40e6c171db663.tar.bz2
Unwire the clear on exit preference from the storage systems.
The "session only" rules should cover the functionality now UI changes and migration code will follow BUG=129349 TEST=added unit tests for the chrome/browser/net/sqlite* classes Review URL: https://chromiumcodereview.appspot.com/10447117 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140502 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_content_browser_client.cc6
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc23
-rw-r--r--chrome/browser/net/chrome_url_request_context.h1
-rw-r--r--chrome/browser/net/sqlite_persistent_cookie_store.cc25
-rw-r--r--chrome/browser/net/sqlite_persistent_cookie_store.h2
-rw-r--r--chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc43
-rw-r--r--chrome/browser/net/sqlite_server_bound_cert_store.cc25
-rw-r--r--chrome/browser/net/sqlite_server_bound_cert_store.h2
-rw-r--r--chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc64
-rw-r--r--chrome/browser/profiles/profile_impl.cc25
-rw-r--r--chrome/browser/profiles/profile_impl.h1
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.cc14
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.h1
-rw-r--r--chrome/browser/profiles/profile_io_data.cc6
-rw-r--r--chrome/browser/profiles/profile_io_data.h6
-rwxr-xr-xchrome/test/functional/cookies.py25
-rw-r--r--content/browser/appcache/chrome_appcache_service_unittest.cc44
-rw-r--r--content/browser/browser_context.cc33
-rw-r--r--content/browser/dom_storage/dom_storage_context_impl.cc13
-rw-r--r--content/browser/dom_storage/dom_storage_context_impl.h3
-rw-r--r--content/browser/in_process_webkit/indexed_db_context_impl.cc23
-rw-r--r--content/browser/in_process_webkit/indexed_db_context_impl.h15
-rw-r--r--content/browser/in_process_webkit/indexed_db_unittest.cc56
-rw-r--r--content/public/browser/browser_context.h3
-rw-r--r--net/base/default_server_bound_cert_store.cc7
-rw-r--r--net/base/default_server_bound_cert_store.h7
-rw-r--r--net/base/default_server_bound_cert_store_unittest.cc4
-rw-r--r--net/base/server_bound_cert_store.h4
-rw-r--r--net/cookies/cookie_monster.cc9
-rw-r--r--net/cookies/cookie_monster.h13
-rw-r--r--net/cookies/cookie_monster_store_test.cc7
-rw-r--r--net/cookies/cookie_monster_store_test.h5
-rw-r--r--net/cookies/cookie_monster_unittest.cc4
-rw-r--r--webkit/appcache/appcache_service.cc4
-rw-r--r--webkit/appcache/appcache_service.h16
-rw-r--r--webkit/appcache/appcache_storage_impl.cc20
-rw-r--r--webkit/database/database_tracker.cc41
-rw-r--r--webkit/database/database_tracker.h16
-rw-r--r--webkit/database/database_tracker_unittest.cc115
-rw-r--r--webkit/dom_storage/dom_storage_context.cc17
-rw-r--r--webkit/dom_storage/dom_storage_context.h12
-rw-r--r--webkit/dom_storage/dom_storage_context_unittest.cc24
42 files changed, 182 insertions, 602 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 1ff3506..1d2cd1d 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -914,8 +914,12 @@ bool ChromeContentBrowserClient::AllowSaveLocalState(
content::ResourceContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
+ CookieSettings* cookie_settings = io_data->GetCookieSettings();
+ ContentSetting setting = cookie_settings->GetDefaultCookieSetting(NULL);
- return !io_data->clear_local_state_on_exit()->GetValue();
+ // TODO(bauerb): Should we also disallow local state if the default is BLOCK?
+ // Could we even support per-origin settings?
+ return setting != CONTENT_SETTING_SESSION_ONLY;
}
bool ChromeContentBrowserClient::AllowWorkerDatabase(
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 11a4d9d..7f8d2ca 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -262,15 +262,6 @@ void ChromeURLRequestContextGetter::Observe(
&ChromeURLRequestContextGetter::OnDefaultCharsetChange,
this,
default_charset));
- } else if (*pref_name_in == prefs::kClearSiteDataOnExit) {
- bool clear_site_data =
- prefs->GetBoolean(prefs::kClearSiteDataOnExit);
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(
- &ChromeURLRequestContextGetter::OnClearSiteDataOnExitChange,
- this,
- clear_site_data));
}
} else {
NOTREACHED();
@@ -283,7 +274,6 @@ void ChromeURLRequestContextGetter::RegisterPrefsObserver(Profile* profile) {
registrar_.Init(profile->GetPrefs());
registrar_.Add(prefs::kAcceptLanguages, this);
registrar_.Add(prefs::kDefaultCharset, this);
- registrar_.Add(prefs::kClearSiteDataOnExit, this);
}
void ChromeURLRequestContextGetter::OnAcceptLanguageChange(
@@ -296,19 +286,6 @@ void ChromeURLRequestContextGetter::OnDefaultCharsetChange(
GetIOContext()->OnDefaultCharsetChange(default_charset);
}
-void ChromeURLRequestContextGetter::OnClearSiteDataOnExitChange(
- bool clear_site_data) {
- net::CookieMonster* cookie_monster =
- GetURLRequestContext()->cookie_store()->GetCookieMonster();
-
- // If there is no cookie monster, this function does nothing. If
- // clear_site_data is true, this is most certainly not the expected behavior.
- DCHECK(!clear_site_data || cookie_monster);
-
- if (cookie_monster)
- cookie_monster->SetClearPersistentStoreOnExit(clear_site_data);
-}
-
// ----------------------------------------------------------------------------
// ChromeURLRequestContext
// ----------------------------------------------------------------------------
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index 31a41d3..acf13d2 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -173,7 +173,6 @@ class ChromeURLRequestContextGetter : public net::URLRequestContextGetter,
// ChromeURLRequestContext.
void OnAcceptLanguageChange(const std::string& accept_language);
void OnDefaultCharsetChange(const std::string& default_charset);
- void OnClearSiteDataOnExitChange(bool clear_site_data);
PrefChangeRegistrar registrar_;
diff --git a/chrome/browser/net/sqlite_persistent_cookie_store.cc b/chrome/browser/net/sqlite_persistent_cookie_store.cc
index 57dbd5b..33ddb35 100644
--- a/chrome/browser/net/sqlite_persistent_cookie_store.cc
+++ b/chrome/browser/net/sqlite_persistent_cookie_store.cc
@@ -66,7 +66,7 @@ class SQLitePersistentCookieStore::Backend
: path_(path),
db_(NULL),
num_pending_(0),
- clear_local_state_on_exit_(false),
+ force_keep_session_state_(false),
initialized_(false),
restore_old_session_cookies_(restore_old_session_cookies),
clear_on_exit_policy_(clear_on_exit_policy),
@@ -98,7 +98,7 @@ class SQLitePersistentCookieStore::Backend
// before the object is destructed.
void Close();
- void SetClearLocalStateOnExit(bool clear_local_state);
+ void SetForceKeepSessionState();
private:
friend class base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend>;
@@ -196,9 +196,9 @@ class SQLitePersistentCookieStore::Backend
typedef std::list<PendingOperation*> PendingOperationsList;
PendingOperationsList pending_;
PendingOperationsList::size_type num_pending_;
- // True if the persistent store should be deleted upon destruction.
- bool clear_local_state_on_exit_;
- // Guard |cookies_|, |pending_|, |num_pending_|, |clear_local_state_on_exit_|
+ // True if the persistent store should skip delete on exit rules.
+ bool force_keep_session_state_;
+ // Guard |cookies_|, |pending_|, |num_pending_|, |force_keep_session_state_|
base::Lock lock_;
// Temporary buffer for cookies loaded from DB. Accumulates cookies to reduce
@@ -921,15 +921,12 @@ void SQLitePersistentCookieStore::Backend::InternalBackgroundClose() {
// Commit any pending operations
Commit();
- if (!clear_local_state_on_exit_ && clear_on_exit_policy_.get() &&
+ if (!force_keep_session_state_ && clear_on_exit_policy_.get() &&
clear_on_exit_policy_->HasClearOnExitOrigins()) {
DeleteSessionCookiesOnShutdown();
}
db_.reset();
-
- if (clear_local_state_on_exit_)
- file_util::Delete(path_, false);
}
void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnShutdown() {
@@ -973,10 +970,9 @@ void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnShutdown() {
LOG(WARNING) << "Unable to delete cookies on shutdown.";
}
-void SQLitePersistentCookieStore::Backend::SetClearLocalStateOnExit(
- bool clear_local_state) {
+void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() {
base::AutoLock locked(lock_);
- clear_local_state_on_exit_ = clear_local_state;
+ force_keep_session_state_ = true;
}
void SQLitePersistentCookieStore::Backend::DeleteSessionCookiesOnStartup() {
@@ -1021,10 +1017,9 @@ void SQLitePersistentCookieStore::DeleteCookie(
backend_->DeleteCookie(cc);
}
-void SQLitePersistentCookieStore::SetClearLocalStateOnExit(
- bool clear_local_state) {
+void SQLitePersistentCookieStore::SetForceKeepSessionState() {
if (backend_.get())
- backend_->SetClearLocalStateOnExit(clear_local_state);
+ backend_->SetForceKeepSessionState();
}
void SQLitePersistentCookieStore::Flush(const base::Closure& callback) {
diff --git a/chrome/browser/net/sqlite_persistent_cookie_store.h b/chrome/browser/net/sqlite_persistent_cookie_store.h
index 235bcf0..6b1e595 100644
--- a/chrome/browser/net/sqlite_persistent_cookie_store.h
+++ b/chrome/browser/net/sqlite_persistent_cookie_store.h
@@ -45,7 +45,7 @@ class SQLitePersistentCookieStore
const net::CookieMonster::CanonicalCookie& cc) OVERRIDE;
virtual void DeleteCookie(
const net::CookieMonster::CanonicalCookie& cc) OVERRIDE;
- virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE;
+ virtual void SetForceKeepSessionState() OVERRIDE;
virtual void Flush(const base::Closure& callback) OVERRIDE;
protected:
diff --git a/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc b/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc
index 222af90..5f5402b 100644
--- a/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc
+++ b/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc
@@ -118,30 +118,6 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
scoped_refptr<SQLitePersistentCookieStore> store_;
};
-TEST_F(SQLitePersistentCookieStoreTest, KeepOnDestruction) {
- InitializeStore(false);
- // Put some data - any data - on disk, to have something to keep.
- AddCookie("A", "B", "foo.bar", "/", base::Time::Now());
- store_->SetClearLocalStateOnExit(false);
- DestroyStore();
-
- ASSERT_TRUE(file_util::PathExists(
- temp_dir_.path().Append(chrome::kCookieFilename)));
- ASSERT_TRUE(file_util::Delete(
- temp_dir_.path().Append(chrome::kCookieFilename), false));
-}
-
-TEST_F(SQLitePersistentCookieStoreTest, RemoveOnDestruction) {
- InitializeStore(false);
- // Put some data - any data - on disk, to have something to remove.
- AddCookie("A", "B", "foo.bar", "/", base::Time::Now());
- store_->SetClearLocalStateOnExit(true);
- DestroyStore();
-
- ASSERT_FALSE(file_util::PathExists(
- temp_dir_.path().Append(chrome::kCookieFilename)));
-}
-
TEST_F(SQLitePersistentCookieStoreTest, TestInvalidMetaTableRecovery) {
InitializeStore(false);
AddCookie("A", "B", "foo.bar", "/", base::Time::Now());
@@ -516,6 +492,9 @@ TEST_F(SQLitePersistentCookieStoreTest, TestClearOnExitPolicy) {
t, t, t,
true, false, true, true));
+ // First, check that we can override the policy.
+ store_->SetForceKeepSessionState();
+
// Force the store to write its data to the disk.
DestroyStore();
@@ -526,6 +505,22 @@ TEST_F(SQLitePersistentCookieStoreTest, TestClearOnExitPolicy) {
clear_policy.get());
Load(&cookies);
+ EXPECT_EQ(4U, cookies.size());
+ EXPECT_TRUE(IsCookiePresent(&cookies, protected_origin, "A", "1", false));
+ EXPECT_TRUE(IsCookiePresent(&cookies, session_origin, "B", "2", false));
+ EXPECT_TRUE(IsCookiePresent(&cookies, other_origin, "C", "3", false));
+ EXPECT_TRUE(IsCookiePresent(&cookies, session_origin, "D", "4", true));
+
+ // This time, the clear on exit policy should be in effect.
+ DestroyStore();
+
+ // Create a store test that the cookie on session_origin does not exist.
+ store_ = new SQLitePersistentCookieStore(
+ temp_dir_.path().Append(chrome::kCookieFilename),
+ false,
+ clear_policy.get());
+ Load(&cookies);
+
EXPECT_EQ(3U, cookies.size());
EXPECT_TRUE(IsCookiePresent(&cookies, protected_origin, "A", "1", false));
EXPECT_TRUE(IsCookiePresent(&cookies, other_origin, "C", "3", false));
diff --git a/chrome/browser/net/sqlite_server_bound_cert_store.cc b/chrome/browser/net/sqlite_server_bound_cert_store.cc
index acf8ba9..0a297ee 100644
--- a/chrome/browser/net/sqlite_server_bound_cert_store.cc
+++ b/chrome/browser/net/sqlite_server_bound_cert_store.cc
@@ -36,7 +36,7 @@ class SQLiteServerBoundCertStore::Backend
: path_(path),
db_(NULL),
num_pending_(0),
- clear_local_state_on_exit_(false),
+ force_keep_session_state_(false),
clear_on_exit_policy_(clear_on_exit_policy) {
}
@@ -59,7 +59,7 @@ class SQLiteServerBoundCertStore::Backend
// before the object is destructed.
void Close();
- void SetClearLocalStateOnExit(bool clear_local_state);
+ void SetForceKeepSessionState();
private:
friend class base::RefCountedThreadSafe<SQLiteServerBoundCertStore::Backend>;
@@ -114,9 +114,9 @@ class SQLiteServerBoundCertStore::Backend
typedef std::list<PendingOperation*> PendingOperationsList;
PendingOperationsList pending_;
PendingOperationsList::size_type num_pending_;
- // True if the persistent store should be deleted upon destruction.
- bool clear_local_state_on_exit_;
- // Guard |pending_|, |num_pending_| and |clear_local_state_on_exit_|.
+ // True if the persistent store should skip clear on exit rules.
+ bool force_keep_session_state_;
+ // Guard |pending_|, |num_pending_| and |force_keep_session_state_|.
base::Lock lock_;
// Cache of origins we have certificates stored for.
@@ -476,15 +476,12 @@ void SQLiteServerBoundCertStore::Backend::InternalBackgroundClose() {
// Commit any pending operations
Commit();
- if (!clear_local_state_on_exit_ && clear_on_exit_policy_.get() &&
+ if (!force_keep_session_state_ && clear_on_exit_policy_.get() &&
clear_on_exit_policy_->HasClearOnExitOrigins()) {
DeleteCertificatesOnShutdown();
}
db_.reset();
-
- if (clear_local_state_on_exit_)
- file_util::Delete(path_, false);
}
void SQLiteServerBoundCertStore::Backend::DeleteCertificatesOnShutdown() {
@@ -523,10 +520,9 @@ void SQLiteServerBoundCertStore::Backend::DeleteCertificatesOnShutdown() {
LOG(WARNING) << "Unable to delete certificates on shutdown.";
}
-void SQLiteServerBoundCertStore::Backend::SetClearLocalStateOnExit(
- bool clear_local_state) {
+void SQLiteServerBoundCertStore::Backend::SetForceKeepSessionState() {
base::AutoLock locked(lock_);
- clear_local_state_on_exit_ = clear_local_state;
+ force_keep_session_state_ = true;
}
SQLiteServerBoundCertStore::SQLiteServerBoundCertStore(
@@ -552,10 +548,9 @@ void SQLiteServerBoundCertStore::DeleteServerBoundCert(
backend_->DeleteServerBoundCert(cert);
}
-void SQLiteServerBoundCertStore::SetClearLocalStateOnExit(
- bool clear_local_state) {
+void SQLiteServerBoundCertStore::SetForceKeepSessionState() {
if (backend_.get())
- backend_->SetClearLocalStateOnExit(clear_local_state);
+ backend_->SetForceKeepSessionState();
}
void SQLiteServerBoundCertStore::Flush(const base::Closure& completion_task) {
diff --git a/chrome/browser/net/sqlite_server_bound_cert_store.h b/chrome/browser/net/sqlite_server_bound_cert_store.h
index b911c2f..5e9d432 100644
--- a/chrome/browser/net/sqlite_server_bound_cert_store.h
+++ b/chrome/browser/net/sqlite_server_bound_cert_store.h
@@ -36,7 +36,7 @@ class SQLiteServerBoundCertStore
const net::DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE;
virtual void DeleteServerBoundCert(
const net::DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE;
- virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE;
+ virtual void SetForceKeepSessionState() OVERRIDE;
virtual void Flush(const base::Closure& completion_task) OVERRIDE;
protected:
diff --git a/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc b/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
index cea865f..29d35fb 100644
--- a/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
+++ b/chrome/browser/net/sqlite_server_bound_cert_store_unittest.cc
@@ -82,37 +82,6 @@ class SQLiteServerBoundCertStoreTest : public testing::Test {
scoped_refptr<SQLiteServerBoundCertStore> store_;
};
-TEST_F(SQLiteServerBoundCertStoreTest, KeepOnDestruction) {
- store_->SetClearLocalStateOnExit(false);
- store_ = NULL;
- // Make sure we wait until the destructor has run.
- scoped_refptr<base::ThreadTestHelper> helper(
- new base::ThreadTestHelper(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
- ASSERT_TRUE(helper->Run());
-
- ASSERT_TRUE(file_util::PathExists(
- temp_dir_.path().Append(chrome::kOBCertFilename)));
- ASSERT_TRUE(file_util::Delete(
- temp_dir_.path().Append(chrome::kOBCertFilename), false));
-}
-
-TEST_F(SQLiteServerBoundCertStoreTest, RemoveOnDestruction) {
- store_->SetClearLocalStateOnExit(true);
- // Replace the store effectively destroying the current one and forcing it
- // to write its data to disk. Then we can see if after loading it again it
- // is still there.
- store_ = NULL;
- // Make sure we wait until the destructor has run.
- scoped_refptr<base::ThreadTestHelper> helper(
- new base::ThreadTestHelper(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
- ASSERT_TRUE(helper->Run());
-
- ASSERT_FALSE(file_util::PathExists(
- temp_dir_.path().Append(chrome::kOBCertFilename)));
-}
-
// Test if data is stored as expected in the SQLite database.
TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) {
store_->AddServerBoundCert(
@@ -540,17 +509,9 @@ bool CertificateExistsInList(
// Tests the interaction with the clear on exit policy.
TEST_F(SQLiteServerBoundCertStoreTest, TestClearOnExitPolicy) {
- // First, delete a possibly existing store.
- store_->SetClearLocalStateOnExit(true);
- store_ = NULL;
- scoped_refptr<base::ThreadTestHelper> helper(
- new base::ThreadTestHelper(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
- ASSERT_TRUE(helper->Run());
-
// Create a new store with three certificates in it.
store_ = new SQLiteServerBoundCertStore(
- temp_dir_.path().Append(chrome::kOBCertFilename), NULL);
+ temp_dir_.path().AppendASCII("ClearOnExitDB"), NULL);
ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs;
ASSERT_TRUE(store_->Load(&certs.get()));
@@ -580,6 +541,9 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestClearOnExitPolicy) {
// Write out the certificates to disk.
store_ = NULL;
+ scoped_refptr<base::ThreadTestHelper> helper(
+ new base::ThreadTestHelper(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
ASSERT_TRUE(helper->Run());
// Load the store again with a clear on exit policy.
@@ -591,17 +555,31 @@ TEST_F(SQLiteServerBoundCertStoreTest, TestClearOnExitPolicy) {
storage_policy->AddSessionOnly(GURL("https://protected.com"));
storage_policy->AddProtected(GURL("https://protected.com"));
store_ = new SQLiteServerBoundCertStore(
- temp_dir_.path().Append(chrome::kOBCertFilename), clear_policy.get());
+ temp_dir_.path().AppendASCII("ClearOnExitDB"), clear_policy.get());
+ ASSERT_TRUE(store_->Load(&certs.get()));
+ ASSERT_EQ(3U, certs.size());
+
+ // We've put a exit policy in place, but force the state to be saved.
+ store_->SetForceKeepSessionState();
+ store_ = NULL;
+ ASSERT_TRUE(helper->Run());
+
+ // Reload the store and check that the certs are still there.
+ store_ = new SQLiteServerBoundCertStore(
+ temp_dir_.path().AppendASCII("ClearOnExitDB"), clear_policy.get());
+
+ // Reload and test for persistence
+ certs.reset();
ASSERT_TRUE(store_->Load(&certs.get()));
ASSERT_EQ(3U, certs.size());
- // Delete the store. This should apply the clear on exit policy.
+ // Delete the store. This time, the exit policy should be in place.
store_ = NULL;
// Make sure we wait until the destructor has run.
ASSERT_TRUE(helper->Run());
store_ = new SQLiteServerBoundCertStore(
- temp_dir_.path().Append(chrome::kOBCertFilename), clear_policy.get());
+ temp_dir_.path().AppendASCII("ClearOnExitDB"), clear_policy.get());
// Reload and test for persistence
certs.reset();
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 0612b82..ba2e92d 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -205,9 +205,6 @@ void ProfileImpl::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kSavingBrowserHistoryDisabled,
false,
PrefService::UNSYNCABLE_PREF);
- prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit,
- false,
- PrefService::SYNCABLE_PREF);
prefs->RegisterBooleanPref(prefs::kProfileShortcutCreated,
false,
PrefService::UNSYNCABLE_PREF);
@@ -220,6 +217,11 @@ void ProfileImpl::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kRestoreSessionStateDialogShown,
false,
PrefService::SYNCABLE_PREF);
+
+ // Deprecated. Kept around for migration.
+ prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit,
+ false,
+ PrefService::SYNCABLE_PREF);
}
ProfileImpl::ProfileImpl(const FilePath& path,
@@ -232,7 +234,6 @@ ProfileImpl::ProfileImpl(const FilePath& path,
host_content_settings_map_(NULL),
history_service_created_(false),
favicon_service_created_(false),
- clear_local_state_on_exit_(false),
start_time_(Time::Now()),
delegate_(delegate),
predictor_(NULL),
@@ -290,7 +291,6 @@ void ProfileImpl::DoFinalInit(bool is_new_profile) {
PrefService* prefs = GetPrefs();
pref_change_registrar_.Init(prefs);
pref_change_registrar_.Add(prefs::kSpeechRecognitionFilterProfanities, this);
- pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this);
pref_change_registrar_.Add(prefs::kGoogleServicesUsername, this);
pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this);
pref_change_registrar_.Add(prefs::kProfileAvatarIndex, this);
@@ -339,15 +339,6 @@ void ProfileImpl::DoFinalInit(bool is_new_profile) {
InitRegisteredProtocolHandlers();
- clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit);
- if (clear_local_state_on_exit_) {
- content::RecordAction(
- UserMetricsAction("ClearSiteDataOnExitEnabled"));
- } else {
- content::RecordAction(
- UserMetricsAction("ClearSiteDataOnExitDisabled"));
- }
-
InstantController::RecordMetrics(this);
FilePath cookie_path = GetPath();
@@ -494,9 +485,6 @@ ProfileImpl::~ProfileImpl() {
content::NotificationService::NoDetails());
bool prefs_loaded = prefs_->GetInitializationStatus() !=
PrefService::INITIALIZATION_STATUS_WAITING;
- // Honor the "clear local state" setting.
- if (clear_local_state_on_exit_)
- BrowserContext::ClearLocalOnDestruction(this);
#if defined(ENABLE_SESSION_SERVICE)
StopCreateSessionServiceTimer();
@@ -929,9 +917,6 @@ void ProfileImpl::Observe(int type,
speech_prefs->SetFilterProfanities(prefs->GetBoolean(
prefs::kSpeechRecognitionFilterProfanities));
}
- } else if (*pref_name_in == prefs::kClearSiteDataOnExit) {
- clear_local_state_on_exit_ =
- prefs->GetBoolean(prefs::kClearSiteDataOnExit);
} else if (*pref_name_in == prefs::kGoogleServicesUsername) {
UpdateProfileUserNameCache();
} else if (*pref_name_in == prefs::kProfileAvatarIndex) {
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index fc48a09..e84c561 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -230,7 +230,6 @@ class ProfileImpl : public Profile,
scoped_refptr<history::ShortcutsBackend> shortcuts_backend_;
bool history_service_created_;
bool favicon_service_created_;
- bool clear_local_state_on_exit_;
// Whether or not the last session exited cleanly. This is set only once.
bool last_session_exited_cleanly_;
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index a3af32e..f3f3c15 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -229,9 +229,6 @@ void ProfileImplIOData::Handle::LazyInitialize() const {
new chrome_browser_net::HttpServerPropertiesManager(pref_service));
ChromeNetworkDelegate::InitializeReferrersEnabled(
io_data_->enable_referrers(), pref_service);
- io_data_->clear_local_state_on_exit()->Init(
- prefs::kClearSiteDataOnExit, pref_service, NULL);
- io_data_->clear_local_state_on_exit()->MoveToThread(BrowserThread::IO);
io_data_->session_startup_pref()->Init(
prefs::kRestoreOnStartup, pref_service, NULL);
io_data_->session_startup_pref()->MoveToThread(BrowserThread::IO);
@@ -251,8 +248,7 @@ ProfileImplIOData::LazyParams::LazyParams()
ProfileImplIOData::LazyParams::~LazyParams() {}
ProfileImplIOData::ProfileImplIOData()
- : ProfileIOData(false),
- clear_local_state_on_exit_(false) {}
+ : ProfileIOData(false) {}
ProfileImplIOData::~ProfileImplIOData() {
DestroyResourceContext();
@@ -262,9 +258,6 @@ ProfileImplIOData::~ProfileImplIOData() {
void ProfileImplIOData::LazyInitializeInternal(
ProfileParams* profile_params) const {
- // Keep track of clear_local_state_on_exit for isolated apps.
- clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit;
-
ChromeURLRequestContext* main_context = main_request_context();
ChromeURLRequestContext* extensions_context = extensions_request_context();
media_request_context_.reset(new ChromeURLRequestContext);
@@ -353,8 +346,6 @@ void ProfileImplIOData::LazyInitializeInternal(
lazy_params_->cookie_path,
lazy_params_->restore_old_session_cookies,
new ClearOnExitPolicy(lazy_params_->special_storage_policy));
- cookie_db->SetClearLocalStateOnExit(
- profile_params->clear_local_state_on_exit);
cookie_store =
new net::CookieMonster(cookie_db.get(),
profile_params->cookie_monster_delegate);
@@ -384,8 +375,6 @@ void ProfileImplIOData::LazyInitializeInternal(
new SQLiteServerBoundCertStore(
lazy_params_->server_bound_cert_path,
new ClearOnExitPolicy(lazy_params_->special_storage_policy));
- server_bound_cert_db->SetClearLocalStateOnExit(
- profile_params->clear_local_state_on_exit);
server_bound_cert_service = new net::ServerBoundCertService(
new net::DefaultServerBoundCertStore(server_bound_cert_db.get()),
base::WorkerPool::GetTaskRunner(true));
@@ -511,7 +500,6 @@ ProfileImplIOData::InitializeAppRequestContext(
scoped_refptr<SQLitePersistentCookieStore> cookie_db =
new SQLitePersistentCookieStore(cookie_path, false, NULL);
- cookie_db->SetClearLocalStateOnExit(clear_local_state_on_exit_);
// TODO(creis): We should have a cookie delegate for notifying the cookie
// extensions API, but we need to update it to understand isolated apps
// first.
diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h
index c7b4d1e..d2ccbec 100644
--- a/chrome/browser/profiles/profile_impl_io_data.h
+++ b/chrome/browser/profiles/profile_impl_io_data.h
@@ -157,7 +157,6 @@ class ProfileImplIOData : public ProfileIOData {
// Parameters needed for isolated apps.
FilePath app_path_;
- mutable bool clear_local_state_on_exit_;
DISALLOW_COPY_AND_ASSIGN(ProfileImplIOData);
};
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index 8b513bb..6881c22 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -164,8 +164,6 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
scoped_ptr<ProfileParams> params(new ProfileParams);
params->path = profile->GetPath();
- params->clear_local_state_on_exit =
- pref_service->GetBoolean(prefs::kClearSiteDataOnExit);
// Set up Accept-Language and Accept-Charset header values
params->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader(
@@ -249,8 +247,7 @@ void ProfileIOData::AppRequestContext::SetHttpTransactionFactory(
ProfileIOData::AppRequestContext::~AppRequestContext() {}
ProfileIOData::ProfileParams::ProfileParams()
- : clear_local_state_on_exit(false),
- io_thread(NULL),
+ : io_thread(NULL),
#if defined(ENABLE_NOTIFICATIONS)
notification_service(NULL),
#endif
@@ -574,7 +571,6 @@ void ProfileIOData::ShutdownOnUIThread() {
#if !defined(OS_CHROMEOS)
enable_metrics_.Destroy();
#endif
- clear_local_state_on_exit_.Destroy();
safe_browsing_enabled_.Destroy();
session_startup_pref_.Destroy();
#if defined(ENABLE_CONFIGURATION_POLICY)
diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h
index f4702bb..64631c5 100644
--- a/chrome/browser/profiles/profile_io_data.h
+++ b/chrome/browser/profiles/profile_io_data.h
@@ -91,10 +91,6 @@ class ProfileIOData {
DesktopNotificationService* GetNotificationService() const;
#endif
- BooleanPrefMember* clear_local_state_on_exit() const {
- return &clear_local_state_on_exit_;
- }
-
IntegerPrefMember* session_startup_pref() const {
return &session_startup_pref_;
}
@@ -149,7 +145,6 @@ class ProfileIOData {
~ProfileParams();
FilePath path;
- bool clear_local_state_on_exit;
std::string accept_language;
std::string accept_charset;
std::string referrer_charset;
@@ -302,7 +297,6 @@ class ProfileIOData {
// Member variables which are pointed to by the various context objects.
mutable BooleanPrefMember enable_referrers_;
- mutable BooleanPrefMember clear_local_state_on_exit_;
mutable BooleanPrefMember safe_browsing_enabled_;
// TODO(marja): Remove session_startup_pref_ if no longer needed.
mutable IntegerPrefMember session_startup_pref_;
diff --git a/chrome/test/functional/cookies.py b/chrome/test/functional/cookies.py
index 55498ad..666adb2 100755
--- a/chrome/test/functional/cookies.py
+++ b/chrome/test/functional/cookies.py
@@ -143,31 +143,6 @@ class CookiesTest(pyauto.PyUITest):
self.assertFalse(self.GetCookie(pyauto.GURL(https_url)),
msg='Cookies are not blocked.')
- def testClearCookiesOnEndingSession(self):
- """Verify that cookies are cleared when the browsing session is closed."""
-
- # This test fails on ChromeOS because kRestoreOnStartup is ignored and
- # the startup preference is always "continue where I left off."
- if self.IsChromeOS():
- logging.info('Skipping testClearCookiesOnEndingSession on ChromeOS')
- return
-
- file_url = self.GetFileURLForDataPath('setcookie.html')
- self.assertFalse(self.GetCookie(pyauto.GURL(file_url)),
- msg='There should be no cookies on %s' % file_url)
-
- # Set the option to clear cookies when the browser session is closed.
- self.SetPrefs(pyauto.kClearSiteDataOnExit, True)
-
- self.NavigateToURL(file_url)
- self.assertEqual('name=Good', self.GetCookie(pyauto.GURL(file_url)),
- msg='Unable to retrieve the cookie name=Good')
-
- # Restart and verify that cookie does not persist
- self.RestartBrowser(clear_profile=False)
- self.assertFalse(self.GetCookie(pyauto.GURL(file_url)),
- msg='Cookie persisted after restarting session.')
-
def testAllowCookiesUsingExceptions(self):
"""Verify that cookies can be allowed and set using exceptions for
particular website(s) when all others are blocked."""
diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc
index bbf7d76..f9f50d1 100644
--- a/content/browser/appcache/chrome_appcache_service_unittest.cc
+++ b/content/browser/appcache/chrome_appcache_service_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -126,7 +126,6 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
InsertDataIntoAppCache(appcache_service);
// Test: delete the ChromeAppCacheService
- appcache_service->set_clear_local_state_on_exit(false);
appcache_service = NULL;
message_loop_.RunAllPending();
@@ -151,44 +150,6 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
message_loop_.RunAllPending();
}
-TEST_F(ChromeAppCacheServiceTest, RemoveOnDestruction) {
- ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- FilePath appcache_path = temp_dir_.path().Append(kTestingAppCacheDirname);
-
- // Create a ChromeAppCacheService and insert data into it
- scoped_refptr<ChromeAppCacheService> appcache_service =
- CreateAppCacheService(appcache_path, true);
- ASSERT_TRUE(file_util::PathExists(appcache_path));
- ASSERT_TRUE(file_util::PathExists(appcache_path.AppendASCII("Index")));
- InsertDataIntoAppCache(appcache_service);
-
- // Test: delete the ChromeAppCacheService
- appcache_service->set_clear_local_state_on_exit(true);
- appcache_service = NULL;
- message_loop_.RunAllPending();
-
- // Recreate the appcache (for reading the data back)
- appcache_service = CreateAppCacheService(appcache_path, false);
-
- // The directory is still there
- ASSERT_TRUE(file_util::PathExists(appcache_path));
-
- // The appcache data for the protected origin is there, and the data for the
- // unprotected origin was deleted.
- AppCacheTestHelper appcache_helper;
- std::set<GURL> origins;
- appcache_helper.GetOriginsWithCaches(appcache_service, &origins);
- EXPECT_EQ(1UL, origins.size());
- EXPECT_TRUE(origins.find(kProtectedManifestURL.GetOrigin()) != origins.end());
- EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) == origins.end());
- EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) ==
- origins.end());
-
- // Delete and let cleanup tasks run prior to returning.
- appcache_service = NULL;
- message_loop_.RunAllPending();
-}
-
TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
FilePath appcache_path = temp_dir_.path().Append(kTestingAppCacheDirname);
@@ -200,9 +161,8 @@ TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
ASSERT_TRUE(file_util::PathExists(appcache_path.AppendASCII("Index")));
InsertDataIntoAppCache(appcache_service);
- appcache_service->set_clear_local_state_on_exit(true);
// Save session state. This should bypass the destruction-time deletion.
- appcache_service->set_save_session_state(true);
+ appcache_service->set_force_keep_session_state();
// Test: delete the ChromeAppCacheService
appcache_service = NULL;
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index aafbee8..5bda8e2 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -11,6 +11,8 @@
#include "content/browser/resource_context_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_constants.h"
+#include "net/base/server_bound_cert_service.h"
+#include "net/base/server_bound_cert_store.h"
#include "net/cookies/cookie_monster.h"
#include "net/cookies/cookie_store.h"
#include "net/url_request/url_request_context.h"
@@ -111,14 +113,16 @@ void CreateQuotaManagerAndClients(BrowserContext* context) {
void SaveSessionStateOnIOThread(ResourceContext* resource_context) {
resource_context->GetRequestContext()->cookie_store()->GetCookieMonster()->
- SaveSessionCookies();
- ResourceContext::GetAppCacheService(resource_context)->set_save_session_state(
- true);
+ SetForceKeepSessionState();
+ resource_context->GetRequestContext()->server_bound_cert_service()->
+ GetCertStore()->SetForceKeepSessionState();
+ ResourceContext::GetAppCacheService(resource_context)->
+ set_force_keep_session_state();
}
void SaveSessionStateOnWebkitThread(
scoped_refptr<IndexedDBContextImpl> indexed_db_context) {
- indexed_db_context->SaveSessionState();
+ indexed_db_context->SetForceKeepSessionState();
}
void PurgeMemoryOnIOThread(ResourceContext* resource_context) {
@@ -181,7 +185,7 @@ void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) {
}
void BrowserContext::SaveSessionState(BrowserContext* browser_context) {
- GetDatabaseTracker(browser_context)->SaveSessionState();
+ GetDatabaseTracker(browser_context)->SetForceKeepSessionState();
if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
BrowserThread::PostTask(
@@ -190,7 +194,7 @@ void BrowserContext::SaveSessionState(BrowserContext* browser_context) {
browser_context->GetResourceContext()));
}
- GetDOMStorageContextImpl(browser_context)->SaveSessionState();
+ GetDOMStorageContextImpl(browser_context)->SetForceKeepSessionState();
if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>(
@@ -202,23 +206,6 @@ void BrowserContext::SaveSessionState(BrowserContext* browser_context) {
}
}
-void BrowserContext::ClearLocalOnDestruction(BrowserContext* browser_context) {
- GetDOMStorageContextImpl(browser_context)->SetClearLocalState(true);
-
- IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>(
- GetIndexedDBContext(browser_context));
- indexed_db->set_clear_local_state_on_exit(true);
-
- GetDatabaseTracker(browser_context)->SetClearLocalStateOnExit(true);
-
- if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit,
- base::Unretained(GetAppCacheService(browser_context)), true));
- }
-}
-
void BrowserContext::PurgeMemory(BrowserContext* browser_context) {
if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
BrowserThread::PostTask(
diff --git a/content/browser/dom_storage/dom_storage_context_impl.cc b/content/browser/dom_storage/dom_storage_context_impl.cc
index a3ff933..a21f4f1 100644
--- a/content/browser/dom_storage/dom_storage_context_impl.cc
+++ b/content/browser/dom_storage/dom_storage_context_impl.cc
@@ -178,21 +178,12 @@ void DOMStorageContextImpl::PurgeMemory() {
base::Bind(&DomStorageContext::PurgeMemory, context_));
}
-void DOMStorageContextImpl::SetClearLocalState(bool clear_local_state) {
+void DOMStorageContextImpl::SetForceKeepSessionState() {
DCHECK(context_);
context_->task_runner()->PostShutdownBlockingTask(
FROM_HERE,
DomStorageTaskRunner::PRIMARY_SEQUENCE,
- base::Bind(&DomStorageContext::SetClearLocalState, context_,
- clear_local_state));
-}
-
-void DOMStorageContextImpl::SaveSessionState() {
- DCHECK(context_);
- context_->task_runner()->PostShutdownBlockingTask(
- FROM_HERE,
- DomStorageTaskRunner::PRIMARY_SEQUENCE,
- base::Bind(&DomStorageContext::SaveSessionState, context_));
+ base::Bind(&DomStorageContext::SetForceKeepSessionState, context_));
}
void DOMStorageContextImpl::Shutdown() {
diff --git a/content/browser/dom_storage/dom_storage_context_impl.h b/content/browser/dom_storage/dom_storage_context_impl.h
index 0ac72e7..46faa97 100644
--- a/content/browser/dom_storage/dom_storage_context_impl.h
+++ b/content/browser/dom_storage/dom_storage_context_impl.h
@@ -49,8 +49,7 @@ class CONTENT_EXPORT DOMStorageContextImpl :
// what data to keep and what data to discard at shutdown.
// The policy is not so straight forward to describe, see
// the implementation for details.
- void SetClearLocalState(bool clear_local_state);
- void SaveSessionState();
+ void SetForceKeepSessionState();
// Called when the BrowserContext/Profile is going away.
void Shutdown();
diff --git a/content/browser/in_process_webkit/indexed_db_context_impl.cc b/content/browser/in_process_webkit/indexed_db_context_impl.cc
index 2c1e338..c793767 100644
--- a/content/browser/in_process_webkit/indexed_db_context_impl.cc
+++ b/content/browser/in_process_webkit/indexed_db_context_impl.cc
@@ -61,11 +61,9 @@ void GetAllOriginsAndPaths(
}
}
-// If clear_all_databases is true, deletes all databases not protected by
-// special storage policy. Otherwise deletes session-only databases.
-void ClearLocalState(
+// Deletes session-only databases.
+void ClearSessionOnlyOrigins(
const FilePath& indexeddb_path,
- bool clear_all_databases,
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
std::vector<GURL> origins;
@@ -75,12 +73,9 @@ void ClearLocalState(
std::vector<FilePath>::const_iterator file_path_iter = file_paths.begin();
for (std::vector<GURL>::const_iterator iter = origins.begin();
iter != origins.end(); ++iter, ++file_path_iter) {
- if (!clear_all_databases &&
- !special_storage_policy->IsStorageSessionOnly(*iter)) {
+ if (!special_storage_policy->IsStorageSessionOnly(*iter))
continue;
- }
- if (special_storage_policy.get() &&
- special_storage_policy->IsStorageProtected(*iter))
+ if (special_storage_policy->IsStorageProtected(*iter))
continue;
file_util::Delete(*file_path_iter, true);
}
@@ -93,8 +88,7 @@ IndexedDBContextImpl::IndexedDBContextImpl(
quota::SpecialStoragePolicy* special_storage_policy,
quota::QuotaManagerProxy* quota_manager_proxy,
base::MessageLoopProxy* webkit_thread_loop)
- : clear_local_state_on_exit_(false),
- save_session_state_(false),
+ : force_keep_session_state_(false),
special_storage_policy_(special_storage_policy),
quota_manager_proxy_(quota_manager_proxy) {
if (!data_path.empty())
@@ -237,7 +231,7 @@ IndexedDBContextImpl::~IndexedDBContextImpl() {
if (data_path_.empty())
return;
- if (save_session_state_)
+ if (force_keep_session_state_)
return;
bool has_session_only_databases =
@@ -245,14 +239,15 @@ IndexedDBContextImpl::~IndexedDBContextImpl() {
special_storage_policy_->HasSessionOnlyOrigins();
// Clearning only session-only databases, and there are none.
- if (!clear_local_state_on_exit_ && !has_session_only_databases)
+ if (!has_session_only_databases)
return;
// No WEBKIT thread here means we are running in a unit test where no clean
// up is needed.
BrowserThread::PostTask(
BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
- base::Bind(&ClearLocalState, data_path_, clear_local_state_on_exit_,
+ base::Bind(&ClearSessionOnlyOrigins,
+ data_path_,
special_storage_policy_));
}
diff --git a/content/browser/in_process_webkit/indexed_db_context_impl.h b/content/browser/in_process_webkit/indexed_db_context_impl.h
index e0e4276..b00a095 100644
--- a/content/browser/in_process_webkit/indexed_db_context_impl.h
+++ b/content/browser/in_process_webkit/indexed_db_context_impl.h
@@ -50,13 +50,9 @@ class CONTENT_EXPORT IndexedDBContextImpl
// The indexed db file extension.
static const FilePath::CharType kIndexedDBExtension[];
- void set_clear_local_state_on_exit(bool clear_local_state) {
- clear_local_state_on_exit_ = clear_local_state;
- }
-
- // Disables the exit-time deletion for all data (also session-only data).
- void SaveSessionState() {
- save_session_state_ = true;
+ // Disables the exit-time deletion of session-only data.
+ void SetForceKeepSessionState() {
+ force_keep_session_state_ = true;
}
// IndexedDBContext implementation:
@@ -89,7 +85,7 @@ class CONTENT_EXPORT IndexedDBContextImpl
private:
FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearLocalState);
FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, ClearSessionOnlyDatabases);
- FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, SaveSessionState);
+ FRIEND_TEST_ALL_PREFIXES(IndexedDBTest, SetForceKeepSessionState);
friend class IndexedDBQuotaClientTest;
typedef std::map<GURL, int64> OriginToSizeMap;
@@ -121,9 +117,8 @@ class CONTENT_EXPORT IndexedDBContextImpl
scoped_ptr<WebKit::WebIDBFactory> idb_factory_;
FilePath data_path_;
- bool clear_local_state_on_exit_;
// If true, nothing (not even session-only data) should be deleted on exit.
- bool save_session_state_;
+ bool force_keep_session_state_;
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
scoped_ptr<std::set<GURL> > origin_set_;
diff --git a/content/browser/in_process_webkit/indexed_db_unittest.cc b/content/browser/in_process_webkit/indexed_db_unittest.cc
index 2a12595..3bc51c1 100644
--- a/content/browser/in_process_webkit/indexed_db_unittest.cc
+++ b/content/browser/in_process_webkit/indexed_db_unittest.cc
@@ -36,55 +36,6 @@ class IndexedDBTest : public testing::Test {
BrowserThreadImpl io_thread_;
};
-TEST_F(IndexedDBTest, ClearLocalState) {
- ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-
- FilePath protected_path;
- FilePath unprotected_path;
-
- // Create the scope which will ensure we run the destructor of the webkit
- // context which should trigger the clean up.
- {
- content::TestBrowserContext browser_context;
-
- // Test our assumptions about what is protected and what is not.
- const GURL kProtectedOrigin("https://foo/");
- const GURL kUnprotectedOrigin("http://foo/");
- scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
- new quota::MockSpecialStoragePolicy;
- special_storage_policy->AddProtected(kProtectedOrigin);
- browser_context.SetSpecialStoragePolicy(special_storage_policy);
- quota::SpecialStoragePolicy* policy =
- browser_context.GetSpecialStoragePolicy();
- ASSERT_TRUE(policy->IsStorageProtected(kProtectedOrigin));
- ASSERT_FALSE(policy->IsStorageProtected(kUnprotectedOrigin));
-
- // Create some indexedDB paths.
- // With the levelDB backend, these are directories.
- IndexedDBContextImpl* idb_context =
- static_cast<IndexedDBContextImpl*>(
- BrowserContext::GetIndexedDBContext(&browser_context));
- idb_context->set_data_path_for_testing(temp_dir.path());
- protected_path = idb_context->GetFilePathForTesting(
- DatabaseUtil::GetOriginIdentifier(kProtectedOrigin));
- unprotected_path = idb_context->GetFilePathForTesting(
- DatabaseUtil::GetOriginIdentifier(kUnprotectedOrigin));
- ASSERT_TRUE(file_util::CreateDirectory(protected_path));
- ASSERT_TRUE(file_util::CreateDirectory(unprotected_path));
-
- // Setup to clear all unprotected origins on exit.
- idb_context->set_clear_local_state_on_exit(true);
- message_loop_.RunAllPending();
- }
-
- // Make sure we wait until the destructor has run.
- message_loop_.RunAllPending();
-
- ASSERT_TRUE(file_util::DirectoryExists(protected_path));
- ASSERT_FALSE(file_util::DirectoryExists(unprotected_path));
-}
-
TEST_F(IndexedDBTest, ClearSessionOnlyDatabases) {
ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
@@ -128,7 +79,7 @@ TEST_F(IndexedDBTest, ClearSessionOnlyDatabases) {
EXPECT_FALSE(file_util::DirectoryExists(session_only_path));
}
-TEST_F(IndexedDBTest, SaveSessionState) {
+TEST_F(IndexedDBTest, SetForceKeepSessionState) {
ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
@@ -154,11 +105,10 @@ TEST_F(IndexedDBTest, SaveSessionState) {
// Override the storage policy with our own.
idb_context->special_storage_policy_ = special_storage_policy;
- idb_context->set_clear_local_state_on_exit(true);
idb_context->set_data_path_for_testing(temp_dir.path());
// Save session state. This should bypass the destruction-time deletion.
- idb_context->SaveSessionState();
+ idb_context->SetForceKeepSessionState();
normal_path = idb_context->GetFilePathForTesting(
DatabaseUtil::GetOriginIdentifier(kNormalOrigin));
@@ -172,7 +122,7 @@ TEST_F(IndexedDBTest, SaveSessionState) {
// Make sure we wait until the destructor has run.
message_loop_.RunAllPending();
- // No data was cleared because of SaveSessionState.
+ // No data was cleared because of SetForceKeepSessionState.
EXPECT_TRUE(file_util::DirectoryExists(normal_path));
EXPECT_TRUE(file_util::DirectoryExists(session_only_path));
}
diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h
index 7a4577e..7b0103b 100644
--- a/content/public/browser/browser_context.h
+++ b/content/public/browser/browser_context.h
@@ -68,9 +68,6 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
// across the next restart.
static void SaveSessionState(BrowserContext* browser_context);
- // Tells the HTML5 objects on this context to clear their data on destruction.
- static void ClearLocalOnDestruction(BrowserContext* browser_context);
-
// Tells the HTML5 objects on this context to purge any uneeded memory.
static void PurgeMemory(BrowserContext* browser_context);
diff --git a/net/base/default_server_bound_cert_store.cc b/net/base/default_server_bound_cert_store.cc
index 2f891ca..0eaf87d 100644
--- a/net/base/default_server_bound_cert_store.cc
+++ b/net/base/default_server_bound_cert_store.cc
@@ -118,6 +118,13 @@ int DefaultServerBoundCertStore::GetCertCount() {
return server_bound_certs_.size();
}
+void DefaultServerBoundCertStore::SetForceKeepSessionState() {
+ base::AutoLock autolock(lock_);
+ InitIfNecessary();
+
+ store_->SetForceKeepSessionState();
+}
+
DefaultServerBoundCertStore::~DefaultServerBoundCertStore() {
DeleteAllInMemory();
}
diff --git a/net/base/default_server_bound_cert_store.h b/net/base/default_server_bound_cert_store.h
index daec007..7783bf2 100644
--- a/net/base/default_server_bound_cert_store.h
+++ b/net/base/default_server_bound_cert_store.h
@@ -76,6 +76,7 @@ class NET_EXPORT DefaultServerBoundCertStore : public ServerBoundCertStore {
virtual void GetAllServerBoundCerts(
ServerBoundCertList* server_bound_certs) OVERRIDE;
virtual int GetCertCount() OVERRIDE;
+ virtual void SetForceKeepSessionState() OVERRIDE;
private:
static const size_t kMaxCerts;
@@ -139,9 +140,9 @@ class NET_EXPORT DefaultServerBoundCertStore::PersistentStore
virtual void DeleteServerBoundCert(const ServerBoundCert& cert) = 0;
- // Sets the value of the user preference whether the persistent storage
- // must be deleted upon destruction.
- virtual void SetClearLocalStateOnExit(bool clear_local_state) = 0;
+ // When invoked, instructs the store to keep session related data on
+ // destruction.
+ virtual void SetForceKeepSessionState() = 0;
// Flush the store and post the given Task when complete.
virtual void Flush(const base::Closure& completion_task) = 0;
diff --git a/net/base/default_server_bound_cert_store_unittest.cc b/net/base/default_server_bound_cert_store_unittest.cc
index 38053c9..6b9bda0 100644
--- a/net/base/default_server_bound_cert_store_unittest.cc
+++ b/net/base/default_server_bound_cert_store_unittest.cc
@@ -29,7 +29,7 @@ class MockPersistentStore
const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE;
virtual void DeleteServerBoundCert(
const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE;
- virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE;
+ virtual void SetForceKeepSessionState() OVERRIDE;
virtual void Flush(const base::Closure& completion_task) OVERRIDE;
protected:
@@ -66,7 +66,7 @@ void MockPersistentStore::DeleteServerBoundCert(
origin_certs_.erase(cert.server_identifier());
}
-void MockPersistentStore::SetClearLocalStateOnExit(bool clear_local_state) {}
+void MockPersistentStore::SetForceKeepSessionState() {}
void MockPersistentStore::Flush(const base::Closure& completion_task) {
NOTREACHED();
diff --git a/net/base/server_bound_cert_store.h b/net/base/server_bound_cert_store.h
index 32b178e..59d9550 100644
--- a/net/base/server_bound_cert_store.h
+++ b/net/base/server_bound_cert_store.h
@@ -112,6 +112,10 @@ class NET_EXPORT ServerBoundCertStore {
// Returns the number of certs in the store.
// Public only for unit testing.
virtual int GetCertCount() = 0;
+
+ // When invoked, instructs the store to keep session related data on
+ // destruction.
+ virtual void SetForceKeepSessionState() = 0;
};
} // namespace net
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
index 8f516ce..63cd002 100644
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -1373,11 +1373,6 @@ void CookieMonster::SetKeepExpiredCookies() {
keep_expired_cookies_ = true;
}
-void CookieMonster::SetClearPersistentStoreOnExit(bool clear_local_store) {
- if (store_)
- store_->SetClearLocalStateOnExit(clear_local_store);
-}
-
// static
void CookieMonster::EnableFileScheme() {
enable_file_scheme_ = true;
@@ -1513,9 +1508,9 @@ void CookieMonster::SetPersistSessionCookies(bool persist_session_cookies) {
persist_session_cookies_ = persist_session_cookies;
}
-void CookieMonster::SaveSessionCookies() {
+void CookieMonster::SetForceKeepSessionState() {
if (store_) {
- store_->SetClearLocalStateOnExit(false);
+ store_->SetForceKeepSessionState();
}
}
diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h
index 8eef2ba..e9529bd 100644
--- a/net/cookies/cookie_monster.h
+++ b/net/cookies/cookie_monster.h
@@ -192,9 +192,8 @@ class NET_EXPORT CookieMonster : public CookieStore {
// arbitrary cookies.
void SetKeepExpiredCookies();
- // Delegates the call to set the |clear_local_store_on_exit_| flag of the
- // PersistentStore if it exists.
- void SetClearPersistentStoreOnExit(bool clear_local_store);
+ // Protects session cookies from deletion on shutdown.
+ void SetForceKeepSessionState();
// There are some unknowns about how to correctly handle file:// cookies,
// and our implementation for this is not robust enough. This allows you
@@ -255,9 +254,6 @@ class NET_EXPORT CookieMonster : public CookieStore {
// (i.e. as part of the instance initialization process).
void SetPersistSessionCookies(bool persist_session_cookies);
- // Protects session cookies from deletion on shutdown.
- void SaveSessionCookies();
-
// Debugging method to perform various validation checks on the map.
// Currently just checking that there are no null CanonicalCookie pointers
// in the map.
@@ -952,9 +948,8 @@ class CookieMonster::PersistentCookieStore
virtual void UpdateCookieAccessTime(const CanonicalCookie& cc) = 0;
virtual void DeleteCookie(const CanonicalCookie& cc) = 0;
- // Sets the value of the user preference whether the persistent storage
- // must be deleted upon destruction.
- virtual void SetClearLocalStateOnExit(bool clear_local_state) = 0;
+ // Instructs the store to not discard session only cookies on shutdown.
+ virtual void SetForceKeepSessionState() = 0;
// Flushes the store and posts |callback| when complete.
virtual void Flush(const base::Closure& callback) = 0;
diff --git a/net/cookies/cookie_monster_store_test.cc b/net/cookies/cookie_monster_store_test.cc
index f347e8d..91f1b84 100644
--- a/net/cookies/cookie_monster_store_test.cc
+++ b/net/cookies/cookie_monster_store_test.cc
@@ -78,9 +78,7 @@ void MockPersistentCookieStore::Flush(const base::Closure& callback) {
MessageLoop::current()->PostTask(FROM_HERE, callback);
}
-// No files are created so nothing to clear either
-void
-MockPersistentCookieStore::SetClearLocalStateOnExit(bool clear_local_state) {
+void MockPersistentCookieStore::SetForceKeepSessionState() {
}
MockPersistentCookieStore::~MockPersistentCookieStore() {}
@@ -193,8 +191,7 @@ void MockSimplePersistentCookieStore::Flush(const base::Closure& callback) {
MessageLoop::current()->PostTask(FROM_HERE, callback);
}
-void MockSimplePersistentCookieStore::SetClearLocalStateOnExit(
- bool clear_local_state) {
+void MockSimplePersistentCookieStore::SetForceKeepSessionState() {
}
CookieMonster* CreateMonsterFromStoreForGC(
diff --git a/net/cookies/cookie_monster_store_test.h b/net/cookies/cookie_monster_store_test.h
index fd4218d..38d6976 100644
--- a/net/cookies/cookie_monster_store_test.h
+++ b/net/cookies/cookie_monster_store_test.h
@@ -98,8 +98,7 @@ class MockPersistentCookieStore
virtual void Flush(const base::Closure& callback) OVERRIDE;
- // No files are created so nothing to clear either
- virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE;
+ virtual void SetForceKeepSessionState() OVERRIDE;
protected:
virtual ~MockPersistentCookieStore();
@@ -178,7 +177,7 @@ class MockSimplePersistentCookieStore
virtual void Flush(const base::Closure& callback) OVERRIDE;
- virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE;
+ virtual void SetForceKeepSessionState() OVERRIDE;
protected:
virtual ~MockSimplePersistentCookieStore();
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc
index fc570b9..84183d7 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -43,8 +43,8 @@ class NewMockPersistentCookieStore
MOCK_METHOD1(UpdateCookieAccessTime,
void(const CookieMonster::CanonicalCookie& cc));
MOCK_METHOD1(DeleteCookie, void(const CookieMonster::CanonicalCookie& cc));
- MOCK_METHOD1(SetClearLocalStateOnExit, void(bool clear_local_state));
MOCK_METHOD1(Flush, void(const base::Closure& callback));
+ MOCK_METHOD0(SetForceKeepSessionState, void());
private:
virtual ~NewMockPersistentCookieStore() {}
@@ -2220,7 +2220,7 @@ class FlushablePersistentStore : public CookieMonster::PersistentCookieStore {
void AddCookie(const CookieMonster::CanonicalCookie&) {}
void UpdateCookieAccessTime(const CookieMonster::CanonicalCookie&) {}
void DeleteCookie(const CookieMonster::CanonicalCookie&) {}
- void SetClearLocalStateOnExit(bool clear_local_state) {}
+ void SetForceKeepSessionState() {}
void Flush(const base::Closure& callback) {
++flush_count_;
diff --git a/webkit/appcache/appcache_service.cc b/webkit/appcache/appcache_service.cc
index 2bb99cf..0c4d9a9 100644
--- a/webkit/appcache/appcache_service.cc
+++ b/webkit/appcache/appcache_service.cc
@@ -425,8 +425,8 @@ void AppCacheService::CheckResponseHelper::OnReadDataComplete(int result) {
AppCacheService::AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy)
: appcache_policy_(NULL), quota_client_(NULL),
quota_manager_proxy_(quota_manager_proxy),
- request_context_(NULL), clear_local_state_on_exit_(false),
- save_session_state_(false) {
+ request_context_(NULL),
+ force_keep_session_state_(false) {
if (quota_manager_proxy_) {
quota_client_ = new AppCacheQuotaClient(this);
quota_manager_proxy_->RegisterClient(quota_client_);
diff --git a/webkit/appcache/appcache_service.h b/webkit/appcache/appcache_service.h
index c05bea4..3d9f8bb 100644
--- a/webkit/appcache/appcache_service.h
+++ b/webkit/appcache/appcache_service.h
@@ -143,16 +143,9 @@ class APPCACHE_EXPORT AppCacheService {
AppCacheStorage* storage() const { return storage_.get(); }
- bool clear_local_state_on_exit() const { return clear_local_state_on_exit_; }
- void set_clear_local_state_on_exit(bool clear_local_state_on_exit) {
- clear_local_state_on_exit_ = clear_local_state_on_exit; }
-
- bool save_session_state() const { return save_session_state_; }
- // If |save_session_state| is true, disables the exit-time deletion for all
- // data (also session-only data).
- void set_save_session_state(bool save_session_state) {
- save_session_state_ = save_session_state;
- }
+ // Disables the exit-time deletion of session-only data.
+ void set_force_keep_session_state() { force_keep_session_state_ = true; }
+ bool force_keep_session_state() const { return force_keep_session_state_; }
protected:
friend class AppCacheStorageImplTest;
@@ -177,9 +170,8 @@ class APPCACHE_EXPORT AppCacheService {
BackendMap backends_; // One 'backend' per child process.
// Context for use during cache updates.
net::URLRequestContext* request_context_;
- bool clear_local_state_on_exit_;
// If true, nothing (not even session-only data) should be deleted on exit.
- bool save_session_state_;
+ bool force_keep_session_state_;
DISALLOW_COPY_AND_ASSIGN(AppCacheService);
};
diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc
index 1ddfaa4..3d8c785 100644
--- a/webkit/appcache/appcache_storage_impl.cc
+++ b/webkit/appcache/appcache_storage_impl.cc
@@ -75,17 +75,15 @@ bool DeleteGroupAndRelatedRecords(AppCacheDatabase* database,
}
// Destroys |database|. If there is appcache data to be deleted
-// (|save_session_state| is false), deletes all appcache data (if
-// |clear_all_data| is true), or session-only appcache data (otherwise).
-void CleanUpOnDatabaseThread(
+// (|force_keep_session_state| is false), deletes session-only appcache data.
+void ClearSessionOnlyOrigins(
AppCacheDatabase* database,
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
- bool clear_all_appcaches,
- bool save_session_state) {
+ bool force_keep_session_state) {
scoped_ptr<AppCacheDatabase> database_to_delete(database);
// If saving session state, only delete the database.
- if (save_session_state)
+ if (force_keep_session_state)
return;
bool has_session_only_appcaches =
@@ -93,7 +91,7 @@ void CleanUpOnDatabaseThread(
special_storage_policy->HasSessionOnlyOrigins();
// Clearning only session-only databases, and there are none.
- if (!clear_all_appcaches && !has_session_only_appcaches)
+ if (!has_session_only_appcaches)
return;
std::set<GURL> origins;
@@ -109,8 +107,7 @@ void CleanUpOnDatabaseThread(
std::set<GURL>::const_iterator origin;
for (origin = origins.begin(); origin != origins.end(); ++origin) {
- if (!clear_all_appcaches &&
- !special_storage_policy->IsStorageSessionOnly(*origin))
+ if (!special_storage_policy->IsStorageSessionOnly(*origin))
continue;
if (special_storage_policy &&
special_storage_policy->IsStorageProtected(*origin))
@@ -1315,10 +1312,9 @@ AppCacheStorageImpl::~AppCacheStorageImpl() {
if (database_ &&
!db_thread_->PostTask(
FROM_HERE,
- base::Bind(&CleanUpOnDatabaseThread, database_,
+ base::Bind(&ClearSessionOnlyOrigins, database_,
make_scoped_refptr(service_->special_storage_policy()),
- service()->clear_local_state_on_exit(),
- service()->save_session_state()))) {
+ service()->force_keep_session_state()))) {
delete database_;
}
}
diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc
index 68899de..2daeef1 100644
--- a/webkit/database/database_tracker.cc
+++ b/webkit/database/database_tracker.cc
@@ -98,8 +98,7 @@ DatabaseTracker::DatabaseTracker(
base::MessageLoopProxy* db_tracker_thread)
: is_initialized_(false),
is_incognito_(is_incognito),
- clear_local_state_on_exit_(false),
- save_session_state_(false),
+ force_keep_session_state_(false),
shutting_down_(false),
profile_path_(profile_path),
db_dir_(is_incognito_ ?
@@ -810,7 +809,7 @@ void DatabaseTracker::DeleteIncognitoDBDirectory() {
file_util::Delete(incognito_db_dir, true);
}
-void DatabaseTracker::ClearLocalState(bool clear_all_databases) {
+void DatabaseTracker::ClearSessionOnlyOrigins() {
shutting_down_ = true;
bool has_session_only_databases =
@@ -818,7 +817,7 @@ void DatabaseTracker::ClearLocalState(bool clear_all_databases) {
special_storage_policy_->HasSessionOnlyOrigins();
// Clearing only session-only databases, and there are none.
- if (!clear_all_databases && !has_session_only_databases)
+ if (!has_session_only_databases)
return;
if (!LazyInit())
@@ -831,14 +830,10 @@ void DatabaseTracker::ClearLocalState(bool clear_all_databases) {
origin != origin_identifiers.end(); ++origin) {
GURL origin_url =
webkit_database::DatabaseUtil::GetOriginFromIdentifier(*origin);
- if (!clear_all_databases &&
- !special_storage_policy_->IsStorageSessionOnly(origin_url)) {
+ if (!special_storage_policy_->IsStorageSessionOnly(origin_url))
continue;
- }
- if (special_storage_policy_.get() &&
- special_storage_policy_->IsStorageProtected(origin_url)) {
+ if (special_storage_policy_->IsStorageProtected(origin_url))
continue;
- }
webkit_database::OriginInfo origin_info;
std::vector<string16> databases;
GetOriginInfo(*origin, &origin_info);
@@ -869,35 +864,19 @@ void DatabaseTracker::Shutdown() {
}
if (is_incognito_)
DeleteIncognitoDBDirectory();
- else if (!save_session_state_)
- ClearLocalState(clear_local_state_on_exit_);
-}
-
-void DatabaseTracker::SetClearLocalStateOnExit(bool clear_local_state_on_exit) {
- DCHECK(db_tracker_thread_.get());
- if (!db_tracker_thread_->BelongsToCurrentThread()) {
- db_tracker_thread_->PostTask(
- FROM_HERE,
- base::Bind(&DatabaseTracker::SetClearLocalStateOnExit, this,
- clear_local_state_on_exit));
- return;
- }
- if (shutting_down_) {
- NOTREACHED();
- return;
- }
- clear_local_state_on_exit_ = clear_local_state_on_exit;
+ else if (!force_keep_session_state_)
+ ClearSessionOnlyOrigins();
}
-void DatabaseTracker::SaveSessionState() {
+void DatabaseTracker::SetForceKeepSessionState() {
DCHECK(db_tracker_thread_.get());
if (!db_tracker_thread_->BelongsToCurrentThread()) {
db_tracker_thread_->PostTask(
FROM_HERE,
- base::Bind(&DatabaseTracker::SaveSessionState, this));
+ base::Bind(&DatabaseTracker::SetForceKeepSessionState, this));
return;
}
- save_session_state_ = true;
+ force_keep_session_state_ = true;
}
} // namespace webkit_database
diff --git a/webkit/database/database_tracker.h b/webkit/database/database_tracker.h
index f8145a8..9c1ef04 100644
--- a/webkit/database/database_tracker.h
+++ b/webkit/database/database_tracker.h
@@ -167,11 +167,10 @@ class DatabaseTracker
bool HasSavedIncognitoFileHandle(const string16& vfs_file_path) const;
// Shutdown the database tracker, deleting database files if the tracker is
- // used for an incognito profile or |clear_local_state_on_exit_| is true.
+ // used for an incognito profile.
void Shutdown();
- void SetClearLocalStateOnExit(bool clear_local_state_on_exit);
- // Disables the exit-time deletion for all data (also session-only data).
- void SaveSessionState();
+ // Disables the exit-time deletion of session-only data.
+ void SetForceKeepSessionState();
private:
friend class base::RefCountedThreadSafe<DatabaseTracker>;
@@ -207,10 +206,8 @@ class DatabaseTracker
// Deletes the directory that stores all DBs in incognito mode, if it exists.
void DeleteIncognitoDBDirectory();
- // If clear_all_databases is true, deletes all databases not protected by
- // special storage policy. Otherwise deletes session-only databases. Blocks
- // databases from being created/opened.
- void ClearLocalState(bool clear_all_databases);
+ // Deletes session-only databases. Blocks databases from being created/opened.
+ void ClearSessionOnlyOrigins();
bool DeleteClosedDatabase(const string16& origin_identifier,
const string16& database_name);
@@ -263,8 +260,7 @@ class DatabaseTracker
bool is_initialized_;
const bool is_incognito_;
- bool clear_local_state_on_exit_;
- bool save_session_state_;
+ bool force_keep_session_state_;
bool shutting_down_;
const FilePath profile_path_;
const FilePath db_dir_;
diff --git a/webkit/database/database_tracker_unittest.cc b/webkit/database/database_tracker_unittest.cc
index 4902c72..a80ca42 100644
--- a/webkit/database/database_tracker_unittest.cc
+++ b/webkit/database/database_tracker_unittest.cc
@@ -528,107 +528,6 @@ class DatabaseTracker_TestHelper_Test {
test_quota_proxy->SimulateQuotaManagerDestroyed();
}
- static void DatabaseTrackerClearLocalStateOnExit() {
- int64 database_size = 0;
- const string16 kOrigin1 =
- DatabaseUtil::GetOriginIdentifier(GURL(kOrigin1Url));
- const string16 kOrigin2 =
- DatabaseUtil::GetOriginIdentifier(GURL(kOrigin2Url));
- const string16 kDB1 = ASCIIToUTF16("db1");
- const string16 kDB2 = ASCIIToUTF16("db2");
- const string16 kDB3 = ASCIIToUTF16("db3");
- const string16 kDescription = ASCIIToUTF16("database_description");
-
- // Initialize the tracker database.
- ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- FilePath origin1_db_dir;
- {
- scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
- new quota::MockSpecialStoragePolicy;
- special_storage_policy->AddProtected(GURL(kOrigin2Url));
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(
- temp_dir.path(), false,
- special_storage_policy, NULL,
- base::MessageLoopProxy::current()));
- tracker->SetClearLocalStateOnExit(true);
-
- // Open three new databases.
- tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
- tracker->DatabaseOpened(kOrigin2, kDB2, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
- tracker->DatabaseOpened(kOrigin1, kDB3, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
-
- // Write some data to each file.
- FilePath db_file;
- db_file = tracker->GetFullDBFilePath(kOrigin1, kDB1);
- EXPECT_TRUE(file_util::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 1));
-
- db_file = tracker->GetFullDBFilePath(kOrigin2, kDB2);
- EXPECT_TRUE(file_util::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 2));
-
- db_file = tracker->GetFullDBFilePath(kOrigin1, kDB3);
- EXPECT_TRUE(file_util::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 3));
-
- // Store the origin database directory as long as it still exists.
- origin1_db_dir = tracker->GetFullDBFilePath(kOrigin1, kDB3).DirName();
-
- tracker->DatabaseModified(kOrigin1, kDB1);
- tracker->DatabaseModified(kOrigin2, kDB2);
- tracker->DatabaseModified(kOrigin1, kDB3);
-
- // Close all databases but one database.
- tracker->DatabaseClosed(kOrigin1, kDB1);
- tracker->DatabaseClosed(kOrigin2, kDB2);
-
- // Keep an open file handle to the last database.
- base::PlatformFile file_handle = base::CreatePlatformFile(
- tracker->GetFullDBFilePath(kOrigin1, kDB3),
- base::PLATFORM_FILE_READ |
- base::PLATFORM_FILE_WRITE |
- base::PLATFORM_FILE_EXCLUSIVE_READ |
- base::PLATFORM_FILE_EXCLUSIVE_WRITE |
- base::PLATFORM_FILE_OPEN_ALWAYS |
- base::PLATFORM_FILE_SHARE_DELETE,
- NULL, NULL);
-
- tracker->Shutdown();
-
- base::ClosePlatformFile(file_handle);
- tracker->DatabaseClosed(kOrigin1, kDB3);
- }
-
- // At this point, the database tracker should be gone. Create a new one.
- scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
- new quota::MockSpecialStoragePolicy;
- special_storage_policy->AddProtected(GURL(kOrigin2Url));
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(), false,
- special_storage_policy, NULL, NULL));
-
- // Get all data for all origins.
- std::vector<OriginInfo> origins_info;
- EXPECT_TRUE(tracker->GetAllOriginsInfo(&origins_info));
- EXPECT_EQ(size_t(1), origins_info.size());
- EXPECT_EQ(kOrigin2, origins_info[0].GetOrigin());
- EXPECT_EQ(FilePath(), tracker->GetFullDBFilePath(kOrigin1, kDB1));
- EXPECT_TRUE(
- file_util::PathExists(tracker->GetFullDBFilePath(kOrigin2, kDB2)));
- EXPECT_EQ(FilePath(), tracker->GetFullDBFilePath(kOrigin1, kDB3));
-
- // The origin directory should be gone as well.
- EXPECT_FALSE(file_util::PathExists(origin1_db_dir));
- }
-
static void DatabaseTrackerClearSessionOnlyDatabasesOnExit() {
int64 database_size = 0;
const string16 kOrigin1 =
@@ -706,7 +605,7 @@ class DatabaseTracker_TestHelper_Test {
EXPECT_FALSE(file_util::PathExists(origin2_db_dir));
}
- static void DatabaseTrackerSaveSessionState() {
+ static void DatabaseTrackerSetForceKeepSessionState() {
int64 database_size = 0;
const string16 kOrigin1 =
DatabaseUtil::GetOriginIdentifier(GURL(kOrigin1Url));
@@ -729,8 +628,7 @@ class DatabaseTracker_TestHelper_Test {
new DatabaseTracker(
temp_dir.path(), false, special_storage_policy, NULL,
base::MessageLoopProxy::current()));
- tracker->SetClearLocalStateOnExit(true);
- tracker->SaveSessionState();
+ tracker->SetForceKeepSessionState();
// Open two new databases.
tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
@@ -925,20 +823,15 @@ TEST(DatabaseTrackerTest, DatabaseTrackerQuotaIntegration) {
DatabaseTracker_TestHelper_Test::DatabaseTrackerQuotaIntegration();
}
-TEST(DatabaseTrackerTest, DatabaseTrackerClearLocalStateOnExit) {
- // Only works for regular mode.
- DatabaseTracker_TestHelper_Test::DatabaseTrackerClearLocalStateOnExit();
-}
-
TEST(DatabaseTrackerTest, DatabaseTrackerClearSessionOnlyDatabasesOnExit) {
// Only works for regular mode.
DatabaseTracker_TestHelper_Test::
DatabaseTrackerClearSessionOnlyDatabasesOnExit();
}
-TEST(DatabaseTrackerTest, DatabaseTrackerSaveSessionState) {
+TEST(DatabaseTrackerTest, DatabaseTrackerSetForceKeepSessionState) {
// Only works for regular mode.
- DatabaseTracker_TestHelper_Test::DatabaseTrackerSaveSessionState();
+ DatabaseTracker_TestHelper_Test::DatabaseTrackerSetForceKeepSessionState();
}
TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) {
diff --git a/webkit/dom_storage/dom_storage_context.cc b/webkit/dom_storage/dom_storage_context.cc
index 287ae99..f9d530a 100644
--- a/webkit/dom_storage/dom_storage_context.cc
+++ b/webkit/dom_storage/dom_storage_context.cc
@@ -31,8 +31,7 @@ DomStorageContext::DomStorageContext(
sessionstorage_directory_(sessionstorage_directory),
task_runner_(task_runner),
is_shutdown_(false),
- clear_local_state_(false),
- save_session_state_(false),
+ force_keep_session_state_(false),
special_storage_policy_(special_storage_policy) {
// AtomicSequenceNum starts at 0 but we want to start session
// namespace ids at one since zero is reserved for the
@@ -115,21 +114,21 @@ void DomStorageContext::Shutdown() {
// Respect the content policy settings about what to
// keep and what to discard.
- if (save_session_state_)
+ if (force_keep_session_state_)
return; // Keep everything.
bool has_session_only_origins =
special_storage_policy_.get() &&
special_storage_policy_->HasSessionOnlyOrigins();
- if (clear_local_state_ || has_session_only_origins) {
+ if (has_session_only_origins) {
// We may have to delete something. We continue on the
// commit sequence after area shutdown tasks have cycled
// thru that sequence (and closed their database files).
bool success = task_runner_->PostShutdownBlockingTask(
FROM_HERE,
DomStorageTaskRunner::COMMIT_SEQUENCE,
- base::Bind(&DomStorageContext::ClearLocalStateInCommitSequence, this));
+ base::Bind(&DomStorageContext::ClearSessionOnlyOrigins, this));
DCHECK(success);
}
}
@@ -200,17 +199,15 @@ void DomStorageContext::CloneSessionNamespace(
CreateSessionNamespace(new_id);
}
-void DomStorageContext::ClearLocalStateInCommitSequence() {
+void DomStorageContext::ClearSessionOnlyOrigins() {
std::vector<UsageInfo> infos;
const bool kDontIncludeFileInfo = false;
GetUsageInfo(&infos, kDontIncludeFileInfo);
for (size_t i = 0; i < infos.size(); ++i) {
const GURL& origin = infos[i].origin;
- if (special_storage_policy_ &&
- special_storage_policy_->IsStorageProtected(origin))
+ if (special_storage_policy_->IsStorageProtected(origin))
continue;
- if (!clear_local_state_ &&
- !special_storage_policy_->IsStorageSessionOnly(origin))
+ if (!special_storage_policy_->IsStorageSessionOnly(origin))
continue;
const bool kNotRecursive = false;
diff --git a/webkit/dom_storage/dom_storage_context.h b/webkit/dom_storage/dom_storage_context.h
index 4aeb7ff..c7d57a3 100644
--- a/webkit/dom_storage/dom_storage_context.h
+++ b/webkit/dom_storage/dom_storage_context.h
@@ -117,11 +117,8 @@ class DomStorageContext
// what data to keep and what data to discard at shutdown.
// The policy is not so straight forward to describe, see
// the implementation for details.
- void SetClearLocalState(bool clear_local_state) {
- clear_local_state_ = clear_local_state;
- }
- void SaveSessionState() {
- save_session_state_ = true;
+ void SetForceKeepSessionState() {
+ force_keep_session_state_ = true;
}
// Called when the owning BrowserContext is ending.
@@ -168,7 +165,7 @@ class DomStorageContext
~DomStorageContext();
- void ClearLocalStateInCommitSequence();
+ void ClearSessionOnlyOrigins();
// Collection of namespaces keyed by id.
StorageNamespaceMap namespaces_;
@@ -192,8 +189,7 @@ class DomStorageContext
base::AtomicSequenceNumber session_id_sequence_;
bool is_shutdown_;
- bool clear_local_state_;
- bool save_session_state_;
+ bool force_keep_session_state_;
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
};
diff --git a/webkit/dom_storage/dom_storage_context_unittest.cc b/webkit/dom_storage/dom_storage_context_unittest.cc
index db3bd3f..4549fb5 100644
--- a/webkit/dom_storage/dom_storage_context_unittest.cc
+++ b/webkit/dom_storage/dom_storage_context_unittest.cc
@@ -141,26 +141,7 @@ TEST_F(DomStorageContextTest, SessionOnly) {
VerifySingleOriginRemains(kOrigin);
}
-TEST_F(DomStorageContextTest, ClearLocalState) {
- const GURL kProtectedOrigin("http://www.protected.com/");
- storage_policy_->AddProtected(kProtectedOrigin);
-
- // Store data for a normal and a protected origin, setup shutdown options
- // to clear normal local state, then shutdown and let things flush.
- NullableString16 old_value;
- EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)->
- OpenStorageArea(kOrigin)->SetItem(kKey, kValue, &old_value));
- EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)->
- OpenStorageArea(kProtectedOrigin)->SetItem(kKey, kValue, &old_value));
- context_->SetClearLocalState(true);
- context_->Shutdown();
- context_ = NULL;
- MessageLoop::current()->RunAllPending();
-
- VerifySingleOriginRemains(kProtectedOrigin);
-}
-
-TEST_F(DomStorageContextTest, SaveSessionState) {
+TEST_F(DomStorageContextTest, SetForceKeepSessionState) {
const GURL kSessionOnlyOrigin("http://www.sessiononly.com/");
storage_policy_->AddSessionOnly(kSessionOnlyOrigin);
@@ -169,8 +150,7 @@ TEST_F(DomStorageContextTest, SaveSessionState) {
NullableString16 old_value;
EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)->
OpenStorageArea(kSessionOnlyOrigin)->SetItem(kKey, kValue, &old_value));
- context_->SetClearLocalState(true);
- context_->SaveSessionState(); // Should override clear behavior.
+ context_->SetForceKeepSessionState(); // Should override clear behavior.
context_->Shutdown();
context_ = NULL;
MessageLoop::current()->RunAllPending();