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 @@ ...@@ -11,6 +11,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/check.h" #include "base/check.h"
#include "base/sequence_checker.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
...@@ -75,17 +76,23 @@ IndexedDBQuotaClient::IndexedDBQuotaClient( ...@@ -75,17 +76,23 @@ IndexedDBQuotaClient::IndexedDBQuotaClient(
scoped_refptr<IndexedDBContextImpl> indexed_db_context) scoped_refptr<IndexedDBContextImpl> indexed_db_context)
: indexed_db_context_(std::move(indexed_db_context)) { : indexed_db_context_(std::move(indexed_db_context)) {
DCHECK(indexed_db_context_.get()); 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, void IndexedDBQuotaClient::GetOriginUsage(const url::Origin& origin,
StorageType type, StorageType type,
GetOriginUsageCallback callback) { GetOriginUsageCallback callback) {
DCHECK(!callback.is_null()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary); DCHECK_EQ(type, StorageType::kTemporary);
DCHECK(!callback.is_null());
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
indexed_db_context_->IDBTaskRunner(), FROM_HERE, indexed_db_context_->IDBTaskRunner(), FROM_HERE,
...@@ -97,8 +104,9 @@ void IndexedDBQuotaClient::GetOriginUsage(const url::Origin& origin, ...@@ -97,8 +104,9 @@ void IndexedDBQuotaClient::GetOriginUsage(const url::Origin& origin,
void IndexedDBQuotaClient::GetOriginsForType( void IndexedDBQuotaClient::GetOriginsForType(
StorageType type, StorageType type,
GetOriginsForTypeCallback callback) { GetOriginsForTypeCallback callback) {
DCHECK(!callback.is_null()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary); DCHECK_EQ(type, StorageType::kTemporary);
DCHECK(!callback.is_null());
auto* origins_to_return = new std::vector<url::Origin>(); auto* origins_to_return = new std::vector<url::Origin>();
indexed_db_context_->IDBTaskRunner()->PostTaskAndReply( indexed_db_context_->IDBTaskRunner()->PostTaskAndReply(
...@@ -114,8 +122,9 @@ void IndexedDBQuotaClient::GetOriginsForHost( ...@@ -114,8 +122,9 @@ void IndexedDBQuotaClient::GetOriginsForHost(
StorageType type, StorageType type,
const std::string& host, const std::string& host,
GetOriginsForHostCallback callback) { GetOriginsForHostCallback callback) {
DCHECK(!callback.is_null()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary); DCHECK_EQ(type, StorageType::kTemporary);
DCHECK(!callback.is_null());
auto* origins_to_return = new std::vector<url::Origin>(); auto* origins_to_return = new std::vector<url::Origin>();
indexed_db_context_->IDBTaskRunner()->PostTaskAndReply( indexed_db_context_->IDBTaskRunner()->PostTaskAndReply(
...@@ -130,8 +139,9 @@ void IndexedDBQuotaClient::GetOriginsForHost( ...@@ -130,8 +139,9 @@ void IndexedDBQuotaClient::GetOriginsForHost(
void IndexedDBQuotaClient::DeleteOriginData(const url::Origin& origin, void IndexedDBQuotaClient::DeleteOriginData(const url::Origin& origin,
StorageType type, StorageType type,
DeleteOriginDataCallback callback) { DeleteOriginDataCallback callback) {
DCHECK(!callback.is_null()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary); DCHECK_EQ(type, StorageType::kTemporary);
DCHECK(!callback.is_null());
indexed_db_context_->IDBTaskRunner()->PostTask( indexed_db_context_->IDBTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
...@@ -145,6 +155,8 @@ void IndexedDBQuotaClient::DeleteOriginData(const url::Origin& origin, ...@@ -145,6 +155,8 @@ void IndexedDBQuotaClient::DeleteOriginData(const url::Origin& origin,
void IndexedDBQuotaClient::PerformStorageCleanup( void IndexedDBQuotaClient::PerformStorageCleanup(
blink::mojom::StorageType type, blink::mojom::StorageType type,
PerformStorageCleanupCallback callback) { PerformStorageCleanupCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(type, StorageType::kTemporary);
std::move(callback).Run(); std::move(callback).Run();
} }
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
#include <set> #include <set>
#include <string> #include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/sequence_checker.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"
...@@ -23,12 +23,16 @@ class IndexedDBContextImpl; ...@@ -23,12 +23,16 @@ class IndexedDBContextImpl;
// Integrates IndexedDB with the quota management system. // 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 { class IndexedDBQuotaClient : public storage::QuotaClient {
public: public:
CONTENT_EXPORT explicit IndexedDBQuotaClient( CONTENT_EXPORT explicit IndexedDBQuotaClient(
scoped_refptr<IndexedDBContextImpl> indexed_db_context); scoped_refptr<IndexedDBContextImpl> indexed_db_context);
IndexedDBQuotaClient(const IndexedDBQuotaClient&) = delete;
IndexedDBQuotaClient& operator=(const IndexedDBQuotaClient&) = delete;
// QuotaClient implementation: // QuotaClient implementation:
void OnQuotaManagerDestroyed() override; void OnQuotaManagerDestroyed() override;
void GetOriginUsage(const url::Origin& origin, void GetOriginUsage(const url::Origin& origin,
...@@ -50,7 +54,7 @@ class IndexedDBQuotaClient : public storage::QuotaClient { ...@@ -50,7 +54,7 @@ class IndexedDBQuotaClient : public storage::QuotaClient {
const scoped_refptr<IndexedDBContextImpl> indexed_db_context_; const scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
DISALLOW_COPY_AND_ASSIGN(IndexedDBQuotaClient); SEQUENCE_CHECKER(sequence_checker_);
}; };
} // namespace content } // 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