#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/timing/background_tracing_helper.h"
#include <string_view>
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/hash/md5.h"
#include "base/numerics/byte_conversions.h"
#include "base/rand_util.h"
#include "base/trace_event/typed_macros.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/timing/performance_mark.h"
#include "third_party/blink/renderer/platform/instrumentation/resource_coordinator/renderer_resource_coordinator.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/text/ascii_ctype.h"
#include "third_party/blink/renderer/platform/wtf/text/number_parsing_options.h"
#include "third_party/blink/renderer/platform/wtf/text/string_operators.h"
#include "third_party/blink/renderer/platform/wtf/text/string_to_number.h"
#include "url/url_constants.h"
namespace blink {
namespace {
enum TerminationCondition { … };
const char* ParseHash(const char* begin,
const char* end,
uint32_t& hash,
TerminationCondition termination,
char valid_terminator0,
char valid_terminator1 = 0,
char valid_terminator2 = 0) { … }
static constexpr char kTriggerPrefix[] = …;
bool MarkNameIsTrigger(const String& mark_name) { … }
String GenerateFullTrigger(const String& site, const String& mark_name) { … }
}
struct BackgroundTracingHelper::SiteMarkHashMapContainer { … };
BackgroundTracingHelper::SiteMarkHashMapContainer::SiteMarkHashMapContainer() { … }
BackgroundTracingHelper::BackgroundTracingHelper(ExecutionContext* context) { … }
BackgroundTracingHelper::~BackgroundTracingHelper() = default;
void BackgroundTracingHelper::MaybeEmitBackgroundTracingPerformanceMarkEvent(
const PerformanceMark& mark) { … }
void BackgroundTracingHelper::Trace(Visitor*) const { … }
const BackgroundTracingHelper::SiteMarkHashMap&
BackgroundTracingHelper::GetSiteMarkHashMap() { … }
const BackgroundTracingHelper::MarkHashSet*
BackgroundTracingHelper::GetMarkHashSetForSiteHash(uint32_t site_hash) { … }
size_t BackgroundTracingHelper::GetSequenceNumberPos(std::string_view string) { … }
uint32_t BackgroundTracingHelper::MD5Hash32(std::string_view string) { … }
void BackgroundTracingHelper::GetMarkHashAndSequenceNumber(
std::string_view mark_name,
uint32_t sequence_number_offset,
uint32_t* mark_hash,
uint32_t* sequence_number) { … }
bool BackgroundTracingHelper::ParseBackgroundTracingPerformanceMarkHashes(
std::string_view allow_list,
SiteMarkHashMap& allow_listed_hashes) { … }
}