OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/i18n/icu_util.h" | 5 #include "base/i18n/icu_util.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll" | 41 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll" |
42 #endif | 42 #endif |
43 #endif | 43 #endif |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 #if !defined(NDEBUG) | 47 #if !defined(NDEBUG) |
48 // Assert that we are not called more than once. Even though calling this | 48 // Assert that we are not called more than once. Even though calling this |
49 // function isn't harmful (ICU can handle it), being called twice probably | 49 // function isn't harmful (ICU can handle it), being called twice probably |
50 // indicates a programming error. | 50 // indicates a programming error. |
| 51 #if !defined(OS_NACL) |
51 bool g_called_once = false; | 52 bool g_called_once = false; |
| 53 #endif |
52 bool g_check_called_once = true; | 54 bool g_check_called_once = true; |
53 #endif | 55 #endif |
54 } | 56 } |
55 | 57 |
56 #if defined(OS_ANDROID) | 58 #if defined(OS_ANDROID) |
57 bool InitializeICUWithFileDescriptor( | 59 bool InitializeICUWithFileDescriptor( |
58 int data_fd, | 60 int data_fd, |
59 base::MemoryMappedFile::Region data_region) { | 61 base::MemoryMappedFile::Region data_region) { |
60 #if !defined(NDEBUG) | 62 #if !defined(NDEBUG) |
61 DCHECK(!g_check_called_once || !g_called_once); | 63 DCHECK(!g_check_called_once || !g_called_once); |
(...skipping 12 matching lines...) Expand all Loading... |
74 } | 76 } |
75 } | 77 } |
76 UErrorCode err = U_ZERO_ERROR; | 78 UErrorCode err = U_ZERO_ERROR; |
77 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); | 79 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); |
78 return err == U_ZERO_ERROR; | 80 return err == U_ZERO_ERROR; |
79 #endif // ICU_UTIL_DATA_FILE | 81 #endif // ICU_UTIL_DATA_FILE |
80 } | 82 } |
81 #endif | 83 #endif |
82 | 84 |
83 | 85 |
| 86 #if !defined(OS_NACL) |
84 bool InitializeICU() { | 87 bool InitializeICU() { |
85 #if !defined(NDEBUG) | 88 #if !defined(NDEBUG) |
86 DCHECK(!g_check_called_once || !g_called_once); | 89 DCHECK(!g_check_called_once || !g_called_once); |
87 g_called_once = true; | 90 g_called_once = true; |
88 #endif | 91 #endif |
89 | 92 |
90 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) | 93 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) |
91 // We expect to find the ICU data module alongside the current module. | 94 // We expect to find the ICU data module alongside the current module. |
92 FilePath data_path; | 95 FilePath data_path; |
93 PathService::Get(base::DIR_MODULE, &data_path); | 96 PathService::Get(base::DIR_MODULE, &data_path); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 if (!mapped_file.Initialize(data_path)) { | 154 if (!mapped_file.Initialize(data_path)) { |
152 LOG(ERROR) << "Couldn't mmap " << data_path.AsUTF8Unsafe(); | 155 LOG(ERROR) << "Couldn't mmap " << data_path.AsUTF8Unsafe(); |
153 return false; | 156 return false; |
154 } | 157 } |
155 } | 158 } |
156 UErrorCode err = U_ZERO_ERROR; | 159 UErrorCode err = U_ZERO_ERROR; |
157 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); | 160 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); |
158 return err == U_ZERO_ERROR; | 161 return err == U_ZERO_ERROR; |
159 #endif | 162 #endif |
160 } | 163 } |
| 164 #endif |
161 | 165 |
162 void AllowMultipleInitializeCallsForTesting() { | 166 void AllowMultipleInitializeCallsForTesting() { |
163 #if !defined(NDEBUG) | 167 #if !defined(NDEBUG) |
164 g_check_called_once = false; | 168 g_check_called_once = false; |
165 #endif | 169 #endif |
166 } | 170 } |
167 | 171 |
168 } // namespace i18n | 172 } // namespace i18n |
169 } // namespace base | 173 } // namespace base |
OLD | NEW |