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

Unified Diff: content/browser/dom_storage/dom_storage_context_impl.cc

Issue 2005783005: Re-enable storage for Suborigins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Rebase on ToT Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_impl.h ('k') | content/common/origin_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/dom_storage/dom_storage_context_impl.cc
diff --git a/content/browser/dom_storage/dom_storage_context_impl.cc b/content/browser/dom_storage/dom_storage_context_impl.cc
index 9431fcec12323ee8ae05b0df362486e794750355..cd2cdbd49181b9fce9b888f912c708c41fc2096e 100644
--- a/content/browser/dom_storage/dom_storage_context_impl.cc
+++ b/content/browser/dom_storage/dom_storage_context_impl.cc
@@ -30,6 +30,7 @@
#include "content/public/browser/dom_storage_context.h"
#include "content/public/browser/local_storage_usage_info.h"
#include "content/public/browser/session_storage_usage_info.h"
+#include "content/public/common/origin_util.h"
#include "storage/browser/quota/special_storage_policy.h"
namespace content {
@@ -203,12 +204,24 @@ void DOMStorageContextImpl::GetSessionStorageUsage(
void DOMStorageContextImpl::DeleteLocalStorage(const GURL& origin) {
DCHECK(!is_shutdown_);
DOMStorageNamespace* local = GetStorageNamespace(kLocalStorageNamespaceId);
- local->DeleteLocalStorageOrigin(origin);
- // Synthesize a 'cleared' event if the area is open so CachedAreas in
- // renderers get emptied out too.
- DOMStorageArea* area = local->GetOpenStorageArea(origin);
- if (area)
- NotifyAreaCleared(area, origin);
+ std::vector<GURL> origins;
+ local->GetOriginsWithAreas(&origins);
+ // Suborigin storage should be deleted in tandem with the physical origin's
+ // storage. https://w3c.github.io/webappsec-suborigins/
+ for (auto origin_candidate : origins) {
+ // |origin| is guaranteed to be deleted below, so don't delete it until
+ // then.
+ if (origin_candidate == origin ||
+ StripSuboriginFromUrl(origin_candidate) != origin) {
+ continue;
+ }
+ DeleteAndClearStorageNamespaceForOrigin(origin_candidate, local);
+ }
+ // It is important to always explicitly delete |origin|. If it does not appear
+ // it |origins| above, there still may be a directory open in the namespace in
+ // preparation for this storage, and this call will make sure that the
+ // directory is deleted.
+ DeleteAndClearStorageNamespaceForOrigin(origin, local);
}
void DOMStorageContextImpl::DeleteSessionStorage(
@@ -610,4 +623,15 @@ void DOMStorageContextImpl::DeleteNextUnusedNamespaceInCommitSequence() {
}
}
+void DOMStorageContextImpl::DeleteAndClearStorageNamespaceForOrigin(
+ const GURL& origin,
+ DOMStorageNamespace* local) {
+ local->DeleteLocalStorageOrigin(origin);
+ // Synthesize a 'cleared' event if the area is open so CachedAreas in
+ // renderers get emptied out too.
+ DOMStorageArea* area = local->GetOpenStorageArea(origin);
+ if (area)
+ NotifyAreaCleared(area, origin);
+}
+
} // namespace content
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_impl.h ('k') | content/common/origin_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698