icu_util.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_I18N_ICU_UTIL_H_
  5. #define BASE_I18N_ICU_UTIL_H_
  6. #include <stdint.h>
  7. #include "base/files/memory_mapped_file.h"
  8. #include "base/i18n/base_i18n_export.h"
  9. #include "build/build_config.h"
  10. #define ICU_UTIL_DATA_FILE 0
  11. #define ICU_UTIL_DATA_STATIC 1
  12. namespace base {
  13. namespace i18n {
  14. #if !defined(OS_NACL)
  15. // Call this function to load ICU's data tables for the current process. This
  16. // function should be called before ICU is used.
  17. BASE_I18N_EXPORT bool InitializeICU();
  18. #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
  19. // Loads ICU's extra data tables from disk for the current process. If used must
  20. // be called before InitializeICU().
  21. BASE_I18N_EXPORT bool InitializeExtraICU();
  22. // Returns the PlatformFile and Region that was initialized by InitializeICU()
  23. // or InitializeExtraICU(). Use with InitializeICUWithFileDescriptor() or
  24. // InitializeExtraICUWithFileDescriptor().
  25. BASE_I18N_EXPORT PlatformFile GetIcuDataFileHandle(
  26. MemoryMappedFile::Region* out_region);
  27. BASE_I18N_EXPORT PlatformFile
  28. GetIcuExtraDataFileHandle(MemoryMappedFile::Region* out_region);
  29. // Loads ICU data file from file descriptor passed by browser process to
  30. // initialize ICU in render processes.
  31. BASE_I18N_EXPORT bool InitializeICUWithFileDescriptor(
  32. PlatformFile data_fd,
  33. const MemoryMappedFile::Region& data_region);
  34. // Loads ICU extra data file from file descriptor passed by browser process to
  35. // initialize ICU in render processes. If used must be called before
  36. // InitializeICUWithFileDescriptor().
  37. BASE_I18N_EXPORT bool InitializeExtraICUWithFileDescriptor(
  38. PlatformFile data_fd,
  39. const MemoryMappedFile::Region& data_region);
  40. BASE_I18N_EXPORT void ResetGlobalsForTesting();
  41. #if defined(OS_FUCHSIA)
  42. // Overrides the directory used by ICU for external time zone data.
  43. BASE_I18N_EXPORT void SetIcuTimeZoneDataDirForTesting(const char* dir);
  44. #endif // defined(OS_FUCHSIA)
  45. #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
  46. // In a test binary, initialize functions might be called twice.
  47. BASE_I18N_EXPORT void AllowMultipleInitializeCallsForTesting();
  48. #endif // !defined(OS_NACL)
  49. } // namespace i18n
  50. } // namespace base
  51. #endif // BASE_I18N_ICU_UTIL_H_