#include "components/safe_browsing/core/browser/db/v4_test_util.h"
#include <algorithm>
#include <string>
#include <utility>
#include "base/strings/strcat.h"
#include "base/task/sequenced_task_runner.h"
#include "components/safe_browsing/core/browser/db/util.h"
#include "crypto/sha2.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace safe_browsing {
namespace {
const char kClient[] = …;
const char kAppVer[] = …;
const char kKeyParam[] = …;
const int kDefaultStoreFileSizeInBytes = …;
}
V4ProtocolConfig GetTestV4ProtocolConfig(bool disable_auto_update) { … }
std::ostream& operator<<(std::ostream& os, const ThreatMetadata& meta) { … }
TestV4Store::TestV4Store(
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const base::FilePath& store_path)
: … { … }
TestV4Store::~TestV4Store() = default;
bool TestV4Store::HasValidData() { … }
void TestV4Store::MarkPrefixAsBad(HashPrefixStr prefix) { … }
void TestV4Store::SetPrefixes(std::vector<HashPrefixStr> prefixes,
PrefixSize size) { … }
HashPrefixStr TestV4Store::GetMatchingHashPrefix(const FullHashStr& full_hash) { … }
TestV4Database::TestV4Database(
const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
std::unique_ptr<StoreMap> store_map)
: … { … }
void TestV4Database::MarkPrefixAsBad(ListIdentifier list_id,
HashPrefixStr prefix) { … }
int64_t TestV4Database::GetStoreSizeInBytes(const ListIdentifier& store) const { … }
TestV4StoreFactory::TestV4StoreFactory() = default;
TestV4StoreFactory::~TestV4StoreFactory() = default;
V4StorePtr TestV4StoreFactory::CreateV4Store(
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const base::FilePath& store_path) { … }
TestV4DatabaseFactory::TestV4DatabaseFactory() = default;
TestV4DatabaseFactory::~TestV4DatabaseFactory() = default;
std::unique_ptr<V4Database, base::OnTaskRunnerDeleter>
TestV4DatabaseFactory::Create(
const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
std::unique_ptr<StoreMap> store_map) { … }
bool TestV4DatabaseFactory::IsReady() { … }
void TestV4DatabaseFactory::MarkPrefixAsBad(ListIdentifier list_id,
HashPrefixStr prefix) { … }
TestV4GetHashProtocolManager::TestV4GetHashProtocolManager(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const StoresToCheck& stores_to_check,
const V4ProtocolConfig& config)
: … { … }
void TestV4GetHashProtocolManager::AddToFullHashCache(FullHashInfo fhi) { … }
TestV4GetHashProtocolManagerFactory::TestV4GetHashProtocolManagerFactory() =
default;
TestV4GetHashProtocolManagerFactory::~TestV4GetHashProtocolManagerFactory() =
default;
std::unique_ptr<V4GetHashProtocolManager>
TestV4GetHashProtocolManagerFactory::CreateProtocolManager(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const StoresToCheck& stores_to_check,
const V4ProtocolConfig& config) { … }
TestV4HashResponseInfo::KeyValue::KeyValue(const std::string key,
const std::string value)
: … { … }
TestV4HashResponseInfo::KeyValue::KeyValue(const KeyValue& other) = default;
TestV4HashResponseInfo::KeyValue::~KeyValue() = default;
TestV4HashResponseInfo::TestV4HashResponseInfo(FullHashStr full_hash,
ListIdentifier list_id)
: … { … }
TestV4HashResponseInfo::TestV4HashResponseInfo(
const TestV4HashResponseInfo& other) = default;
TestV4HashResponseInfo::~TestV4HashResponseInfo() = default;
std::string GetV4HashResponse(
std::vector<TestV4HashResponseInfo> response_infos) { … }
FullHashInfo GetFullHashInfo(const GURL& url, const ListIdentifier& list_id) { … }
FullHashInfo GetFullHashInfoWithMetadata(
const GURL& url,
const ListIdentifier& list_id,
const ThreatMetadata& threat_metadata) { … }
}