Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: base/i18n/icu_util.cc

Issue 1429263005: Revert of mandoline: Fix ICU initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/i18n/icu_util.h ('k') | components/html_viewer/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 udata_setCommonData(const_cast<uint8*>(g_icudtl_mapped_file->data()), &err); 157 udata_setCommonData(const_cast<uint8*>(g_icudtl_mapped_file->data()), &err);
158 return err == U_ZERO_ERROR; 158 return err == U_ZERO_ERROR;
159 } 159 }
160 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 160 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
161 #endif // !defined(OS_NACL) 161 #endif // !defined(OS_NACL)
162 162
163 } // namespace 163 } // namespace
164 164
165 #if !defined(OS_NACL) 165 #if !defined(OS_NACL)
166 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 166 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
167 #if defined(OS_ANDROID)
168 bool InitializeICUWithFileDescriptor( 167 bool InitializeICUWithFileDescriptor(
169 PlatformFile data_fd, 168 PlatformFile data_fd,
170 const MemoryMappedFile::Region& data_region) { 169 const MemoryMappedFile::Region& data_region) {
171 #if !defined(NDEBUG) 170 #if !defined(NDEBUG)
172 DCHECK(!g_check_called_once || !g_called_once); 171 DCHECK(!g_check_called_once || !g_called_once);
173 g_called_once = true; 172 g_called_once = true;
174 #endif 173 #endif
175 return InitializeICUWithFileDescriptorInternal(data_fd, data_region); 174 return InitializeICUWithFileDescriptorInternal(data_fd, data_region);
176 } 175 }
177 176
178 PlatformFile GetIcuDataFileHandle(MemoryMappedFile::Region* out_region) { 177 PlatformFile GetIcuDataFileHandle(MemoryMappedFile::Region* out_region) {
179 CHECK_NE(g_icudtl_pf, kInvalidPlatformFile); 178 CHECK_NE(g_icudtl_pf, kInvalidPlatformFile);
180 *out_region = g_icudtl_region; 179 *out_region = g_icudtl_region;
181 return g_icudtl_pf; 180 return g_icudtl_pf;
182 } 181 }
183 #endif
184
185 const uint8* GetRawIcuMemory() {
186 CHECK(g_icudtl_mapped_file);
187 return g_icudtl_mapped_file->data();
188 }
189
190 bool InitializeICUFromRawMemory(const uint8* raw_memory) {
191 #if !defined(COMPONENT_BUILD)
192 #if !defined(NDEBUG)
193 DCHECK(!g_check_called_once || !g_called_once);
194 g_called_once = true;
195 #endif
196
197 UErrorCode err = U_ZERO_ERROR;
198 udata_setCommonData(const_cast<uint8*>(raw_memory), &err);
199 return err == U_ZERO_ERROR;
200 #else
201 return true;
202 #endif
203 }
204
205 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 182 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
206 183
207 bool InitializeICU() { 184 bool InitializeICU() {
208 #if !defined(NDEBUG) 185 #if !defined(NDEBUG)
209 DCHECK(!g_check_called_once || !g_called_once); 186 DCHECK(!g_check_called_once || !g_called_once);
210 g_called_once = true; 187 g_called_once = true;
211 #endif 188 #endif
212 189
213 bool result; 190 bool result;
214 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) 191 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 #endif // !defined(OS_NACL) 240 #endif // !defined(OS_NACL)
264 241
265 void AllowMultipleInitializeCallsForTesting() { 242 void AllowMultipleInitializeCallsForTesting() {
266 #if !defined(NDEBUG) && !defined(OS_NACL) 243 #if !defined(NDEBUG) && !defined(OS_NACL)
267 g_check_called_once = false; 244 g_check_called_once = false;
268 #endif 245 #endif
269 } 246 }
270 247
271 } // namespace i18n 248 } // namespace i18n
272 } // namespace base 249 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/icu_util.h ('k') | components/html_viewer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698