#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/browser/api/declarative_net_request/flat_ruleset_indexer.h"
#include <string>
#include "base/check_op.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/escape.h"
#include "base/strings/string_util.h"
#include "extensions/browser/api/declarative_net_request/constants.h"
#include "extensions/browser/api/declarative_net_request/indexed_rule.h"
#include "extensions/browser/api/declarative_net_request/utils.h"
namespace extensions::declarative_net_request {
namespace {
dnr_api;
flat_rule;
FlatOffset;
FlatVectorOffset;
FlatStringOffset;
FlatStringListOffset;
FlatIntListOffset;
bool IsBeforeRequestRule(const IndexedRule& indexed_rule) { … }
template <typename T>
FlatStringListOffset BuildVectorOfSharedStringsImpl(
flatbuffers::FlatBufferBuilder* builder,
const T& container,
bool is_lower_case) { … }
template <typename T>
FlatStringListOffset BuildVectorOfSharedStrings(
flatbuffers::FlatBufferBuilder* builder,
const T& container) { … }
template <typename T>
FlatStringListOffset BuildVectorOfSharedLowercaseStrings(
flatbuffers::FlatBufferBuilder* builder,
const T& container) { … }
FlatIntListOffset BuildIntVector(flatbuffers::FlatBufferBuilder* builder,
const base::flat_set<int>& input) { … }
std::vector<std::unique_ptr<url_pattern_index::UrlPatternIndexBuilder>>
CreateIndexBuilders(flatbuffers::FlatBufferBuilder* builder) { … }
FlatOffset<flat::UrlTransform> BuildTransformOffset(
flatbuffers::FlatBufferBuilder* builder,
const dnr_api::URLTransform& transform) { … }
FlatVectorOffset<flat::ModifyHeaderInfo> BuildModifyHeaderInfoOffset(
flatbuffers::FlatBufferBuilder* builder,
const std::vector<dnr_api::ModifyHeaderInfo>& modify_header_list) { … }
FlatVectorOffset<flat::HeaderCondition> BuildHeaderConditionsOffset(
flatbuffers::FlatBufferBuilder* builder,
const std::vector<dnr_api::HeaderInfo>& header_infos) { … }
FlatOffset<flatbuffers::Vector<uint8_t>> BuildEmbedderConditionsOffset(
flatbuffers::FlatBufferBuilder* builder,
const IndexedRule& indexed_rule) { … }
}
FlatRulesetIndexer::FlatRulesetIndexer()
: … { … }
FlatRulesetIndexer::~FlatRulesetIndexer() = default;
void FlatRulesetIndexer::AddUrlRule(const IndexedRule& indexed_rule) { … }
flatbuffers::DetachedBuffer FlatRulesetIndexer::FinishAndReleaseBuffer() { … }
std::vector<FlatRulesetIndexer::UrlPatternIndexBuilder*>
FlatRulesetIndexer::GetBuilders(const IndexedRule& indexed_rule) { … }
}