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

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

Issue 2403713002: Add suborigin logic to url::Origin (Closed)
Patch Set: Clarify DeleteLocalStorage API 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
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 2479f8f8d50adaa0fc904ae0846fc2ca4cf1e234..ab823cc88703e078805767c3ad28e8285da48d53 100644
--- a/content/browser/dom_storage/dom_storage_context_impl.cc
+++ b/content/browser/dom_storage/dom_storage_context_impl.cc
@@ -30,8 +30,9 @@
#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"
+#include "url/gurl.h"
+#include "url/origin.h"
namespace content {
namespace {
@@ -201,27 +202,39 @@ void DOMStorageContextImpl::GetSessionStorageUsage(
}
}
-void DOMStorageContextImpl::DeleteLocalStorage(const GURL& origin) {
+void DOMStorageContextImpl::DeleteLocalStorageForPhysicalOrigin(
+ const GURL& origin_url) {
DCHECK(!is_shutdown_);
+ url::Origin origin(origin_url);
+ DCHECK(origin.suborigin().empty());
michaeln 2016/10/21 23:07:12 if we redefine the semantics as described i the .h
jww 2016/10/22 00:43:12 Done.
DOMStorageNamespace* local = GetStorageNamespace(kLocalStorageNamespaceId);
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) {
+ // Suborigin at the physical origin of |origin_url| should have their storage
+ // deleted as well. Since suborigins are not allowed to be sent to the method,
+ // there is no need to be concerned with the inverse case.
+ // https://w3c.github.io/webappsec-suborigins/
+ for (const auto& origin_candidate_url : origins) {
+ url::Origin origin_candidate(origin_candidate_url);
// |origin| is guaranteed to be deleted below, so don't delete it until
- // then.
- if (origin_candidate == origin ||
- StripSuboriginFromUrl(origin_candidate) != origin) {
+ // then. That is, only suborigins at the same physical origin as |origin|
+ // should be deleted at this point.
+ if (origin_candidate.IsSameOriginWith(origin) ||
+ !origin_candidate.IsSamePhysicalOriginWith(origin)) {
continue;
}
- DeleteAndClearStorageNamespaceForOrigin(origin_candidate, local);
+ DeleteAndClearStorageNamespaceForOrigin(origin_candidate_url, local);
michaeln 2016/10/21 23:07:12 call DeleteLocalStorage here and on line 232
jww 2016/10/22 00:43:12 Done.
}
// 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);
+ DeleteAndClearStorageNamespaceForOrigin(origin_url, local);
+}
+
+void DOMStorageContextImpl::DeleteLocalStorage(const GURL& origin_url) {
michaeln 2016/10/21 23:07:12 make this method do what DeleteAndClearStorageName
jww 2016/10/22 00:43:12 Done.
+ url::Origin origin(origin_url);
+ DeleteLocalStorageForPhysicalOrigin(origin.GetPhysicalOrigin().GetURL());
}
void DOMStorageContextImpl::DeleteSessionStorage(
@@ -621,14 +634,14 @@ void DOMStorageContextImpl::DeleteNextUnusedNamespaceInCommitSequence() {
}
void DOMStorageContextImpl::DeleteAndClearStorageNamespaceForOrigin(
- const GURL& origin,
+ const GURL& origin_url,
DOMStorageNamespace* local) {
- local->DeleteLocalStorageOrigin(origin);
+ local->DeleteLocalStorageOrigin(origin_url);
// Synthesize a 'cleared' event if the area is open so CachedAreas in
// renderers get emptied out too.
- DOMStorageArea* area = local->GetOpenStorageArea(origin);
+ DOMStorageArea* area = local->GetOpenStorageArea(origin_url);
if (area)
- NotifyAreaCleared(area, origin);
+ NotifyAreaCleared(area, origin_url);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698