Commit 30058f2c authored by Jarryd's avatar Jarryd Committed by Commit Bot

Quota: Remove manual deletion logic from QuotaManager.

QuotaManager currently uses a custom deleter that ensures the deletion happens on the IO thread. This CL removes the custom logic, and instead
has QuotaManager inherit from RefCountedDeleteOnSequence.

This CL was previously submitted with https://crrev.com/c/1479302 as d82ad3d0. It is currently broken up to
minimize the impact of a potential revert.

Change-Id: If39890da03f577771b31faf71a1ae479ca11cc9d
Reviewed-on: https://chromium-review.googlesource.com/c/1481591
Commit-Queue: Jarryd Goodman <jarrydg@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635213}
parent 67685b76
......@@ -879,12 +879,13 @@ QuotaManager::QuotaManager(
scoped_refptr<base::SingleThreadTaskRunner> io_thread,
scoped_refptr<SpecialStoragePolicy> special_storage_policy,
const GetQuotaSettingsFunc& get_settings_function)
: is_incognito_(is_incognito),
: RefCountedDeleteOnSequence<QuotaManager>(io_thread),
is_incognito_(is_incognito),
profile_path_(profile_path),
proxy_(new QuotaManagerProxy(this, io_thread)),
db_disabled_(false),
eviction_disabled_(false),
io_thread_(std::move(io_thread)),
io_thread_(io_thread),
db_runner_(base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::USER_VISIBLE,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN})),
......@@ -1796,14 +1797,6 @@ void QuotaManager::DidDatabaseWork(bool success) {
db_disabled_ = !success;
}
void QuotaManager::DeleteOnCorrectThread() const {
if (!io_thread_->BelongsToCurrentThread() &&
io_thread_->DeleteSoon(FROM_HERE, this)) {
return;
}
delete this;
}
void QuotaManager::PostTaskAndReplyWithResultForDBThread(
const base::Location& from_here,
base::OnceCallback<bool(QuotaDatabase*)> task,
......
......@@ -21,6 +21,7 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_delete_on_sequence.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/sequence_checker.h"
......@@ -108,7 +109,7 @@ struct UsageInfo {
class COMPONENT_EXPORT(STORAGE_BROWSER) QuotaManager
: public QuotaTaskObserver,
public QuotaEvictionHandler,
public base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter> {
public base::RefCountedDeleteOnSequence<QuotaManager> {
public:
using UsageAndQuotaCallback = base::OnceCallback<
void(blink::mojom::QuotaStatusCode, int64_t usage, int64_t quota)>;
......@@ -265,7 +266,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) QuotaManager
private:
friend class base::DeleteHelper<QuotaManager>;
friend class base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter>;
friend class base::RefCountedDeleteOnSequence<QuotaManager>;
friend class content::QuotaManagerTest;
friend class content::StorageMonitorTest;
friend class content::MockQuotaManager;
......@@ -487,12 +488,6 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) QuotaManager
DISALLOW_COPY_AND_ASSIGN(QuotaManager);
};
struct QuotaManagerDeleter {
static void Destruct(const QuotaManager* manager) {
manager->DeleteOnCorrectThread();
}
};
} // namespace storage
#endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_
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