#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/wtf/text/text_encoding_registry.h"
#include <atomic>
#include <memory>
#include "base/dcheck_is_on.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/synchronization/lock.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/ascii_ctype.h"
#include "third_party/blink/renderer/platform/wtf/text/case_folding_hash.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec_cjk.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec_icu.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec_latin1.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec_replacement.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec_user_defined.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec_utf16.h"
#include "third_party/blink/renderer/platform/wtf/text/text_codec_utf8.h"
#include "third_party/blink/renderer/platform/wtf/text/text_encoding.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"
namespace WTF {
const size_t kMaxEncodingNameLength = …;
struct TextCodecFactory { … };
TextEncodingNameMap;
TextCodecMap;
static base::Lock& EncodingRegistryLock() { … }
static TextEncodingNameMap* g_text_encoding_name_map;
static TextCodecMap* g_text_codec_map;
namespace {
static std::atomic_bool g_did_extend_text_codec_maps{ … };
ALWAYS_INLINE bool AtomicDidExtendTextCodecMaps() { … }
ALWAYS_INLINE void AtomicSetDidExtendTextCodecMaps() { … }
}
#if !DCHECK_IS_ON()
static inline void CheckExistingName(const char*, const char*) {}
#else
static void CheckExistingName(const char* alias, const char* atomic_name) { … }
#endif
static bool IsUndesiredAlias(const char* alias) { … }
static void AddToTextEncodingNameMap(const char* alias, const char* name) { … }
static void AddToTextCodecMap(const char* name,
NewTextCodecFunction function,
const void* additional_data) { … }
static void BuildBaseTextCodecMaps() { … }
static void ExtendTextCodecMaps() { … }
std::unique_ptr<TextCodec> NewTextCodec(const TextEncoding& encoding) { … }
const char* AtomicCanonicalTextEncodingName(const char* name) { … }
template <typename CharacterType>
const char* AtomicCanonicalTextEncodingName(const CharacterType* characters,
size_t length) { … }
const char* AtomicCanonicalTextEncodingName(const String& alias) { … }
bool NoExtendedTextEncodingNameUsed() { … }
Vector<String> TextEncodingAliasesForTesting() { … }
#ifndef NDEBUG
void DumpTextEncodingNameMap() { … }
#endif
}