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

Unified Diff: webkit/dom_storage/dom_storage_context.cc

Issue 9817011: DomStorage data deletion and memory purging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | « webkit/dom_storage/dom_storage_context.h ('k') | webkit/dom_storage/dom_storage_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/dom_storage/dom_storage_context.cc
===================================================================
--- webkit/dom_storage/dom_storage_context.cc (revision 127981)
+++ webkit/dom_storage/dom_storage_context.cc (working copy)
@@ -8,20 +8,17 @@
#include "base/bind_helpers.h"
#include "base/file_util.h"
#include "base/time.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "webkit/dom_storage/dom_storage_area.h"
#include "webkit/dom_storage/dom_storage_namespace.h"
#include "webkit/dom_storage/dom_storage_task_runner.h"
#include "webkit/dom_storage/dom_storage_types.h"
-#include "webkit/glue/webkit_glue.h"
#include "webkit/quota/special_storage_policy.h"
using file_util::FileEnumerator;
namespace dom_storage {
-DomStorageContext::UsageInfo::UsageInfo() {}
+DomStorageContext::UsageInfo::UsageInfo() : data_size(0) {}
DomStorageContext::UsageInfo::~UsageInfo() {}
DomStorageContext::DomStorageContext(
@@ -60,35 +57,40 @@
return found->second;
}
-void DomStorageContext::GetUsageInfo(std::vector<UsageInfo>* infos) {
+void DomStorageContext::GetUsageInfo(std::vector<UsageInfo>* infos,
+ bool include_file_info) {
+ if (directory_.empty())
+ return;
FileEnumerator enumerator(directory_, false, FileEnumerator::FILES);
for (FilePath path = enumerator.Next(); !path.empty();
path = enumerator.Next()) {
if (path.MatchesExtension(DomStorageArea::kDatabaseFileExtension)) {
UsageInfo info;
-
- // Extract origin id from the path and construct a GURL.
- WebKit::WebString origin_id = webkit_glue::FilePathToWebString(
- path.BaseName().RemoveExtension());
- info.origin = GURL(WebKit::WebSecurityOrigin::
- createFromDatabaseIdentifier(origin_id).toString());
-
- FileEnumerator::FindInfo find_info;
- enumerator.GetFindInfo(&find_info);
- info.data_size = FileEnumerator::GetFilesize(find_info);
- info.last_modified = FileEnumerator::GetLastModifiedTime(find_info);
-
+ info.origin = DomStorageArea::OriginFromDatabaseFileName(path);
+ if (include_file_info) {
+ FileEnumerator::FindInfo find_info;
+ enumerator.GetFindInfo(&find_info);
+ info.data_size = FileEnumerator::GetFilesize(find_info);
+ info.last_modified = FileEnumerator::GetLastModifiedTime(find_info);
+ }
infos->push_back(info);
}
}
}
void DomStorageContext::DeleteOrigin(const GURL& origin) {
michaeln 2012/03/21 23:22:02 fyi: When this DeleteOrigin() method is invoked, n
- // TODO(michaeln): write me
+ DCHECK(!is_shutdown_);
+ DomStorageNamespace* local = GetStorageNamespace(kLocalStorageNamespaceId);
+ local->DeleteOrigin(origin);
}
void DomStorageContext::DeleteDataModifiedSince(const base::Time& cutoff) {
- // TODO(michaeln): write me
+ std::vector<UsageInfo> infos;
+ GetUsageInfo(&infos, true);
+ for (size_t i = 0; i < infos.size(); ++i) {
+ if (infos[i].last_modified > cutoff)
+ DeleteOrigin(infos[i].origin);
+ }
}
void DomStorageContext::PurgeMemory() {
« no previous file with comments | « webkit/dom_storage/dom_storage_context.h ('k') | webkit/dom_storage/dom_storage_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698