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

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

Issue 651983002: [ServiceWorkerCache] Implement storage::QuotaClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS7 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_cache_quota_client.cc
diff --git a/content/browser/service_worker/service_worker_cache_quota_client.cc b/content/browser/service_worker/service_worker_cache_quota_client.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d3e61c8af17dd6065f2fe27510f3b84d70d40669
--- /dev/null
+++ b/content/browser/service_worker/service_worker_cache_quota_client.cc
@@ -0,0 +1,92 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/service_worker/service_worker_cache_quota_client.h"
+
+#include "content/browser/service_worker/service_worker_cache_storage_manager.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+ServiceWorkerCacheQuotaClient::ServiceWorkerCacheQuotaClient(
+ const scoped_refptr<ServiceWorkerCacheStorageManager>& cache_manager)
+ : cache_manager_(cache_manager) {
+}
+
+ServiceWorkerCacheQuotaClient::~ServiceWorkerCacheQuotaClient() {
+}
+
+storage::QuotaClient::ID ServiceWorkerCacheQuotaClient::id() const {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ return kServiceWorkerCache;
+}
+
+void ServiceWorkerCacheQuotaClient::OnQuotaManagerDestroyed() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ delete this;
+}
+
+void ServiceWorkerCacheQuotaClient::GetOriginUsage(
+ const GURL& origin_url,
+ storage::StorageType type,
+ const GetUsageCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ if (!DoesSupport(type)) {
+ callback.Run(0);
+ return;
+ }
+
+ cache_manager_->GetOriginUsage(origin_url, callback);
+}
+
+void ServiceWorkerCacheQuotaClient::GetOriginsForType(
+ storage::StorageType type,
+ const GetOriginsCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ if (!DoesSupport(type)) {
+ callback.Run(std::set<GURL>());
+ return;
+ }
+
+ cache_manager_->GetOrigins(callback);
+}
+
+void ServiceWorkerCacheQuotaClient::GetOriginsForHost(
+ storage::StorageType type,
+ const std::string& host,
+ const GetOriginsCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ if (!DoesSupport(type)) {
+ callback.Run(std::set<GURL>());
+ return;
+ }
+
+ cache_manager_->GetOriginsForHost(host, callback);
+}
+
+void ServiceWorkerCacheQuotaClient::DeleteOriginData(
+ const GURL& origin,
+ storage::StorageType type,
+ const DeletionCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ if (!DoesSupport(type)) {
+ callback.Run(storage::kQuotaStatusOk);
+ return;
+ }
+
+ cache_manager_->DeleteOriginData(origin, callback);
+}
+
+bool ServiceWorkerCacheQuotaClient::DoesSupport(
+ storage::StorageType type) const {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ return type == storage::kStorageTypeTemporary;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698