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

IndexedDB: Add sequence checks to IndexedDBQuotaClient.

Change-Id: I36ed7cf8876168e6da5e0e68ae364c2dc33560d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2587832
Auto-Submit: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarJarryd Goodman <jarrydg@chromium.org>
Commit-Queue: Jarryd Goodman <jarrydg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836498}
parent 6ec6cea9
......@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/check.h"
#include "base/sequence_checker.h"
#include "base/task/post_task.h"
#include "base/task_runner_util.h"
#include "base/threading/sequenced_task_runner_handle.h"
......@@ -75,17 +76,23 @@ IndexedDBQuotaClient::IndexedDBQuotaClient(
scoped_refptr<IndexedDBContextImpl> indexed_db_context)
: indexed_db_context_(std::move(indexed_db_context)) {
DCHECK(indexed_db_context_.get());
DETACH_FROM_SEQUENCE(sequence_checker_);
}
IndexedDBQuotaClient::~IndexedDBQuotaClient() = default;
IndexedDBQuotaClient::~IndexedDBQuotaClient() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
void IndexedDBQuotaClient::OnQuotaManagerDestroyed() {}
void IndexedDBQuotaClient::OnQuotaManagerDestroyed() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
void IndexedDBQuotaClient::GetOriginUsage(const url::Origin& origin,
StorageType type,
GetOriginUsageCallback callback) {
DCHECK(!callback.is_null());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary);
DCHECK(!callback.is_null());
base::PostTaskAndReplyWithResult(
indexed_db_context_->IDBTaskRunner(), FROM_HERE,
......@@ -97,8 +104,9 @@ void IndexedDBQuotaClient::GetOriginUsage(const url::Origin& origin,
void IndexedDBQuotaClient::GetOriginsForType(
StorageType type,
GetOriginsForTypeCallback callback) {
DCHECK(!callback.is_null());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary);
DCHECK(!callback.is_null());
auto* origins_to_return = new std::vector<url::Origin>();
indexed_db_context_->IDBTaskRunner()->PostTaskAndReply(
......@@ -114,8 +122,9 @@ void IndexedDBQuotaClient::GetOriginsForHost(
StorageType type,
const std::string& host,
GetOriginsForHostCallback callback) {
DCHECK(!callback.is_null());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary);
DCHECK(!callback.is_null());
auto* origins_to_return = new std::vector<url::Origin>();
indexed_db_context_->IDBTaskRunner()->PostTaskAndReply(
......@@ -130,8 +139,9 @@ void IndexedDBQuotaClient::GetOriginsForHost(
void IndexedDBQuotaClient::DeleteOriginData(const url::Origin& origin,
StorageType type,
DeleteOriginDataCallback callback) {
DCHECK(!callback.is_null());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary);
DCHECK(!callback.is_null());
indexed_db_context_->IDBTaskRunner()->PostTask(
FROM_HERE,
......@@ -145,6 +155,8 @@ void IndexedDBQuotaClient::DeleteOriginData(const url::Origin& origin,
void IndexedDBQuotaClient::PerformStorageCleanup(
blink::mojom::StorageType type,
PerformStorageCleanupCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary);
std::move(callback).Run();
}
......
......@@ -8,9 +8,9 @@
#include <set>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.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"
......@@ -23,12 +23,16 @@ class IndexedDBContextImpl;
// Integrates IndexedDB with the quota management system.
//
// This interface is used on the IO thread by the quota manager.
// Instances are constructed on the UI thread, and then exclusively used on the
// IO thread by the quota system.
class IndexedDBQuotaClient : public storage::QuotaClient {
public:
CONTENT_EXPORT explicit IndexedDBQuotaClient(
scoped_refptr<IndexedDBContextImpl> indexed_db_context);
IndexedDBQuotaClient(const IndexedDBQuotaClient&) = delete;
IndexedDBQuotaClient& operator=(const IndexedDBQuotaClient&) = delete;
// QuotaClient implementation:
void OnQuotaManagerDestroyed() override;
void GetOriginUsage(const url::Origin& origin,
......@@ -50,7 +54,7 @@ class IndexedDBQuotaClient : public storage::QuotaClient {
const scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
DISALLOW_COPY_AND_ASSIGN(IndexedDBQuotaClient);
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