| 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 get_file_info_too) {
|
| + 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 (get_file_info_too) {
|
| + 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) {
|
| - // 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() {
|
|
|