#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/visitedlink/browser/partitioned_visitedlink_writer.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/metrics/histogram_functions.h"
#include "base/rand_util.h"
#include "base/trace_event/trace_event.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/core/visited_link.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/schemeful_site.h"
#include "third_party/abseil-cpp/absl/container/inlined_vector.h"
#include "third_party/blink/public/common/features.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace {
enum class AddFingerprint { … };
}
namespace visitedlink {
const unsigned PartitionedVisitedLinkWriter::kDefaultTableSize = …;
bool PartitionedVisitedLinkWriter::fail_table_creation_for_testing_ = …;
class PartitionedVisitedLinkWriter::TableBuilder
: public VisitedLinkDelegate::VisitedLinkEnumerator { … };
PartitionedVisitedLinkWriter::TableBuilder::TableBuilder(
base::WeakPtr<PartitionedVisitedLinkWriter> writer)
: … { … }
void PartitionedVisitedLinkWriter::TableBuilder::OnVisitedLink(
const GURL& link_url,
const net::SchemefulSite& top_level_site,
const url::Origin& frame_origin) { … }
void PartitionedVisitedLinkWriter::TableBuilder::OnVisitedLinkComplete(
bool success) { … }
uint64_t PartitionedVisitedLinkWriter::TableBuilder::GetOrAddLocalOriginSalt(
const url::Origin& origin) { … }
void PartitionedVisitedLinkWriter::TableBuilder::OnCompleteMainThread() { … }
PartitionedVisitedLinkWriter::PartitionedVisitedLinkWriter(
content::BrowserContext* browser_context,
VisitedLinkDelegate* delegate)
: … { … }
PartitionedVisitedLinkWriter::PartitionedVisitedLinkWriter(
std::unique_ptr<Listener> listener,
VisitedLinkDelegate* delegate,
bool suppress_build,
int32_t default_table_size)
: … { … }
PartitionedVisitedLinkWriter::~PartitionedVisitedLinkWriter() = default;
bool PartitionedVisitedLinkWriter::Init() { … }
bool PartitionedVisitedLinkWriter::CreateVisitedLinkTable(int32_t num_entries) { … }
bool PartitionedVisitedLinkWriter::CreateVisitedLinkTableHelper(
int32_t num_entries,
base::MappedReadOnlyRegion* memory) { … }
bool PartitionedVisitedLinkWriter::ResizeTableIfNecessary() { … }
void PartitionedVisitedLinkWriter::ResizeTable(int32_t new_size) { … }
bool PartitionedVisitedLinkWriter::BuildTableFromDelegate() { … }
VisitedLinkWriter::Hash PartitionedVisitedLinkWriter::AddFingerprint(
Fingerprint fingerprint,
bool send_notifications) { … }
void PartitionedVisitedLinkWriter::DeleteFingerprintsFromCurrentTable(
const std::set<Fingerprint>& fingerprints) { … }
bool PartitionedVisitedLinkWriter::DeleteFingerprint(Fingerprint fingerprint) { … }
void PartitionedVisitedLinkWriter::OnTableBuildComplete(
bool success,
const std::vector<Fingerprint>& fingerprints,
std::map<url::Origin, uint64_t> salts) { … }
uint32_t PartitionedVisitedLinkWriter::DefaultTableSize() const { … }
uint32_t PartitionedVisitedLinkWriter::NewTableSizeForCount(
int32_t item_count) const { … }
void PartitionedVisitedLinkWriter::AddVisitedLink(const VisitedLink& link) { … }
VisitedLinkWriter::Hash PartitionedVisitedLinkWriter::TryToAddVisitedLink(
const VisitedLink& link) { … }
void PartitionedVisitedLinkWriter::DeleteAllVisitedLinks() { … }
void PartitionedVisitedLinkWriter::DeleteVisitedLinks(
VisitedLinkIterator* links) { … }
std::optional<uint64_t> PartitionedVisitedLinkWriter::GetOrAddOriginSalt(
const url::Origin& origin) { … }
VisitedLinkCommon::Fingerprint*
PartitionedVisitedLinkWriter::GetHashTableFromMapping(
const base::WritableSharedMemoryMapping& hash_table_mapping) { … }
}