| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_I18N_ICU_UTIL_H_ | 5 #ifndef BASE_I18N_ICU_UTIL_H_ |
| 6 #define BASE_I18N_ICU_UTIL_H_ | 6 #define BASE_I18N_ICU_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/files/memory_mapped_file.h" | 8 #include "base/files/memory_mapped_file.h" |
| 9 #include "base/i18n/base_i18n_export.h" | 9 #include "base/i18n/base_i18n_export.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 namespace i18n { | 13 namespace i18n { |
| 14 | 14 |
| 15 #if !defined(OS_NACL) | 15 #if !defined(OS_NACL) |
| 16 // Call this function to load ICU's data tables for the current process. This | 16 // Call this function to load ICU's data tables for the current process. This |
| 17 // function should be called before ICU is used. | 17 // function should be called before ICU is used. |
| 18 BASE_I18N_EXPORT bool InitializeICU(); | 18 BASE_I18N_EXPORT bool InitializeICU(); |
| 19 | 19 |
| 20 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE | 20 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE |
| 21 #if defined(OS_ANDROID) |
| 21 // Returns the PlatformFile and Region that was initialized by InitializeICU(). | 22 // Returns the PlatformFile and Region that was initialized by InitializeICU(). |
| 22 // Use with InitializeICUWithFileDescriptor(). | 23 // Use with InitializeICUWithFileDescriptor(). |
| 23 BASE_I18N_EXPORT PlatformFile GetIcuDataFileHandle( | 24 BASE_I18N_EXPORT PlatformFile GetIcuDataFileHandle( |
| 24 MemoryMappedFile::Region* out_region); | 25 MemoryMappedFile::Region* out_region); |
| 25 | 26 |
| 26 // Android and html_viewer use a file descriptor passed by browser process to | 27 // Android uses a file descriptor passed by browser process to initialize ICU |
| 27 // initialize ICU in render processes. | 28 // in render processes. |
| 28 BASE_I18N_EXPORT bool InitializeICUWithFileDescriptor( | 29 BASE_I18N_EXPORT bool InitializeICUWithFileDescriptor( |
| 29 PlatformFile data_fd, | 30 PlatformFile data_fd, |
| 30 const MemoryMappedFile::Region& data_region); | 31 const MemoryMappedFile::Region& data_region); |
| 32 #endif |
| 33 |
| 34 // Returns a void pointer to the memory mapped ICU data file. |
| 35 // |
| 36 // There are cases on Android where we would be unsafely reusing a file |
| 37 // descriptor within the same process when initializing two copies of ICU from |
| 38 // different binaries in the same address space. This returns an unowned |
| 39 // pointer to the memory mapped icu data file; consumers copies of base must |
| 40 // not outlive the copy of base that owns the memory mapped file. |
| 41 BASE_I18N_EXPORT const uint8* GetRawIcuMemory(); |
| 42 |
| 43 // Initializes ICU memory |
| 44 // |
| 45 // This does nothing in component builds; this initialization should only be |
| 46 // done in cases where there could be two copies of base in a single process in |
| 47 // non-component builds. (The big example is mojo: the shell will have a copy |
| 48 // of base linked in, and the majority of mojo applications will have base |
| 49 // linked in but in non-component builds, these will be separate copies of |
| 50 // base.) |
| 51 BASE_I18N_EXPORT bool InitializeICUFromRawMemory(const uint8* raw_memory); |
| 31 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE | 52 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE |
| 32 #endif // !defined(OS_NACL) | 53 #endif // !defined(OS_NACL) |
| 33 | 54 |
| 34 // In a test binary, the call above might occur twice. | 55 // In a test binary, the call above might occur twice. |
| 35 BASE_I18N_EXPORT void AllowMultipleInitializeCallsForTesting(); | 56 BASE_I18N_EXPORT void AllowMultipleInitializeCallsForTesting(); |
| 36 | 57 |
| 37 } // namespace i18n | 58 } // namespace i18n |
| 38 } // namespace base | 59 } // namespace base |
| 39 | 60 |
| 40 #endif // BASE_I18N_ICU_UTIL_H_ | 61 #endif // BASE_I18N_ICU_UTIL_H_ |
| OLD | NEW |