#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "storage/browser/quota/quota_database.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <iterator>
#include <memory>
#include <set>
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/sequence_checker.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "components/services/storage/public/cpp/buckets/bucket_locator.h"
#include "components/services/storage/public/cpp/buckets/constants.h"
#include "components/services/storage/public/cpp/constants.h"
#include "sql/database.h"
#include "sql/meta_table.h"
#include "sql/sqlite_result_code.h"
#include "sql/sqlite_result_code_values.h"
#include "sql/statement.h"
#include "sql/test/scoped_error_expecter.h"
#include "sql/test/test_helpers.h"
#include "storage/browser/quota/quota_client_type.h"
#include "storage/browser/quota/quota_features.h"
#include "storage/browser/quota/quota_internals.mojom.h"
#include "storage/browser/quota/storage_directory_util.h"
#include "storage/browser/test/mock_special_storage_policy.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom-shared.h"
#include "url/gurl.h"
StorageKey;
namespace storage {
namespace {
static const blink::mojom::StorageType kTemp = …;
static const blink::mojom::StorageType kSync = …;
static const blink::mojom::StorageType kStorageTemp = …;
static const blink::mojom::StorageType kStorageSync = …;
static constexpr char kDatabaseName[] = …;
bool ContainsBucket(const std::set<BucketLocator>& buckets,
const BucketInfo& target_bucket) { … }
}
class QuotaDatabaseTest
: public testing::TestWithParam<std::tuple<bool, bool, bool>> { … };
TEST_P(QuotaDatabaseTest, EnsureOpened) { … }
TEST_P(QuotaDatabaseTest, UpdateOrCreateBucket) { … }
TEST_P(QuotaDatabaseTest, UpdateBucket) { … }
TEST_P(QuotaDatabaseTest, GetOrCreateBucketDeprecated) { … }
TEST_P(QuotaDatabaseTest, GetBucket) { … }
TEST_P(QuotaDatabaseTest, GetBucketById) { … }
TEST_P(QuotaDatabaseTest, GetBucketsForType) { … }
TEST_P(QuotaDatabaseTest, GetBucketsForHost) { … }
TEST_P(QuotaDatabaseTest, GetBucketsForStorageKey) { … }
TEST_P(QuotaDatabaseTest, BucketLastAccessTimeLRU) { … }
TEST_P(QuotaDatabaseTest, BucketPersistence) { … }
TEST_P(QuotaDatabaseTest, SetStorageKeyLastAccessTime) { … }
TEST_P(QuotaDatabaseTest, GetStorageKeysForType) { … }
TEST_P(QuotaDatabaseTest, BucketLastModifiedBetween) { … }
TEST_P(QuotaDatabaseTest, RegisterInitialStorageKeyInfo) { … }
TEST_P(QuotaDatabaseTest, DumpBucketTable) { … }
TEST_P(QuotaDatabaseTest, DeleteBucketData) { … }
TEST_P(QuotaDatabaseTest, BootstrapFlag) { … }
TEST_P(QuotaDatabaseTest, OpenCorruptedDatabase) { … }
TEST_P(QuotaDatabaseTest, QuotaDatabasePathMigration) { … }
TEST_P(QuotaDatabaseTest, QuotaDatabasePathBadMigration) { … }
#if !BUILDFLAG(IS_APPLE)
TEST_P(QuotaDatabaseTest, QuotaDatabaseDirectoryMigrationError) { … }
#endif
TEST_P(QuotaDatabaseTest, UpdateOrCreateBucket_CorruptedDatabase) { … }
TEST_P(QuotaDatabaseTest, Expiration) { … }
TEST_P(QuotaDatabaseTest, Stale) { … }
TEST_P(QuotaDatabaseTest, Orphan) { … }
TEST_P(QuotaDatabaseTest, PersistentPolicy) { … }
INSTANTIATE_TEST_SUITE_P(…);
}