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

Unified Diff: content/browser/service_worker/service_worker_quota_client.cc

Issue 672813002: [ServiceWorker] Added size deltas and total size computation for QuotaM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switching size storage to the registration info, not the version. Updated tests Created 6 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/service_worker/service_worker_quota_client.cc
diff --git a/content/browser/service_worker/service_worker_quota_client.cc b/content/browser/service_worker/service_worker_quota_client.cc
index e2697e2303a62054a46c8736bac95798123ba30d..4c88a5d1976ecf6cf9874e4cc388a19988d21132 100644
--- a/content/browser/service_worker/service_worker_quota_client.cc
+++ b/content/browser/service_worker/service_worker_quota_client.cc
@@ -30,6 +30,18 @@ void ReportToQuotaStatus(const QuotaClient::DeletionCallback& callback,
callback.Run(status ? storage::QuotaStatusCode::kQuotaStatusOk
: storage::QuotaStatusCode::kQuotaStatusUnknown);
}
+
+void AccumulateUsage(const QuotaClient::GetUsageCallback& callback,
michaeln 2014/10/30 23:32:24 oh, the name of this method doesn't fit since its
dmurph 2014/10/31 19:10:49 Done.
+ const GURL& origin,
+ const std::vector<ServiceWorkerUsageInfo>& usage_info) {
+ for (const auto& info : usage_info) {
+ if (info.origin == origin) {
+ callback.Run(info.total_size_bytes);
+ return;
+ }
+ }
+ callback.Run(0);
+}
} // namespace
ServiceWorkerQuotaClient::ServiceWorkerQuotaClient(
@@ -52,8 +64,11 @@ void ServiceWorkerQuotaClient::GetOriginUsage(
const GURL& origin,
storage::StorageType type,
const GetUsageCallback& callback) {
- // TODO(dmurph): Add usage fetching when information is available.
- callback.Run(0);
+ if (type != storage::StorageType::kStorageTypeTemporary) {
+ callback.Run(0);
+ return;
+ }
+ context_->GetAllOriginsInfo(base::Bind(&AccumulateUsage, callback, origin));
}
void ServiceWorkerQuotaClient::GetOriginsForType(

Powered by Google App Engine
This is Rietveld 408576698