0

[Code Health] Remove a use of base::SupportsWeakPtr. (storage)

This CL replaces the base class with a base::WeakPtrFactory data
member and an accessor member function.

Bug: 40485134
Change-Id: I4a6f88fe209938019eba454f06c6aee2b8faaf57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5578738
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Auto-Submit: David Bertoni <dbertoni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1307507}
This commit is contained in:
David Bertoni
2024-05-29 16:54:25 +00:00
committed by Chromium LUCI CQ
parent 02c2fb8369
commit c80b56b95c
2 changed files with 13 additions and 5 deletions

@ -7,6 +7,9 @@
namespace storage {
MockBlobRegistryDelegate::MockBlobRegistryDelegate() = default;
MockBlobRegistryDelegate::~MockBlobRegistryDelegate() = default;
bool MockBlobRegistryDelegate::CanReadFile(const base::FilePath& file) {
return can_read_file_result;
}

@ -10,18 +10,23 @@
namespace storage {
class MockBlobRegistryDelegate
: public BlobRegistryImpl::Delegate,
public base::SupportsWeakPtr<MockBlobRegistryDelegate> {
class MockBlobRegistryDelegate final : public BlobRegistryImpl::Delegate {
public:
MockBlobRegistryDelegate() = default;
~MockBlobRegistryDelegate() override = default;
MockBlobRegistryDelegate();
~MockBlobRegistryDelegate() override;
bool CanReadFile(const base::FilePath& file) override;
bool CanAccessDataForOrigin(const url::Origin& origin) override;
bool can_read_file_result = true;
bool can_access_data_for_origin = true;
base::WeakPtr<MockBlobRegistryDelegate> AsWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
private:
base::WeakPtrFactory<MockBlobRegistryDelegate> weak_ptr_factory_{this};
};
} // namespace storage