Fix emulator build error
[platform/framework/web/chromium-efl.git] / base / i18n / icu_util.h
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_I18N_ICU_UTIL_H_
6 #define BASE_I18N_ICU_UTIL_H_
7
8 #include <stdint.h>
9
10 #include "base/files/memory_mapped_file.h"
11 #include "base/i18n/base_i18n_export.h"
12 #include "build/build_config.h"
13 #include "build/chromeos_buildflags.h"
14
15 #if BUILDFLAG(IS_CHROMEOS_LACROS)
16 #include "icu_mergeable_data_file.h"
17 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
18
19 #define ICU_UTIL_DATA_FILE 0
20 #define ICU_UTIL_DATA_STATIC 1
21
22 namespace base::i18n {
23
24 #if !BUILDFLAG(IS_NACL)
25 // Call this function to load ICU's data tables for the current process.  This
26 // function should be called before ICU is used.
27 BASE_I18N_EXPORT bool InitializeICU();
28
29 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
30
31 // In ChromeOS, two versions of icudtl.dat are shipped separately with Ash and
32 // Lacros. Although the two files can differ, there's a big overlap in content.
33 // We can take advantage of that and save memory by scanning the two files and
34 // merging the pages that are in common.
35 #if BUILDFLAG(IS_CHROMEOS_LACROS)
36 using IcuDataFile = IcuMergeableDataFile;
37 #else
38 // Outside of Lacros, we simply memory map the ICU data file.
39 using IcuDataFile = MemoryMappedFile;
40 #endif  // BUILDFLAG(IS_CHROMEOS_LACROS)
41 // Returns the PlatformFile and Region that was initialized by InitializeICU().
42 // Use with InitializeICUWithFileDescriptor().
43 BASE_I18N_EXPORT PlatformFile
44 GetIcuDataFileHandle(MemoryMappedFile::Region* out_region);
45
46 // Loads ICU data file from file descriptor passed by browser process to
47 // initialize ICU in render processes.
48 BASE_I18N_EXPORT bool InitializeICUWithFileDescriptor(
49     PlatformFile data_fd,
50     const MemoryMappedFile::Region& data_region);
51
52 BASE_I18N_EXPORT void ResetGlobalsForTesting();
53
54 #if BUILDFLAG(IS_FUCHSIA)
55 // Overrides the directory used by ICU for external time zone data.
56 BASE_I18N_EXPORT void SetIcuTimeZoneDataDirForTesting(const char* dir);
57 #endif  // BUILDFLAG(IS_FUCHSIA)
58 #endif  // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
59
60 // In a test binary, initialize functions might be called twice.
61 BASE_I18N_EXPORT void AllowMultipleInitializeCallsForTesting();
62 #endif  // !BUILDFLAG(IS_NACL)
63
64 }  // namespace base::i18n
65
66 #endif  // BASE_I18N_ICU_UTIL_H_