| Index: content/browser/dom_storage/dom_storage_context_impl.cc
|
| ===================================================================
|
| --- content/browser/dom_storage/dom_storage_context_impl.cc (revision 139818)
|
| +++ content/browser/dom_storage/dom_storage_context_impl.cc (working copy)
|
| @@ -23,10 +23,43 @@
|
| using dom_storage::DomStorageWorkerPoolTaskRunner;
|
| using webkit_database::DatabaseUtil;
|
|
|
| +namespace content {
|
| +DOMStorageContext::UsageInfo::UsageInfo() : data_size(0) {}
|
| +DOMStorageContext::UsageInfo::~UsageInfo() {}
|
| +}
|
| +
|
| namespace {
|
|
|
| const char kLocalStorageDirectory[] = "Local Storage";
|
|
|
| +void InvokeUsageInfoCallbackHelper(
|
| + const DOMStorageContext::GetUsageInfoCallback& callback,
|
| + const std::vector<DOMStorageContext::UsageInfo>* infos) {
|
| + callback.Run(*infos);
|
| +}
|
| +
|
| +void GetUsageInfoHelper(
|
| + base::MessageLoopProxy* reply_loop,
|
| + DomStorageContext* context,
|
| + const DOMStorageContext::GetUsageInfoCallback& callback) {
|
| + std::vector<DomStorageContext::UsageInfo> infos;
|
| + const bool kIncludeFileInfo = true;
|
| + context->GetUsageInfo(&infos, kIncludeFileInfo);
|
| +
|
| + std::vector<DOMStorageContext::UsageInfo>* public_infos =
|
| + new std::vector<DOMStorageContext::UsageInfo>(infos.size());
|
| + for (size_t i = 0; i < infos.size(); ++i) {
|
| + (*public_infos)[i].origin = infos[i].origin;
|
| + (*public_infos)[i].data_size = infos[i].data_size;
|
| + (*public_infos)[i].last_modified = infos[i].last_modified;
|
| + }
|
| +
|
| + reply_loop->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&InvokeUsageInfoCallbackHelper,
|
| + callback, base::Owned(public_infos)));
|
| +}
|
| +
|
| // TODO(michaeln): Fix the content layer api, FilePaths and
|
| // string16 origin_ids are just wrong. Then get rid of
|
| // this conversion non-sense. Most of the includes are just
|
| @@ -98,6 +131,24 @@
|
| DOMStorageContextImpl::~DOMStorageContextImpl() {
|
| }
|
|
|
| +void DOMStorageContextImpl::GetUsageInfo(const GetUsageInfoCallback& callback) {
|
| + DCHECK(context_);
|
| + context_->task_runner()->PostShutdownBlockingTask(
|
| + FROM_HERE,
|
| + DomStorageTaskRunner::PRIMARY_SEQUENCE,
|
| + base::Bind(&GetUsageInfoHelper,
|
| + base::MessageLoopProxy::current(),
|
| + context_, callback));
|
| +}
|
| +
|
| +void DOMStorageContextImpl::DeleteOrigin(const GURL& origin) {
|
| + DCHECK(context_);
|
| + context_->task_runner()->PostShutdownBlockingTask(
|
| + FROM_HERE,
|
| + DomStorageTaskRunner::PRIMARY_SEQUENCE,
|
| + base::Bind(&DomStorageContext::DeleteOrigin, context_, origin));
|
| +}
|
| +
|
| void DOMStorageContextImpl::GetAllStorageFiles(
|
| const GetAllStorageFilesCallback& callback) {
|
| DCHECK(context_);
|
|
|