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

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: 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..dc4dd8385db829e9acd1dad7eb3f6eb931a084fa 100644
--- a/content/browser/service_worker/service_worker_quota_client.cc
+++ b/content/browser/service_worker/service_worker_quota_client.cc
@@ -30,6 +30,15 @@ void ReportToQuotaStatus(const QuotaClient::DeletionCallback& callback,
callback.Run(status ? storage::QuotaStatusCode::kQuotaStatusOk
: storage::QuotaStatusCode::kQuotaStatusUnknown);
}
+
+void AccumulateUsage(const QuotaClient::GetUsageCallback& callback,
+ const std::vector<ServiceWorkerUsageInfo>& usage_info) {
+ int64 usage_total = 0;
+ for (const auto& info : usage_info) {
+ usage_total += info.total_size_bytes;
+ }
+ callback.Run(usage_total);
+}
} // namespace
ServiceWorkerQuotaClient::ServiceWorkerQuotaClient(
@@ -52,8 +61,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));
michaeln 2014/10/24 23:15:47 The method is supposed to return the amount of dat
dmurph 2014/10/27 21:37:06 Done.
}
void ServiceWorkerQuotaClient::GetOriginsForType(

Powered by Google App Engine
This is Rietveld 408576698