Commit f5d895cf authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

Service Worker: Remove unnecessary StorageType handling in QuotaClient.

QuotaClient's methods will only be called with a StorageType in the list
of types provided to QuotaManager::RegisterClient(). The QuotaClient
implementation managing service worker registrations only provides
kTemporary, like all modern storage APIs. Therefore, its QuotaClient
implementation does not need to handle other StorageType values.

Bug: 1016065
Change-Id: I15d6cd4dc503790d6ac3a7b1d7bd5c5db0b6da01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2249635Reviewed-by: default avatarJarryd Goodman <jarrydg@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Auto-Submit: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779660}
parent 9ab65466
// Copyright 2014 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/service_worker/service_worker_quota_client.h" #include "content/browser/service_worker/service_worker_quota_client.h"
#include <string>
#include <utility>
#include <vector>
#include "base/bind.h" #include "base/bind.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h" #include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_usage_info.h" #include "content/public/browser/storage_usage_info.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom-shared.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
using blink::mojom::StorageType; using blink::mojom::StorageType;
using storage::QuotaClient; using storage::QuotaClient;
...@@ -56,20 +65,14 @@ ServiceWorkerQuotaClient::~ServiceWorkerQuotaClient() { ...@@ -56,20 +65,14 @@ ServiceWorkerQuotaClient::~ServiceWorkerQuotaClient() {
void ServiceWorkerQuotaClient::GetOriginUsage(const url::Origin& origin, void ServiceWorkerQuotaClient::GetOriginUsage(const url::Origin& origin,
StorageType type, StorageType type,
GetUsageCallback callback) { GetUsageCallback callback) {
if (type != StorageType::kTemporary) { DCHECK_EQ(type, StorageType::kTemporary);
std::move(callback).Run(0);
return;
}
context_->GetAllOriginsInfo(base::BindOnce( context_->GetAllOriginsInfo(base::BindOnce(
&FindUsageForOrigin, std::move(callback), origin.GetURL())); &FindUsageForOrigin, std::move(callback), origin.GetURL()));
} }
void ServiceWorkerQuotaClient::GetOriginsForType(StorageType type, void ServiceWorkerQuotaClient::GetOriginsForType(StorageType type,
GetOriginsCallback callback) { GetOriginsCallback callback) {
if (type != StorageType::kTemporary) { DCHECK_EQ(type, StorageType::kTemporary);
std::move(callback).Run(std::set<url::Origin>());
return;
}
context_->GetAllOriginsInfo( context_->GetAllOriginsInfo(
base::BindOnce(&ReportOrigins, std::move(callback), false, "")); base::BindOnce(&ReportOrigins, std::move(callback), false, ""));
} }
...@@ -77,10 +80,7 @@ void ServiceWorkerQuotaClient::GetOriginsForType(StorageType type, ...@@ -77,10 +80,7 @@ void ServiceWorkerQuotaClient::GetOriginsForType(StorageType type,
void ServiceWorkerQuotaClient::GetOriginsForHost(StorageType type, void ServiceWorkerQuotaClient::GetOriginsForHost(StorageType type,
const std::string& host, const std::string& host,
GetOriginsCallback callback) { GetOriginsCallback callback) {
if (type != StorageType::kTemporary) { DCHECK_EQ(type, StorageType::kTemporary);
std::move(callback).Run(std::set<url::Origin>());
return;
}
context_->GetAllOriginsInfo( context_->GetAllOriginsInfo(
base::BindOnce(&ReportOrigins, std::move(callback), true, host)); base::BindOnce(&ReportOrigins, std::move(callback), true, host));
} }
...@@ -88,10 +88,7 @@ void ServiceWorkerQuotaClient::GetOriginsForHost(StorageType type, ...@@ -88,10 +88,7 @@ void ServiceWorkerQuotaClient::GetOriginsForHost(StorageType type,
void ServiceWorkerQuotaClient::DeleteOriginData(const url::Origin& origin, void ServiceWorkerQuotaClient::DeleteOriginData(const url::Origin& origin,
StorageType type, StorageType type,
DeletionCallback callback) { DeletionCallback callback) {
if (type != StorageType::kTemporary) { DCHECK_EQ(type, StorageType::kTemporary);
std::move(callback).Run(blink::mojom::QuotaStatusCode::kOk);
return;
}
context_->DeleteForOrigin( context_->DeleteForOrigin(
origin.GetURL(), origin.GetURL(),
base::BindOnce(&ReportToQuotaStatus, std::move(callback))); base::BindOnce(&ReportToQuotaStatus, std::move(callback)));
...@@ -100,10 +97,7 @@ void ServiceWorkerQuotaClient::DeleteOriginData(const url::Origin& origin, ...@@ -100,10 +97,7 @@ void ServiceWorkerQuotaClient::DeleteOriginData(const url::Origin& origin,
void ServiceWorkerQuotaClient::PerformStorageCleanup( void ServiceWorkerQuotaClient::PerformStorageCleanup(
blink::mojom::StorageType type, blink::mojom::StorageType type,
base::OnceClosure callback) { base::OnceClosure callback) {
if (type != StorageType::kTemporary) { DCHECK_EQ(type, StorageType::kTemporary);
std::move(callback).Run();
return;
}
context_->PerformStorageCleanup(std::move(callback)); context_->PerformStorageCleanup(std::move(callback));
} }
......
...@@ -5,13 +5,17 @@ ...@@ -5,13 +5,17 @@
#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_QUOTA_CLIENT_H_ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_QUOTA_CLIENT_H_
#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_QUOTA_CLIENT_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_QUOTA_CLIENT_H_
#include "base/callback_forward.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "storage/browser/quota/quota_client.h" #include "storage/browser/quota/quota_client.h"
#include "storage/browser/quota/quota_client_type.h" #include "storage/browser/quota/quota_client_type.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom.h" #include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
#include "url/origin.h"
namespace url {
class Origin;
} // namespace url
namespace content { namespace content {
class ServiceWorkerContextWrapper; class ServiceWorkerContextWrapper;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment