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

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

Issue 1900793003: Allow to clear session and local storage when not backed on disk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 7fee39c34abf0647fe6e9c329bafdf54c76fe190..2e4d21e831828d1cd156e594f6022196ad6440a0 100644
--- a/content/browser/dom_storage/dom_storage_context_impl.cc
+++ b/content/browser/dom_storage/dom_storage_context_impl.cc
@@ -95,8 +95,19 @@ DOMStorageNamespace* DOMStorageContextImpl::GetStorageNamespace(
void DOMStorageContextImpl::GetLocalStorageUsage(
std::vector<LocalStorageUsageInfo>* infos,
bool include_file_info) {
- if (localstorage_directory_.empty())
+ if (localstorage_directory_.empty()) {
+ DOMStorageNamespace* local = GetStorageNamespace(kLocalStorageNamespaceId);
+ std::vector<GURL> origins;
+ local->ReadOrigins(&origins);
+ for (std::vector<GURL>::const_iterator origin_it = origins.begin();
michaeln 2016/05/05 00:38:23 please use a range based for loop for this one fo
Julien Isorce Samsung 2016/05/05 11:05:04 Done.
+ origin_it != origins.end(); ++origin_it) {
+ LocalStorageUsageInfo info;
+ info.origin = *origin_it;
+ infos->push_back(info);
+ }
return;
+ }
+
base::FileEnumerator enumerator(localstorage_directory_, false,
base::FileEnumerator::FILES);
for (base::FilePath path = enumerator.Next(); !path.empty();
@@ -116,8 +127,23 @@ void DOMStorageContextImpl::GetLocalStorageUsage(
void DOMStorageContextImpl::GetSessionStorageUsage(
std::vector<SessionStorageUsageInfo>* infos) {
- if (!session_storage_database_.get())
+ if (!session_storage_database_.get()) {
+ for (StorageNamespaceMap::const_iterator namespace_it = namespaces_.begin();
+ namespace_it != namespaces_.end(); ++namespace_it) {
michaeln 2016/05/05 00:38:23 might be nice to use range based loops here too
Julien Isorce Samsung 2016/05/05 11:05:04 Done and I used "auto" like in DOMStorageContextIm
+ std::vector<GURL> origins;
+ namespace_it->second->ReadOrigins(&origins);
+ for (std::vector<GURL>::const_iterator origin_it = origins.begin();
+ origin_it != origins.end(); ++origin_it) {
+ SessionStorageUsageInfo info;
+ info.persistent_namespace_id =
+ namespace_it->second->persistent_namespace_id();
+ info.origin = *origin_it;
+ infos->push_back(info);
+ }
+ }
return;
+ }
+
std::map<std::string, std::vector<GURL> > namespaces_and_origins;
session_storage_database_->ReadNamespacesAndOrigins(
&namespaces_and_origins);

Powered by Google App Engine
This is Rietveld 408576698