Quota: Cleanup StorageType from QuotaManagerProxy::RegisterClient
This change removes StorageType param from QuotaManagerProxy::RegisterClient. After StorageType::kSyncable deprecation, all other storage types except kTemporary are deprecated. So we no longer need to specify StorageType. As a side-effect there is also clean-up in BrowsingDataQuotaHelper to no longer collect syncable usage. No storage data is associated with Syncable type now and will always return 0. Further StorageType cleanup from QuotaManager/QuotaDatabase will be done in a follow-up change. Bug: 40211051 Change-Id: I70cb64c7b270def02d8b539a77498eba208b1e4a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6309405 Reviewed-by: Bo Liu <boliu@chromium.org> Reviewed-by: Martin Šrámek <msramek@chromium.org> Reviewed-by: Tsuyoshi Horo <horo@chromium.org> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Reviewed-by: Nasko Oskov <nasko@chromium.org> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org> Commit-Queue: Ayu Ishii <ayui@chromium.org> Cr-Commit-Position: refs/heads/main@{#1429075}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
bb84cecb6e
commit
baef7c60e6
chrome/browser
components/browsing_data/content
browsing_data_model.ccbrowsing_data_quota_helper.ccbrowsing_data_quota_helper.hbrowsing_data_quota_helper_impl.ccbrowsing_data_quota_helper_impl.hbrowsing_data_quota_helper_unittest.ccmock_browsing_data_quota_helper.ccmock_browsing_data_quota_helper.h
content
browser
background_fetch
cache_storage
indexed_db
service_worker
storage_partition_impl.ccstorage_partition_impl_unittest.ccpublic
browser
storage/browser
@ -97,8 +97,9 @@ void SiteDataSizeCollector::OnQuotaModelInfoLoaded(
|
||||
const QuotaStorageUsageInfoList& quota_storage_info_list) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
int64_t total_size = 0;
|
||||
for (const auto& quota_info : quota_storage_info_list)
|
||||
total_size += quota_info.temporary_usage + quota_info.syncable_usage;
|
||||
for (const auto& quota_info : quota_storage_info_list) {
|
||||
total_size += quota_info.usage;
|
||||
}
|
||||
OnStorageSizeFetched(total_size);
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,7 @@ void GetProgressiveWebAppSizeJob::OnQuotaModelInfoLoaded(
|
||||
// TODO(crbug.com/40214522): Optimise the computation of the following loop.
|
||||
for (const auto& quota_info : quota_storage_info_list) {
|
||||
if (origin_ == quota_info.storage_key.origin()) {
|
||||
browsing_data_size_ +=
|
||||
quota_info.temporary_usage + quota_info.syncable_usage;
|
||||
browsing_data_size_ += quota_info.usage;
|
||||
}
|
||||
}
|
||||
debug_value_->Set("data_size_in_bytes", base::ToString(browsing_data_size_));
|
||||
|
@ -271,13 +271,8 @@ void StorageRemoverHelper::Visitor::operator()<blink::StorageKey>(
|
||||
}
|
||||
|
||||
if (types.Has(BrowsingDataModel::StorageType::kQuotaStorage)) {
|
||||
const blink::mojom::StorageType quota_types[] = {
|
||||
blink::mojom::StorageType::kTemporary,
|
||||
blink::mojom::StorageType::kSyncable};
|
||||
for (auto type : quota_types) {
|
||||
helper->quota_helper_->DeleteStorageKeyData(
|
||||
storage_key, type, helper->GetCompleteCallback());
|
||||
}
|
||||
helper->quota_helper_->DeleteStorageKeyData(storage_key,
|
||||
helper->GetCompleteCallback());
|
||||
}
|
||||
|
||||
if (types.Has(BrowsingDataModel::StorageType::kLocalStorage)) {
|
||||
@ -519,7 +514,7 @@ void OnQuotaStorageLoaded(
|
||||
for (const auto& entry : quota_info) {
|
||||
model->AddBrowsingData(entry.storage_key,
|
||||
BrowsingDataModel::StorageType::kQuotaStorage,
|
||||
entry.syncable_usage + entry.temporary_usage);
|
||||
entry.usage);
|
||||
}
|
||||
std::move(loaded_callback).Run();
|
||||
}
|
||||
|
@ -16,11 +16,8 @@ BrowsingDataQuotaHelper::QuotaInfo::QuotaInfo(
|
||||
|
||||
BrowsingDataQuotaHelper::QuotaInfo::QuotaInfo(
|
||||
const blink::StorageKey& storage_key,
|
||||
int64_t temporary_usage,
|
||||
int64_t syncable_usage)
|
||||
: storage_key(storage_key),
|
||||
temporary_usage(temporary_usage),
|
||||
syncable_usage(syncable_usage) {}
|
||||
int64_t usage)
|
||||
: storage_key(storage_key), usage(usage) {}
|
||||
|
||||
BrowsingDataQuotaHelper::QuotaInfo::~QuotaInfo() = default;
|
||||
|
||||
@ -36,12 +33,10 @@ BrowsingDataQuotaHelper::~BrowsingDataQuotaHelper() = default;
|
||||
|
||||
bool BrowsingDataQuotaHelper::QuotaInfo::operator<(
|
||||
const BrowsingDataQuotaHelper::QuotaInfo& rhs) const {
|
||||
return std::tie(storage_key, temporary_usage, syncable_usage) <
|
||||
std::tie(rhs.storage_key, rhs.temporary_usage, rhs.syncable_usage);
|
||||
return std::tie(storage_key, usage) < std::tie(rhs.storage_key, rhs.usage);
|
||||
}
|
||||
|
||||
bool BrowsingDataQuotaHelper::QuotaInfo::operator==(
|
||||
const BrowsingDataQuotaHelper::QuotaInfo& rhs) const {
|
||||
return std::tie(storage_key, temporary_usage, syncable_usage) ==
|
||||
std::tie(rhs.storage_key, rhs.temporary_usage, rhs.syncable_usage);
|
||||
return std::tie(storage_key, usage) == std::tie(rhs.storage_key, rhs.usage);
|
||||
}
|
||||
|
@ -44,9 +44,7 @@ class BrowsingDataQuotaHelper
|
||||
struct QuotaInfo {
|
||||
QuotaInfo();
|
||||
explicit QuotaInfo(const blink::StorageKey& storage_key);
|
||||
QuotaInfo(const blink::StorageKey& storage_key,
|
||||
int64_t temporary_usage,
|
||||
int64_t syncable_usage);
|
||||
QuotaInfo(const blink::StorageKey& storage_key, int64_t usage);
|
||||
~QuotaInfo();
|
||||
|
||||
// Certain versions of MSVC 2008 have bad implementations of ADL for nested
|
||||
@ -56,8 +54,7 @@ class BrowsingDataQuotaHelper
|
||||
bool operator==(const QuotaInfo& rhs) const;
|
||||
|
||||
blink::StorageKey storage_key;
|
||||
int64_t temporary_usage = 0;
|
||||
int64_t syncable_usage = 0;
|
||||
int64_t usage = 0;
|
||||
};
|
||||
|
||||
using QuotaInfoArray = std::list<QuotaInfo>;
|
||||
@ -72,7 +69,6 @@ class BrowsingDataQuotaHelper
|
||||
virtual void StartFetching(FetchResultCallback callback) = 0;
|
||||
|
||||
virtual void DeleteStorageKeyData(const blink::StorageKey& storage_key,
|
||||
blink::mojom::StorageType type,
|
||||
base::OnceClosure completed) = 0;
|
||||
|
||||
protected:
|
||||
|
@ -44,14 +44,13 @@ void BrowsingDataQuotaHelperImpl::StartFetching(FetchResultCallback callback) {
|
||||
|
||||
void BrowsingDataQuotaHelperImpl::DeleteStorageKeyData(
|
||||
const blink::StorageKey& storage_key,
|
||||
blink::mojom::StorageType type,
|
||||
base::OnceClosure completed) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
content::GetIOThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(
|
||||
&BrowsingDataQuotaHelperImpl::DeleteStorageKeyDataOnIOThread, this,
|
||||
storage_key, type, std::move(completed)));
|
||||
storage_key, std::move(completed)));
|
||||
}
|
||||
|
||||
BrowsingDataQuotaHelperImpl::BrowsingDataQuotaHelperImpl(
|
||||
@ -66,30 +65,15 @@ void BrowsingDataQuotaHelperImpl::FetchQuotaInfoOnIOThread(
|
||||
FetchResultCallback callback) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
|
||||
const StorageType types[] = {StorageType::kTemporary, StorageType::kSyncable};
|
||||
|
||||
// Query storage keys for each storage types. When complete, process the
|
||||
// collected quota info.
|
||||
QuotaInfoMap* quota_info = new QuotaInfoMap();
|
||||
|
||||
base::RepeatingClosure completion = base::BarrierClosure(
|
||||
std::size(types),
|
||||
base::BindOnce(&BrowsingDataQuotaHelperImpl::OnGetHostsUsageComplete,
|
||||
weak_factory_.GetWeakPtr(), std::move(callback),
|
||||
base::Owned(quota_info)));
|
||||
|
||||
for (const StorageType& type : types) {
|
||||
quota_manager_->GetStorageKeysForType(
|
||||
type, base::BindOnce(&BrowsingDataQuotaHelperImpl::GotStorageKeys,
|
||||
weak_factory_.GetWeakPtr(), quota_info, completion,
|
||||
type));
|
||||
}
|
||||
// Query for storage keys. When complete, process the collected quota info.
|
||||
quota_manager_->GetStorageKeysForType(
|
||||
StorageType::kTemporary,
|
||||
base::BindOnce(&BrowsingDataQuotaHelperImpl::GotStorageKeys,
|
||||
weak_factory_.GetWeakPtr(), std::move(callback)));
|
||||
}
|
||||
|
||||
void BrowsingDataQuotaHelperImpl::GotStorageKeys(
|
||||
QuotaInfoMap* quota_info,
|
||||
base::OnceClosure completion,
|
||||
StorageType type,
|
||||
FetchResultCallback callback,
|
||||
const std::set<blink::StorageKey>& storage_keys) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
int storage_key_count = std::ranges::count_if(
|
||||
@ -97,38 +81,32 @@ void BrowsingDataQuotaHelperImpl::GotStorageKeys(
|
||||
return browsing_data::IsWebScheme(storage_key.origin().scheme());
|
||||
});
|
||||
|
||||
auto storage_key_completion =
|
||||
base::BarrierClosure(storage_key_count, std::move(completion));
|
||||
QuotaInfoMap* quota_info = new QuotaInfoMap();
|
||||
base::RepeatingClosure completion = base::BarrierClosure(
|
||||
storage_key_count,
|
||||
base::BindOnce(&BrowsingDataQuotaHelperImpl::OnGetHostsUsageComplete,
|
||||
weak_factory_.GetWeakPtr(), std::move(callback),
|
||||
base::Owned(quota_info)));
|
||||
|
||||
for (const blink::StorageKey& storage_key : storage_keys) {
|
||||
if (!browsing_data::IsWebScheme(storage_key.origin().scheme())) {
|
||||
continue; // Non-websafe state is not considered browsing data.
|
||||
}
|
||||
quota_manager_->GetStorageKeyUsageWithBreakdown(
|
||||
storage_key, type,
|
||||
storage_key, StorageType::kTemporary,
|
||||
base::BindOnce(&BrowsingDataQuotaHelperImpl::GotStorageKeyUsage,
|
||||
weak_factory_.GetWeakPtr(), quota_info, storage_key,
|
||||
type)
|
||||
.Then(storage_key_completion));
|
||||
weak_factory_.GetWeakPtr(), quota_info, storage_key)
|
||||
.Then(completion));
|
||||
}
|
||||
}
|
||||
|
||||
void BrowsingDataQuotaHelperImpl::GotStorageKeyUsage(
|
||||
QuotaInfoMap* quota_info,
|
||||
const blink::StorageKey& storage_key,
|
||||
StorageType type,
|
||||
int64_t usage,
|
||||
blink::mojom::UsageBreakdownPtr usage_breakdown) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
switch (type) {
|
||||
case StorageType::kTemporary:
|
||||
(*quota_info)[storage_key].temporary_usage += usage;
|
||||
break;
|
||||
case StorageType::kSyncable:
|
||||
(*quota_info)[storage_key].syncable_usage += usage;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
(*quota_info)[storage_key].usage = usage;
|
||||
}
|
||||
|
||||
void BrowsingDataQuotaHelperImpl::OnGetHostsUsageComplete(
|
||||
@ -149,11 +127,10 @@ void BrowsingDataQuotaHelperImpl::OnGetHostsUsageComplete(
|
||||
|
||||
void BrowsingDataQuotaHelperImpl::DeleteStorageKeyDataOnIOThread(
|
||||
const blink::StorageKey& storage_key,
|
||||
blink::mojom::StorageType type,
|
||||
base::OnceClosure completed) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
quota_manager_->DeleteStorageKeyData(
|
||||
storage_key, type,
|
||||
storage_key, StorageType::kTemporary,
|
||||
base::BindOnce(
|
||||
&BrowsingDataQuotaHelperImpl::OnStorageKeyDeletionCompleted,
|
||||
weak_factory_.GetWeakPtr(), std::move(completed)));
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "components/browsing_data/content/browsing_data_quota_helper.h"
|
||||
#include "third_party/blink/public/mojom/quota/quota_types.mojom-forward.h"
|
||||
|
||||
namespace blink {
|
||||
class StorageKey;
|
||||
@ -34,7 +33,6 @@ class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper {
|
||||
public:
|
||||
void StartFetching(FetchResultCallback callback) override;
|
||||
void DeleteStorageKeyData(const blink::StorageKey& storage_key,
|
||||
blink::mojom::StorageType type,
|
||||
base::OnceClosure completed) override;
|
||||
|
||||
explicit BrowsingDataQuotaHelperImpl(storage::QuotaManager* quota_manager);
|
||||
@ -54,15 +52,12 @@ class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper {
|
||||
void FetchQuotaInfoOnIOThread(FetchResultCallback callback);
|
||||
|
||||
// Callback function for QuotaManager::GetStorageKeysForType.
|
||||
void GotStorageKeys(QuotaInfoMap* quota_info,
|
||||
base::OnceClosure completion,
|
||||
blink::mojom::StorageType type,
|
||||
void GotStorageKeys(FetchResultCallback callback,
|
||||
const std::set<blink::StorageKey>& storage_keys);
|
||||
|
||||
// Callback function for QuotaManager::GetStorageKeyUsage.
|
||||
void GotStorageKeyUsage(QuotaInfoMap* quota_info,
|
||||
const blink::StorageKey& storage_key,
|
||||
blink::mojom::StorageType type,
|
||||
int64_t usage,
|
||||
blink::mojom::UsageBreakdownPtr usage_breakdown);
|
||||
|
||||
@ -71,7 +66,6 @@ class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper {
|
||||
QuotaInfoMap* quota_info);
|
||||
|
||||
void DeleteStorageKeyDataOnIOThread(const blink::StorageKey& storage_key,
|
||||
blink::mojom::StorageType type,
|
||||
base::OnceClosure completed);
|
||||
|
||||
void OnStorageKeyDeletionCompleted(base::OnceClosure completed,
|
||||
|
@ -27,15 +27,11 @@
|
||||
#include "storage/browser/quota/quota_manager_proxy.h"
|
||||
#include "storage/browser/test/mock_quota_client.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
|
||||
|
||||
using blink::mojom::StorageType;
|
||||
|
||||
namespace {
|
||||
|
||||
struct ClientDefaultBucketData {
|
||||
const char* origin;
|
||||
StorageType type;
|
||||
int64_t usage;
|
||||
};
|
||||
|
||||
@ -97,17 +93,15 @@ class BrowsingDataQuotaHelperTest : public testing::Test {
|
||||
// bucket usage retrieval happens after MockQuotaClient is ready.
|
||||
quota_manager_->SetBootstrapDisabledForTesting(true);
|
||||
quota_manager_->proxy()->RegisterClient(
|
||||
std::move(quota_client), storage::QuotaClientType::kFileSystem,
|
||||
{blink::mojom::StorageType::kTemporary,
|
||||
blink::mojom::StorageType::kSyncable});
|
||||
std::move(quota_client), storage::QuotaClientType::kFileSystem);
|
||||
|
||||
std::map<storage::BucketLocator, int64_t> buckets_data;
|
||||
for (const ClientDefaultBucketData& data : storage_key_data) {
|
||||
base::test::TestFuture<storage::QuotaErrorOr<storage::BucketInfo>> future;
|
||||
quota_manager_->GetOrCreateBucketDeprecated(
|
||||
quota_manager_->UpdateOrCreateBucket(
|
||||
storage::BucketInitParams::ForDefaultBucket(
|
||||
blink::StorageKey::CreateFromStringForTesting(data.origin)),
|
||||
data.type, future.GetCallback());
|
||||
future.GetCallback());
|
||||
ASSERT_OK_AND_ASSIGN(auto bucket, future.Take());
|
||||
buckets_data.insert(std::pair<storage::BucketLocator, int64_t>(
|
||||
bucket.ToBucketLocator(), data.usage));
|
||||
@ -145,10 +139,9 @@ TEST_F(BrowsingDataQuotaHelperTest, Empty) {
|
||||
|
||||
TEST_F(BrowsingDataQuotaHelperTest, FetchData) {
|
||||
static const ClientDefaultBucketData kStorageKeys[] = {
|
||||
{"http://example.com/", StorageType::kTemporary, 1},
|
||||
{"https://example.com/", StorageType::kTemporary, 10},
|
||||
{"https://example.com/", StorageType::kSyncable, 1},
|
||||
{"http://example2.com/", StorageType::kTemporary, 1000},
|
||||
{"http://example.com/", 1},
|
||||
{"https://example.com/", 10},
|
||||
{"http://example2.com/", 1000},
|
||||
};
|
||||
|
||||
RegisterClient(kStorageKeys);
|
||||
@ -159,28 +152,25 @@ TEST_F(BrowsingDataQuotaHelperTest, FetchData) {
|
||||
std::set<QuotaInfo> expected, actual;
|
||||
actual.insert(quota_info().begin(), quota_info().end());
|
||||
expected.insert(QuotaInfo(
|
||||
blink::StorageKey::CreateFromStringForTesting("http://example.com"), 1,
|
||||
0));
|
||||
blink::StorageKey::CreateFromStringForTesting("http://example.com"), 1));
|
||||
expected.insert(QuotaInfo(
|
||||
blink::StorageKey::CreateFromStringForTesting("http://example2.com"),
|
||||
1000, 0));
|
||||
1000));
|
||||
expected.insert(QuotaInfo(
|
||||
blink::StorageKey::CreateFromStringForTesting("https://example.com"), 10,
|
||||
1));
|
||||
blink::StorageKey::CreateFromStringForTesting("https://example.com"),
|
||||
10));
|
||||
EXPECT_TRUE(expected == actual);
|
||||
}
|
||||
|
||||
TEST_F(BrowsingDataQuotaHelperTest, IgnoreExtensionsAndDevTools) {
|
||||
static const ClientDefaultBucketData kStorageKeys[] = {
|
||||
{"http://example.com/", StorageType::kTemporary, 1},
|
||||
{"https://example.com/", StorageType::kTemporary, 10},
|
||||
{"https://example.com/", StorageType::kSyncable, 1},
|
||||
{"http://example2.com/", StorageType::kTemporary, 1000},
|
||||
{"http://example.com/", 1},
|
||||
{"https://example.com/", 10},
|
||||
{"http://example2.com/", 1000},
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
{"chrome-extension://abcdefghijklmnopqrstuvwxyz/", StorageType::kTemporary,
|
||||
10000},
|
||||
{"chrome-extension://abcdefghijklmnopqrstuvwxyz/", 10000},
|
||||
#endif
|
||||
{"devtools://abcdefghijklmnopqrstuvwxyz/", StorageType::kTemporary, 10000},
|
||||
{"devtools://abcdefghijklmnopqrstuvwxyz/", 10000},
|
||||
};
|
||||
|
||||
RegisterClient(kStorageKeys);
|
||||
@ -191,13 +181,12 @@ TEST_F(BrowsingDataQuotaHelperTest, IgnoreExtensionsAndDevTools) {
|
||||
std::set<QuotaInfo> expected, actual;
|
||||
actual.insert(quota_info().begin(), quota_info().end());
|
||||
expected.insert(QuotaInfo(
|
||||
blink::StorageKey::CreateFromStringForTesting("http://example.com"), 1,
|
||||
0));
|
||||
blink::StorageKey::CreateFromStringForTesting("http://example.com"), 1));
|
||||
expected.insert(QuotaInfo(
|
||||
blink::StorageKey::CreateFromStringForTesting("http://example2.com"),
|
||||
1000, 0));
|
||||
1000));
|
||||
expected.insert(QuotaInfo(
|
||||
blink::StorageKey::CreateFromStringForTesting("https://example.com"), 10,
|
||||
1));
|
||||
blink::StorageKey::CreateFromStringForTesting("https://example.com"),
|
||||
10));
|
||||
EXPECT_TRUE(expected == actual);
|
||||
}
|
||||
|
@ -21,20 +21,18 @@ void MockBrowsingDataQuotaHelper::StartFetching(FetchResultCallback callback) {
|
||||
|
||||
void MockBrowsingDataQuotaHelper::DeleteStorageKeyData(
|
||||
const blink::StorageKey& storage_key,
|
||||
blink::mojom::StorageType type,
|
||||
base::OnceClosure completed) {}
|
||||
|
||||
void MockBrowsingDataQuotaHelper::AddHost(const blink::StorageKey& storage_key,
|
||||
int64_t temporary_usage,
|
||||
int64_t syncable_usage) {
|
||||
response_.push_back(QuotaInfo(storage_key, temporary_usage, syncable_usage));
|
||||
int64_t usage) {
|
||||
response_.emplace_back(storage_key, usage);
|
||||
}
|
||||
|
||||
void MockBrowsingDataQuotaHelper::AddQuotaSamples() {
|
||||
AddHost(blink::StorageKey::CreateFromStringForTesting("http://quotahost1"), 1,
|
||||
1);
|
||||
AddHost(blink::StorageKey::CreateFromStringForTesting("http://quotahost1"),
|
||||
2);
|
||||
AddHost(blink::StorageKey::CreateFromStringForTesting("https://quotahost2"),
|
||||
10, 10);
|
||||
20);
|
||||
}
|
||||
|
||||
void MockBrowsingDataQuotaHelper::Notify() {
|
||||
|
@ -22,12 +22,9 @@ class MockBrowsingDataQuotaHelper : public BrowsingDataQuotaHelper {
|
||||
|
||||
void StartFetching(FetchResultCallback callback) override;
|
||||
void DeleteStorageKeyData(const blink::StorageKey& storage_key,
|
||||
blink::mojom::StorageType type,
|
||||
base::OnceClosure completed) override;
|
||||
|
||||
void AddHost(const blink::StorageKey& storage_key,
|
||||
int64_t temporary_usage,
|
||||
int64_t syncable_usage);
|
||||
void AddHost(const blink::StorageKey& storage_key, int64_t usage);
|
||||
void AddQuotaSamples();
|
||||
void Notify();
|
||||
|
||||
|
@ -34,11 +34,8 @@ class MockBGFQuotaManagerProxy : public storage::MockQuotaManagerProxy {
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault().get()) {}
|
||||
|
||||
// Ignore quota client, it is irrelevant for these tests.
|
||||
void RegisterClient(
|
||||
mojo::PendingRemote<storage::mojom::QuotaClient> client,
|
||||
storage::QuotaClientType client_type,
|
||||
const base::flat_set<blink::mojom::StorageType>& storage_types) override {
|
||||
}
|
||||
void RegisterClient(mojo::PendingRemote<storage::mojom::QuotaClient> client,
|
||||
storage::QuotaClientType client_type) override {}
|
||||
|
||||
void GetUsageAndQuota(
|
||||
const blink::StorageKey& storage_key,
|
||||
|
@ -26,8 +26,7 @@ CacheStorageControlWrapper::CacheStorageControlWrapper(
|
||||
cache_storage_client_remote.InitWithNewPipeAndPassReceiver();
|
||||
quota_manager_proxy->RegisterClient(
|
||||
std::move(cache_storage_client_remote),
|
||||
storage::QuotaClientType::kServiceWorkerCache,
|
||||
{blink::mojom::StorageType::kTemporary});
|
||||
storage::QuotaClientType::kServiceWorkerCache);
|
||||
mojo::PendingRemote<storage::mojom::QuotaClient>
|
||||
background_fetch_client_remote;
|
||||
mojo::PendingReceiver<storage::mojom::QuotaClient>
|
||||
@ -35,8 +34,7 @@ CacheStorageControlWrapper::CacheStorageControlWrapper(
|
||||
background_fetch_client_remote.InitWithNewPipeAndPassReceiver();
|
||||
quota_manager_proxy->RegisterClient(
|
||||
std::move(background_fetch_client_remote),
|
||||
storage::QuotaClientType::kBackgroundFetch,
|
||||
{blink::mojom::StorageType::kTemporary});
|
||||
storage::QuotaClientType::kBackgroundFetch);
|
||||
|
||||
cache_storage_context_ = base::SequenceBound<CacheStorageContextImpl>(
|
||||
CacheStorageContextImpl::CreateSchedulerTaskRunner(),
|
||||
|
@ -189,10 +189,8 @@ class MockCacheStorageQuotaManagerProxy
|
||||
base::SingleThreadTaskRunner* task_runner)
|
||||
: MockQuotaManagerProxy(quota_manager, task_runner) {}
|
||||
|
||||
void RegisterClient(
|
||||
mojo::PendingRemote<storage::mojom::QuotaClient> client,
|
||||
storage::QuotaClientType client_type,
|
||||
const base::flat_set<blink::mojom::StorageType>& storage_types) override {
|
||||
void RegisterClient(mojo::PendingRemote<storage::mojom::QuotaClient> client,
|
||||
storage::QuotaClientType client_type) override {
|
||||
registered_clients_.emplace_back(std::move(client));
|
||||
}
|
||||
|
||||
|
@ -247,8 +247,7 @@ IndexedDBContextImpl::IndexedDBContextImpl(
|
||||
quota_client_remote.InitWithNewPipeAndPassReceiver();
|
||||
quota_manager_proxy_->RegisterClient(
|
||||
std::move(quota_client_remote),
|
||||
storage::QuotaClientType::kIndexedDatabase,
|
||||
{blink::mojom::StorageType::kTemporary});
|
||||
storage::QuotaClientType::kIndexedDatabase);
|
||||
IDBTaskRunner()->PostTask(
|
||||
FROM_HERE, base::BindOnce(&IndexedDBContextImpl::BindPipesOnIDBSequence,
|
||||
weak_factory_.GetWeakPtr(),
|
||||
|
@ -340,8 +340,7 @@ ServiceWorkerContextCore::ServiceWorkerContextCore(
|
||||
if (quota_manager_proxy) {
|
||||
quota_manager_proxy->RegisterClient(
|
||||
quota_client_receiver_->BindNewPipeAndPassRemote(),
|
||||
storage::QuotaClientType::kServiceWorker,
|
||||
{blink::mojom::StorageType::kTemporary});
|
||||
storage::QuotaClientType::kServiceWorker);
|
||||
}
|
||||
|
||||
registry_->GetRegisteredStorageKeys(
|
||||
|
@ -2670,9 +2670,8 @@ void StoragePartitionImpl::QuotaManagedDataDeletionHelper::ClearDataOnIOThread(
|
||||
&QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO,
|
||||
base::Unretained(this));
|
||||
|
||||
// Ask the QuotaManager for all buckets with temporary quota modified
|
||||
// within the user-specified timeframe, and deal with the resulting set in
|
||||
// ClearBucketsOnIOThread().
|
||||
// Ask the QuotaManager for all buckets modified within the user-specified
|
||||
// timeframe, and deal with the resulting set in ClearBucketsOnIOThread().
|
||||
if (quota_storage_remove_mask_ & QUOTA_MANAGED_STORAGE_MASK_TEMPORARY) {
|
||||
IncrementTaskCountOnIO();
|
||||
quota_manager->GetBucketsModifiedBetween(
|
||||
@ -2684,18 +2683,6 @@ void StoragePartitionImpl::QuotaManagedDataDeletionHelper::ClearDataOnIOThread(
|
||||
blink::mojom::StorageType::kTemporary));
|
||||
}
|
||||
|
||||
// Do the same for syncable quota.
|
||||
if (quota_storage_remove_mask_ & QUOTA_MANAGED_STORAGE_MASK_SYNCABLE) {
|
||||
IncrementTaskCountOnIO();
|
||||
quota_manager->GetBucketsModifiedBetween(
|
||||
blink::mojom::StorageType::kSyncable, begin, end,
|
||||
base::BindOnce(&QuotaManagedDataDeletionHelper::ClearBucketsOnIOThread,
|
||||
base::Unretained(this), base::RetainedRef(quota_manager),
|
||||
special_storage_policy, std::move(storage_key_matcher),
|
||||
perform_storage_cleanup, decrement_callback,
|
||||
blink::mojom::StorageType::kSyncable));
|
||||
}
|
||||
|
||||
DecrementTaskCountOnIO();
|
||||
}
|
||||
|
||||
|
@ -129,8 +129,6 @@ const char kCacheValue[] = "cached value";
|
||||
|
||||
const blink::mojom::StorageType kTemporary =
|
||||
blink::mojom::StorageType::kTemporary;
|
||||
const blink::mojom::StorageType kSyncable =
|
||||
blink::mojom::StorageType::kSyncable;
|
||||
|
||||
const storage::QuotaClientType kClientFile =
|
||||
storage::QuotaClientType::kFileSystem;
|
||||
@ -648,9 +646,9 @@ void ClearQuotaDataForOrigin(content::StoragePartition* partition,
|
||||
delete_begin, base::Time::Max(), loop_to_quit->QuitClosure());
|
||||
}
|
||||
|
||||
void ClearQuotaDataForTemporary(content::StoragePartition* partition,
|
||||
const base::Time delete_begin,
|
||||
base::RunLoop* loop_to_quit) {
|
||||
void ClearQuotaDataTime(content::StoragePartition* partition,
|
||||
const base::Time delete_begin,
|
||||
base::RunLoop* loop_to_quit) {
|
||||
partition->ClearData(kAllQuotaRemoveMask,
|
||||
StoragePartition::QUOTA_MANAGED_STORAGE_MASK_TEMPORARY,
|
||||
blink::StorageKey(), delete_begin, base::Time::Max(),
|
||||
@ -795,9 +793,7 @@ class StoragePartitionImplTest : public testing::Test {
|
||||
quota_manager_->proxy(), storage::QuotaClientType::kFileSystem),
|
||||
quota_client.InitWithNewPipeAndPassReceiver());
|
||||
quota_manager_->proxy()->RegisterClient(
|
||||
std::move(quota_client), storage::QuotaClientType::kFileSystem,
|
||||
{blink::mojom::StorageType::kTemporary,
|
||||
blink::mojom::StorageType::kSyncable});
|
||||
std::move(quota_client), storage::QuotaClientType::kFileSystem);
|
||||
}
|
||||
return quota_manager_.get();
|
||||
}
|
||||
@ -896,55 +892,24 @@ storage::BucketInfo AddQuotaManagedBucket(
|
||||
storage::MockQuotaManager* manager,
|
||||
const blink::StorageKey& storage_key,
|
||||
const std::string& bucket_name,
|
||||
blink::mojom::StorageType type,
|
||||
base::Time modified = base::Time::Now()) {
|
||||
storage::BucketInfo bucket =
|
||||
manager->CreateBucket({storage_key, bucket_name}, type);
|
||||
manager->CreateBucket({storage_key, bucket_name}, kTemporary);
|
||||
manager->AddBucket(bucket, {kClientFile}, modified);
|
||||
EXPECT_TRUE(manager->BucketHasData(bucket, kClientFile));
|
||||
return bucket;
|
||||
}
|
||||
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverBoth) {
|
||||
const blink::StorageKey kStorageKey1 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host1:1/");
|
||||
const blink::StorageKey kStorageKey2 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host2:1/");
|
||||
const blink::StorageKey kStorageKey3 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host3:1/");
|
||||
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey1,
|
||||
storage::kDefaultBucketName, kTemporary);
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey2,
|
||||
storage::kDefaultBucketName, kTemporary);
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey2,
|
||||
storage::kDefaultBucketName, kSyncable);
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey3,
|
||||
storage::kDefaultBucketName, kSyncable);
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 4);
|
||||
|
||||
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
|
||||
browser_context()->GetDefaultStoragePartition());
|
||||
partition->OverrideQuotaManagerForTesting(GetMockManager());
|
||||
|
||||
base::RunLoop run_loop;
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
|
||||
FROM_HERE, base::BindOnce(&ClearQuotaData, partition, &run_loop));
|
||||
run_loop.Run();
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 0);
|
||||
}
|
||||
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyTemporary) {
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForever) {
|
||||
const blink::StorageKey kStorageKey1 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host1:1/");
|
||||
const blink::StorageKey kStorageKey2 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host2:1/");
|
||||
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey1,
|
||||
storage::kDefaultBucketName, kTemporary);
|
||||
storage::kDefaultBucketName);
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey2,
|
||||
storage::kDefaultBucketName, kTemporary);
|
||||
storage::kDefaultBucketName);
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
|
||||
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
|
||||
@ -959,31 +924,7 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyTemporary) {
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 0);
|
||||
}
|
||||
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlySyncable) {
|
||||
const blink::StorageKey kStorageKey1 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host1:1/");
|
||||
const blink::StorageKey kStorageKey2 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host2:1/");
|
||||
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey1,
|
||||
storage::kDefaultBucketName, kSyncable);
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey2,
|
||||
storage::kDefaultBucketName, kSyncable);
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
|
||||
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
|
||||
browser_context()->GetDefaultStoragePartition());
|
||||
partition->OverrideQuotaManagerForTesting(GetMockManager());
|
||||
|
||||
base::RunLoop run_loop;
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
|
||||
FROM_HERE, base::BindOnce(&ClearQuotaData, partition, &run_loop));
|
||||
run_loop.Run();
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 0);
|
||||
}
|
||||
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverNeither) {
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverNone) {
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 0);
|
||||
|
||||
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
|
||||
@ -1003,19 +944,13 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverSpecificOrigin) {
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host1:1/");
|
||||
const blink::StorageKey kStorageKey2 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host2:1/");
|
||||
const blink::StorageKey kStorageKey3 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host3:1/");
|
||||
|
||||
storage::BucketInfo host1_temp_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey1, storage::kDefaultBucketName, kTemporary);
|
||||
storage::BucketInfo host2_temp_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey2, storage::kDefaultBucketName, kTemporary);
|
||||
storage::BucketInfo host2_sync_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey2, storage::kDefaultBucketName, kSyncable);
|
||||
storage::BucketInfo host3_sync_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey3, storage::kDefaultBucketName, kSyncable);
|
||||
storage::BucketInfo host1_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey1, storage::kDefaultBucketName);
|
||||
storage::BucketInfo host2_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey2, storage::kDefaultBucketName);
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 4);
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
|
||||
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
|
||||
browser_context()->GetDefaultStoragePartition());
|
||||
@ -1028,11 +963,9 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverSpecificOrigin) {
|
||||
kStorageKey1.origin().GetURL(), base::Time(), &run_loop));
|
||||
run_loop.Run();
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 3);
|
||||
EXPECT_FALSE(GetMockManager()->BucketHasData(host1_temp_bucket, kClientFile));
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host2_temp_bucket, kClientFile));
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host2_sync_bucket, kClientFile));
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host3_sync_bucket, kClientFile));
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 1);
|
||||
EXPECT_FALSE(GetMockManager()->BucketHasData(host1_bucket, kClientFile));
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host2_bucket, kClientFile));
|
||||
}
|
||||
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) {
|
||||
@ -1045,30 +978,19 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) {
|
||||
|
||||
// Buckets modified now.
|
||||
base::Time now = base::Time::Now();
|
||||
storage::BucketInfo host1_temp_bucket_now = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey1, "temp_bucket_now", kTemporary, now);
|
||||
storage::BucketInfo host1_sync_bucket_now =
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey1,
|
||||
storage::kDefaultBucketName, kSyncable, now);
|
||||
storage::BucketInfo host2_temp_bucket_now = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey2, "temp_bucket_now", kTemporary, now);
|
||||
storage::BucketInfo host2_sync_bucket_now =
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey2,
|
||||
storage::kDefaultBucketName, kSyncable, now);
|
||||
storage::BucketInfo host1_bucket_now =
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey1, "bucket_now", now);
|
||||
storage::BucketInfo host2_bucket_now =
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey2, "bucket_now", now);
|
||||
|
||||
// Buckets modified a day ago.
|
||||
base::Time yesterday = now - base::Days(1);
|
||||
storage::BucketInfo host1_temp_bucket_yesterday =
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey1,
|
||||
"temp_bucket_yesterday", kTemporary, yesterday);
|
||||
storage::BucketInfo host2_temp_bucket_yesterday =
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey2,
|
||||
"temp_bucket_yesterday", kTemporary, yesterday);
|
||||
storage::BucketInfo host3_sync_bucket_yesterday =
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey3,
|
||||
storage::kDefaultBucketName, kSyncable, yesterday);
|
||||
storage::BucketInfo host1_bucket_yesterday = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey1, "bucket_yesterday", yesterday);
|
||||
storage::BucketInfo host2_bucket_yesterday = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey2, "bucket_yesterday", yesterday);
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 7);
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 4);
|
||||
|
||||
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
|
||||
browser_context()->GetDefaultStoragePartition());
|
||||
@ -1080,44 +1002,31 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) {
|
||||
base::Time::Now() - base::Hours(1), &run_loop));
|
||||
run_loop.Run();
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 3);
|
||||
EXPECT_FALSE(
|
||||
GetMockManager()->BucketHasData(host1_temp_bucket_now, kClientFile));
|
||||
EXPECT_FALSE(
|
||||
GetMockManager()->BucketHasData(host1_sync_bucket_now, kClientFile));
|
||||
EXPECT_FALSE(
|
||||
GetMockManager()->BucketHasData(host2_temp_bucket_now, kClientFile));
|
||||
EXPECT_FALSE(
|
||||
GetMockManager()->BucketHasData(host2_sync_bucket_now, kClientFile));
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host1_temp_bucket_yesterday,
|
||||
kClientFile));
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host3_sync_bucket_yesterday,
|
||||
kClientFile));
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host2_temp_bucket_yesterday,
|
||||
kClientFile));
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
EXPECT_FALSE(GetMockManager()->BucketHasData(host1_bucket_now, kClientFile));
|
||||
EXPECT_FALSE(GetMockManager()->BucketHasData(host2_bucket_now, kClientFile));
|
||||
EXPECT_TRUE(
|
||||
GetMockManager()->BucketHasData(host1_bucket_yesterday, kClientFile));
|
||||
EXPECT_TRUE(
|
||||
GetMockManager()->BucketHasData(host2_bucket_yesterday, kClientFile));
|
||||
}
|
||||
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedTemporaryDataForLastWeek) {
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastWeek) {
|
||||
const blink::StorageKey kStorageKey =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host1:1/");
|
||||
|
||||
// Buckets modified yesterday.
|
||||
base::Time now = base::Time::Now();
|
||||
base::Time yesterday = now - base::Days(1);
|
||||
storage::BucketInfo temp_bucket_yesterday =
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey,
|
||||
"temp_bucket_yesterday", kTemporary, yesterday);
|
||||
storage::BucketInfo sync_bucket_yesterday =
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey,
|
||||
storage::kDefaultBucketName, kSyncable, yesterday);
|
||||
storage::BucketInfo bucket_yesterday = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey, "bucket_yesterday", yesterday);
|
||||
|
||||
// Buckets modified 10 days ago.
|
||||
base::Time ten_days_ago = now - base::Days(10);
|
||||
storage::BucketInfo temp_bucket_ten_days_ago = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey, "temp_bucket_ten_days_ago", kTemporary,
|
||||
ten_days_ago);
|
||||
storage::BucketInfo bucket_ten_days_ago = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey, "bucket_ten_days_ago", ten_days_ago);
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 3);
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
|
||||
base::RunLoop run_loop;
|
||||
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
|
||||
@ -1125,17 +1034,14 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedTemporaryDataForLastWeek) {
|
||||
partition->OverrideQuotaManagerForTesting(GetMockManager());
|
||||
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault()->PostTask(
|
||||
FROM_HERE, base::BindOnce(&ClearQuotaDataForTemporary, partition,
|
||||
FROM_HERE, base::BindOnce(&ClearQuotaDataTime, partition,
|
||||
base::Time::Now() - base::Days(7), &run_loop));
|
||||
run_loop.Run();
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
EXPECT_FALSE(
|
||||
GetMockManager()->BucketHasData(temp_bucket_yesterday, kClientFile));
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 1);
|
||||
EXPECT_FALSE(GetMockManager()->BucketHasData(bucket_yesterday, kClientFile));
|
||||
EXPECT_TRUE(
|
||||
GetMockManager()->BucketHasData(sync_bucket_yesterday, kClientFile));
|
||||
EXPECT_TRUE(
|
||||
GetMockManager()->BucketHasData(temp_bucket_ten_days_ago, kClientFile));
|
||||
GetMockManager()->BucketHasData(bucket_ten_days_ago, kClientFile));
|
||||
}
|
||||
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedUnprotectedOrigins) {
|
||||
@ -1144,16 +1050,12 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedUnprotectedOrigins) {
|
||||
const blink::StorageKey kStorageKey2 =
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host2:1/");
|
||||
|
||||
storage::BucketInfo host1_temp_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey1, storage::kDefaultBucketName, kTemporary);
|
||||
storage::BucketInfo host1_sync_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey1, storage::kDefaultBucketName, kSyncable);
|
||||
storage::BucketInfo host2_temp_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey2, storage::kDefaultBucketName, kTemporary);
|
||||
storage::BucketInfo host2_sync_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey2, storage::kDefaultBucketName, kSyncable);
|
||||
storage::BucketInfo host1_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey1, storage::kDefaultBucketName);
|
||||
storage::BucketInfo host2_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey2, storage::kDefaultBucketName);
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 4);
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
|
||||
// Protect kStorageKey1.
|
||||
auto mock_policy = base::MakeRefCounted<storage::MockSpecialStoragePolicy>();
|
||||
@ -1172,11 +1074,9 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedUnprotectedOrigins) {
|
||||
base::Time(), &run_loop));
|
||||
run_loop.Run();
|
||||
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host1_temp_bucket, kClientFile));
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host1_sync_bucket, kClientFile));
|
||||
EXPECT_FALSE(GetMockManager()->BucketHasData(host2_temp_bucket, kClientFile));
|
||||
EXPECT_FALSE(GetMockManager()->BucketHasData(host2_sync_bucket, kClientFile));
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 1);
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(host1_bucket, kClientFile));
|
||||
EXPECT_FALSE(GetMockManager()->BucketHasData(host2_bucket, kClientFile));
|
||||
}
|
||||
|
||||
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedOrigins) {
|
||||
@ -1186,14 +1086,10 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedOrigins) {
|
||||
blink::StorageKey::CreateFromStringForTesting("http://host2:1/");
|
||||
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey1,
|
||||
storage::kDefaultBucketName, kTemporary);
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey1,
|
||||
storage::kDefaultBucketName, kSyncable);
|
||||
storage::kDefaultBucketName);
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey2,
|
||||
storage::kDefaultBucketName, kTemporary);
|
||||
AddQuotaManagedBucket(GetMockManager(), kStorageKey2,
|
||||
storage::kDefaultBucketName, kSyncable);
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 4);
|
||||
storage::kDefaultBucketName);
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
|
||||
// Protect kStorageKey1.
|
||||
auto mock_policy = base::MakeRefCounted<storage::MockSpecialStoragePolicy>();
|
||||
@ -1222,13 +1118,9 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedIgnoreDevTools) {
|
||||
blink::StorageKey::CreateFromStringForTesting(
|
||||
"devtools://abcdefghijklmnopqrstuvw/");
|
||||
|
||||
storage::BucketInfo temp_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey, storage::kDefaultBucketName, kTemporary,
|
||||
base::Time());
|
||||
storage::BucketInfo sync_bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey, storage::kDefaultBucketName, kSyncable,
|
||||
base::Time());
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
storage::BucketInfo bucket = AddQuotaManagedBucket(
|
||||
GetMockManager(), kStorageKey, storage::kDefaultBucketName, base::Time());
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 1);
|
||||
|
||||
base::RunLoop run_loop;
|
||||
StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
|
||||
@ -1243,9 +1135,8 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedIgnoreDevTools) {
|
||||
run_loop.Run();
|
||||
|
||||
// Check that devtools data isn't removed.
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 2);
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(temp_bucket, kClientFile));
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(sync_bucket, kClientFile));
|
||||
EXPECT_EQ(GetMockManager()->BucketDataCount(kClientFile), 1);
|
||||
EXPECT_TRUE(GetMockManager()->BucketHasData(bucket, kClientFile));
|
||||
}
|
||||
|
||||
TEST_F(StoragePartitionImplTest, RemoveCookieForever) {
|
||||
|
@ -228,13 +228,9 @@ class CONTENT_EXPORT StoragePartition {
|
||||
|
||||
REMOVE_DATA_MASK_ALL = 0xFFFFFFFF,
|
||||
|
||||
// Corresponds to storage::kStorageTypeTemporary.
|
||||
// Corresponds to storage::kStorageTypeTemporary, which is equivalent to
|
||||
// all quota managed storage after all other types have been deprecated.
|
||||
QUOTA_MANAGED_STORAGE_MASK_TEMPORARY = 1 << 0,
|
||||
// Corresponds to storage::kStorageTypePersistent.
|
||||
// Deprecated since crbug.com/1233525.
|
||||
// QUOTA_MANAGED_STORAGE_MASK_PERSISTENT = 1 << 1,
|
||||
// Corresponds to storage::kStorageTypeSyncable.
|
||||
QUOTA_MANAGED_STORAGE_MASK_SYNCABLE = 1 << 2,
|
||||
QUOTA_MANAGED_STORAGE_MASK_ALL = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
|
@ -145,8 +145,7 @@ void DatabaseTracker::RegisterQuotaClient() {
|
||||
mojo::PendingReceiver<storage::mojom::QuotaClient> quota_client_receiver =
|
||||
quota_client_remote.InitWithNewPipeAndPassReceiver();
|
||||
quota_manager_proxy_->RegisterClient(std::move(quota_client_remote),
|
||||
storage::QuotaClientType::kDatabase,
|
||||
{blink::mojom::StorageType::kTemporary});
|
||||
storage::QuotaClientType::kDatabase);
|
||||
|
||||
task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
|
@ -104,10 +104,8 @@ class TestQuotaManagerProxy : public QuotaManagerProxy {
|
||||
base::SequencedTaskRunner::GetCurrentDefault(),
|
||||
/*profile_path=*/base::FilePath()) {}
|
||||
|
||||
void RegisterClient(
|
||||
mojo::PendingRemote<mojom::QuotaClient> client,
|
||||
QuotaClientType client_type,
|
||||
const base::flat_set<blink::mojom::StorageType>& storage_types) override {
|
||||
void RegisterClient(mojo::PendingRemote<mojom::QuotaClient> client,
|
||||
QuotaClientType client_type) override {
|
||||
EXPECT_FALSE(registered_client_);
|
||||
registered_client_.Bind(std::move(client));
|
||||
}
|
||||
|
@ -249,8 +249,7 @@ void FileSystemContext::Initialize() {
|
||||
mojo::PendingReceiver<mojom::QuotaClient> quota_client_receiver =
|
||||
quota_client_remote.InitWithNewPipeAndPassReceiver();
|
||||
quota_manager_proxy_->RegisterClient(std::move(quota_client_remote),
|
||||
QuotaClientType::kFileSystem,
|
||||
QuotaManagedStorageTypes());
|
||||
QuotaClientType::kFileSystem);
|
||||
|
||||
io_task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
@ -643,21 +642,6 @@ FileSystemContext::~FileSystemContext() {
|
||||
env_override_.release();
|
||||
}
|
||||
|
||||
base::flat_set<blink::mojom::StorageType>
|
||||
FileSystemContext::QuotaManagedStorageTypes() {
|
||||
std::vector<blink::mojom::StorageType> quota_storage_types;
|
||||
for (FileSystemType file_system_type : GetFileSystemTypes()) {
|
||||
const blink::mojom::StorageType storage_type =
|
||||
FileSystemTypeToQuotaStorageType(file_system_type);
|
||||
if (storage_type == blink::mojom::StorageType::kTemporary ||
|
||||
storage_type == blink::mojom::StorageType::kSyncable) {
|
||||
quota_storage_types.push_back(storage_type);
|
||||
}
|
||||
}
|
||||
return base::flat_set<blink::mojom::StorageType>(
|
||||
std::move(quota_storage_types));
|
||||
}
|
||||
|
||||
std::unique_ptr<FileSystemOperation>
|
||||
FileSystemContext::CreateFileSystemOperation(OperationType type,
|
||||
const FileSystemURL& url,
|
||||
|
@ -360,10 +360,6 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileSystemContext
|
||||
// Must be called after creating the FileSystemContext.
|
||||
void Initialize();
|
||||
|
||||
// The set of quota-managed storage types covered by file system backends.
|
||||
// This may be called before the file system backends are initialized.
|
||||
base::flat_set<blink::mojom::StorageType> QuotaManagedStorageTypes();
|
||||
|
||||
// Creates a new FileSystemOperation instance by getting an appropriate
|
||||
// FileSystemBackend for `url` and calling the backend's corresponding
|
||||
// CreateFileSystemOperation method.
|
||||
|
@ -82,20 +82,19 @@ base::FilePath QuotaManagerProxy::GetClientBucketPath(
|
||||
|
||||
void QuotaManagerProxy::RegisterClient(
|
||||
mojo::PendingRemote<mojom::QuotaClient> client,
|
||||
QuotaClientType client_type,
|
||||
const base::flat_set<blink::mojom::StorageType>& storage_types) {
|
||||
QuotaClientType client_type) {
|
||||
if (!quota_manager_impl_task_runner_->RunsTasksInCurrentSequence()) {
|
||||
quota_manager_impl_task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&QuotaManagerProxy::RegisterClient, this,
|
||||
std::move(client), client_type, storage_types));
|
||||
FROM_HERE, base::BindOnce(&QuotaManagerProxy::RegisterClient, this,
|
||||
std::move(client), client_type));
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(quota_manager_impl_sequence_checker_);
|
||||
if (quota_manager_impl_) {
|
||||
quota_manager_impl_->RegisterClient(std::move(client), client_type,
|
||||
storage_types);
|
||||
quota_manager_impl_->RegisterClient(
|
||||
std::move(client), client_type,
|
||||
{blink::mojom::StorageType::kTemporary});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,10 +67,8 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) QuotaManagerProxy
|
||||
QuotaManagerProxy(const QuotaManagerProxy&) = delete;
|
||||
QuotaManagerProxy& operator=(const QuotaManagerProxy&) = delete;
|
||||
|
||||
virtual void RegisterClient(
|
||||
mojo::PendingRemote<mojom::QuotaClient> client,
|
||||
QuotaClientType client_type,
|
||||
const base::flat_set<blink::mojom::StorageType>& storage_types);
|
||||
virtual void RegisterClient(mojo::PendingRemote<mojom::QuotaClient> client,
|
||||
QuotaClientType client_type);
|
||||
|
||||
virtual void BindInternalsHandler(
|
||||
mojo::PendingReceiver<mojom::QuotaInternalsHandler> receiver);
|
||||
|
@ -204,8 +204,8 @@ class QuotaManagerImplTest : public testing::Test {
|
||||
mojo::PendingRemote<storage::mojom::QuotaClient> quota_client;
|
||||
mojo::MakeSelfOwnedReceiver(std::move(mock_quota_client),
|
||||
quota_client.InitWithNewPipeAndPassReceiver());
|
||||
quota_manager_impl_->proxy()->RegisterClient(std::move(quota_client),
|
||||
client_type, storage_types);
|
||||
quota_manager_impl_->RegisterClient(std::move(quota_client), client_type,
|
||||
storage_types);
|
||||
return mock_quota_client_ptr;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user