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

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

Issue 1425853003: mandoline: Fix ICU initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to to 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)
167 bool InitializeICUWithFileDescriptor( 168 bool InitializeICUWithFileDescriptor(
168 PlatformFile data_fd, 169 PlatformFile data_fd,
169 const MemoryMappedFile::Region& data_region) { 170 const MemoryMappedFile::Region& data_region) {
170 #if !defined(NDEBUG) 171 #if !defined(NDEBUG)
171 DCHECK(!g_check_called_once || !g_called_once); 172 DCHECK(!g_check_called_once || !g_called_once);
172 g_called_once = true; 173 g_called_once = true;
173 #endif 174 #endif
174 return InitializeICUWithFileDescriptorInternal(data_fd, data_region); 175 return InitializeICUWithFileDescriptorInternal(data_fd, data_region);
175 } 176 }
176 177
177 PlatformFile GetIcuDataFileHandle(MemoryMappedFile::Region* out_region) { 178 PlatformFile GetIcuDataFileHandle(MemoryMappedFile::Region* out_region) {
178 CHECK_NE(g_icudtl_pf, kInvalidPlatformFile); 179 CHECK_NE(g_icudtl_pf, kInvalidPlatformFile);
179 *out_region = g_icudtl_region; 180 *out_region = g_icudtl_region;
180 return g_icudtl_pf; 181 return g_icudtl_pf;
181 } 182 }
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
182 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 205 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
183 206
184 bool InitializeICU() { 207 bool InitializeICU() {
185 #if !defined(NDEBUG) 208 #if !defined(NDEBUG)
186 DCHECK(!g_check_called_once || !g_called_once); 209 DCHECK(!g_check_called_once || !g_called_once);
187 g_called_once = true; 210 g_called_once = true;
188 #endif 211 #endif
189 212
190 bool result; 213 bool result;
191 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) 214 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 #endif // !defined(OS_NACL) 263 #endif // !defined(OS_NACL)
241 264
242 void AllowMultipleInitializeCallsForTesting() { 265 void AllowMultipleInitializeCallsForTesting() {
243 #if !defined(NDEBUG) && !defined(OS_NACL) 266 #if !defined(NDEBUG) && !defined(OS_NACL)
244 g_check_called_once = false; 267 g_check_called_once = false;
245 #endif 268 #endif
246 } 269 }
247 270
248 } // namespace i18n 271 } // namespace i18n
249 } // namespace base 272 } // 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