• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define ICU_UTIL_DATA_FILE 0
16 #define ICU_UTIL_DATA_STATIC 1
17 
18 namespace base::i18n {
19 
20 #if !BUILDFLAG(IS_NACL)
21 // Call this function to load ICU's data tables for the current process.  This
22 // function should be called before ICU is used.
23 BASE_I18N_EXPORT bool InitializeICU();
24 
25 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
26 
27 // Returns the PlatformFile and Region that was initialized by InitializeICU().
28 // Use with InitializeICUWithFileDescriptor().
29 BASE_I18N_EXPORT PlatformFile
30 GetIcuDataFileHandle(MemoryMappedFile::Region* out_region);
31 
32 // Loads ICU data file from file descriptor passed by browser process to
33 // initialize ICU in render processes.
34 BASE_I18N_EXPORT bool InitializeICUWithFileDescriptor(
35     PlatformFile data_fd,
36     const MemoryMappedFile::Region& data_region);
37 
38 // Calls `u_cleanup()` to reset the ICU library, and clears global state,
39 // notably releasing the mapped ICU data file, and handle.
40 BASE_I18N_EXPORT void ResetGlobalsForTesting();
41 
42 #if BUILDFLAG(IS_FUCHSIA)
43 // Overrides the directory used by ICU for external time zone data.
44 BASE_I18N_EXPORT void SetIcuTimeZoneDataDirForTesting(const char* dir);
45 #endif  // BUILDFLAG(IS_FUCHSIA)
46 #endif  // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
47 
48 // In a test binary, initialize functions might be called twice.
49 BASE_I18N_EXPORT void AllowMultipleInitializeCallsForTesting();
50 #endif  // !BUILDFLAG(IS_NACL)
51 
52 }  // namespace base::i18n
53 
54 #endif  // BASE_I18N_ICU_UTIL_H_
55