Commit a2379c66 authored by Victor Costan's avatar Victor Costan Committed by Chromium LUCI CQ

NativeIO: Minor improvements for NativeIOQuotaClient.

This CL fixes issues I missed while reviewing
https://crrev.com/c/2467899.

* Use base::SequenceChecker instead of making thread-hostile checks. The
  quota client doesn't need to run on the IO thread, it just needs to
  run on the same sequence as NativeIOContext.

* Replace the deprecated DISALLOW_COPY_AND_ASSIGN() macro with deleted
  copy constructor and assignment operator.

* Remove qualifier (storage::QuotaClient::) from QuotaClient callback
  types. This reduces churn when QuotaClient becomes a mojo interface.

* Remove unused GetClientTypeFromOwner() declaration.

* Remove self-#include in header.

No functional changes are introduced.

Bug: 1137788, 1016065
Change-Id: I34f59e128e877358d16f197bc6e6f0ac79de5df3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2570318
Commit-Queue: Jarryd Goodman <jarrydg@chromium.org>
Reviewed-by: default avatarJarryd Goodman <jarrydg@chromium.org>
Auto-Submit: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833862}
parent 923ca485
......@@ -3,21 +3,28 @@
// found in the LICENSE file.
#include "content/browser/native_io/native_io_quota_client.h"
#include "base/sequence_checker.h"
#include "content/public/browser/browser_thread.h"
#include "url/origin.h"
namespace content {
NativeIOQuotaClient::NativeIOQuotaClient() = default;
NativeIOQuotaClient::NativeIOQuotaClient() {
// Constructed on the UI thread and used on the IO thread.
DETACH_FROM_SEQUENCE(sequence_checker_);
}
NativeIOQuotaClient::~NativeIOQuotaClient() = default;
NativeIOQuotaClient::~NativeIOQuotaClient() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
void NativeIOQuotaClient::OnQuotaManagerDestroyed() {}
void NativeIOQuotaClient::GetOriginUsage(const url::Origin& origin,
blink::mojom::StorageType type,
GetOriginUsageCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, blink::mojom::StorageType::kTemporary);
// TODO(crbug.com/1137788): Implement quota accounting.
......@@ -28,7 +35,7 @@ void NativeIOQuotaClient::GetOriginUsage(const url::Origin& origin,
void NativeIOQuotaClient::GetOriginsForType(
blink::mojom::StorageType type,
GetOriginsForTypeCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, blink::mojom::StorageType::kTemporary);
std::vector<url::Origin> origins;
......@@ -40,7 +47,7 @@ void NativeIOQuotaClient::GetOriginsForHost(
blink::mojom::StorageType type,
const std::string& host,
GetOriginsForHostCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, blink::mojom::StorageType::kTemporary);
std::vector<url::Origin> origins;
......@@ -51,7 +58,7 @@ void NativeIOQuotaClient::GetOriginsForHost(
void NativeIOQuotaClient::DeleteOriginData(const url::Origin& origin,
blink::mojom::StorageType type,
DeleteOriginDataCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, blink::mojom::StorageType::kTemporary);
// TODO(crbug.com/1137788): Implement quota accounting.
......@@ -61,6 +68,8 @@ void NativeIOQuotaClient::DeleteOriginData(const url::Origin& origin,
void NativeIOQuotaClient::PerformStorageCleanup(
blink::mojom::StorageType type,
PerformStorageCleanupCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// TODO(crbug.com/1137788): Implement quota accounting.
std::move(callback).Run();
}
......
......@@ -5,9 +5,7 @@
#ifndef CONTENT_BROWSER_NATIVE_IO_NATIVE_IO_QUOTA_CLIENT_H_
#define CONTENT_BROWSER_NATIVE_IO_NATIVE_IO_QUOTA_CLIENT_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "content/browser/native_io/native_io_quota_client.h"
#include "base/sequence_checker.h"
#include "content/common/content_export.h"
#include "storage/browser/quota/quota_client.h"
#include "storage/browser/quota/quota_client_type.h"
......@@ -26,6 +24,9 @@ class CONTENT_EXPORT NativeIOQuotaClient : public storage::QuotaClient {
public:
NativeIOQuotaClient();
NativeIOQuotaClient(const NativeIOQuotaClient&) = delete;
NativeIOQuotaClient& operator=(const NativeIOQuotaClient&) = delete;
// QuotaClient.
void OnQuotaManagerDestroyed() override;
void GetOriginUsage(const url::Origin& origin,
......@@ -36,19 +37,16 @@ class CONTENT_EXPORT NativeIOQuotaClient : public storage::QuotaClient {
void GetOriginsForHost(blink::mojom::StorageType type,
const std::string& host,
GetOriginsForHostCallback callback) override;
void DeleteOriginData(
const url::Origin& origin,
blink::mojom::StorageType type,
storage::QuotaClient::DeleteOriginDataCallback callback) override;
void DeleteOriginData(const url::Origin& origin,
blink::mojom::StorageType type,
DeleteOriginDataCallback callback) override;
void PerformStorageCleanup(blink::mojom::StorageType type,
PerformStorageCleanupCallback callback) override;
static storage::QuotaClientType GetClientTypeFromOwner(NativeIOOwner owner);
private:
~NativeIOQuotaClient() override;
DISALLOW_COPY_AND_ASSIGN(NativeIOQuotaClient);
SEQUENCE_CHECKER(sequence_checker_);
};
} // namespace content
......
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