summaryrefslogtreecommitdiffstats
path: root/webkit/dom_storage
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 /webkit/dom_storage
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
Diffstat (limited to 'webkit/dom_storage')
-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
3 files changed, 13 insertions, 40 deletions
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();