#include "base/i18n/icu_util.h"
#include "build/build_config.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
#include <string.h>
#include <memory>
#include <string>
#include "base/debug/alias.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/metrics_hashes.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "build/chromecast_buildflags.h"
#include "third_party/icu/source/common/unicode/putil.h"
#include "third_party/icu/source/common/unicode/uclean.h"
#include "third_party/icu/source/common/unicode/udata.h"
#include "third_party/icu/source/common/unicode/utrace.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/apk_assets.h"
#include "base/android/timezone_utils.h"
#endif
#if BUILDFLAG(IS_IOS)
#include "base/ios/ios_util.h"
#endif
#if BUILDFLAG(IS_APPLE)
#include "base/apple/foundation_util.h"
#endif
#if BUILDFLAG(IS_FUCHSIA)
#include "base/fuchsia/intl_profile_watcher.h"
#endif
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA)
#include "third_party/icu/source/common/unicode/unistr.h"
#endif
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \
BUILDFLAG(IS_CHROMEOS) || (BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CASTOS))
#include "third_party/icu/source/i18n/unicode/timezone.h"
#endif
namespace base::i18n {
#if !BUILDFLAG(IS_NACL)
namespace {
#if DCHECK_IS_ON()
bool g_check_called_once = …;
bool g_called_once = …;
#endif
#if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE)
int g_debug_icu_last_error;
int g_debug_icu_load;
int g_debug_icu_pf_error_details;
int g_debug_icu_pf_last_error;
#if BUILDFLAG(IS_WIN)
wchar_t g_debug_icu_pf_filename[_MAX_PATH];
#endif
const char kIcuDataFileName[] = …;
#if BUILDFLAG(IS_FUCHSIA)
const char kIcuTimeZoneEnvVariable[] = "ICU_TIMEZONE_FILES_DIR";
const char kIcuTimeZoneDataDir[] = "/config/tzdata/icu/44/le";
#endif
#if BUILDFLAG(IS_ANDROID)
const char kAndroidAssetsIcuDataFileName[] = "assets/icudtl.dat";
#endif
PlatformFile g_icudtl_pf = …;
MemoryMappedFile* g_icudtl_mapped_file = …;
MemoryMappedFile::Region g_icudtl_region;
#if BUILDFLAG(IS_FUCHSIA)
const char* g_icu_time_zone_data_dir = kIcuTimeZoneDataDir;
#endif
void LazyInitIcuDataFile() { … }
void InitializeExternalTimeZoneData() { … }
int LoadIcuData(PlatformFile data_fd,
const MemoryMappedFile::Region& data_region,
std::unique_ptr<MemoryMappedFile>* out_mapped_data_file,
UErrorCode* out_error_code) { … }
bool InitializeICUWithFileDescriptorInternal(
PlatformFile data_fd,
const MemoryMappedFile::Region& data_region) { … }
bool InitializeICUFromDataFile() { … }
#endif
void InitializeIcuTimeZone() { … }
enum class ICUCreateInstance { … };
bool DoCommonInitialization() { … }
}
#if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE)
bool InitializeICUWithFileDescriptor(
PlatformFile data_fd,
const MemoryMappedFile::Region& data_region) { … }
PlatformFile GetIcuDataFileHandle(MemoryMappedFile::Region* out_region) { … }
void ResetGlobalsForTesting() { … }
#if BUILDFLAG(IS_FUCHSIA)
void SetIcuTimeZoneDataDirForTesting(const char* dir) {
g_icu_time_zone_data_dir = dir;
}
#endif
#endif
bool InitializeICU() { … }
void AllowMultipleInitializeCallsForTesting() { … }
#endif
}