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

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

Issue 1542323002: Switch to standard integer types in base/i18n/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: header Created 5 years 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') | base/i18n/message_formatter.h » ('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
11 #include <string> 11 #include <string>
12 12
13 #include "base/debug/alias.h" 13 #include "base/debug/alias.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/memory_mapped_file.h" 15 #include "base/files/memory_mapped_file.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/sys_string_conversions.h" 19 #include "base/strings/sys_string_conversions.h"
20 #include "build/build_config.h"
20 #include "third_party/icu/source/common/unicode/putil.h" 21 #include "third_party/icu/source/common/unicode/putil.h"
21 #include "third_party/icu/source/common/unicode/udata.h" 22 #include "third_party/icu/source/common/unicode/udata.h"
22 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 23 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
23 #include "third_party/icu/source/i18n/unicode/timezone.h" 24 #include "third_party/icu/source/i18n/unicode/timezone.h"
24 #endif 25 #endif
25 26
26 #if defined(OS_ANDROID) 27 #if defined(OS_ANDROID)
27 #include "base/android/apk_assets.h" 28 #include "base/android/apk_assets.h"
28 #endif 29 #endif
29 30
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 149 }
149 150
150 scoped_ptr<MemoryMappedFile> icudtl_mapped_file(new MemoryMappedFile()); 151 scoped_ptr<MemoryMappedFile> icudtl_mapped_file(new MemoryMappedFile());
151 if (!icudtl_mapped_file->Initialize(File(data_fd), data_region)) { 152 if (!icudtl_mapped_file->Initialize(File(data_fd), data_region)) {
152 LOG(ERROR) << "Couldn't mmap icu data file"; 153 LOG(ERROR) << "Couldn't mmap icu data file";
153 return false; 154 return false;
154 } 155 }
155 g_icudtl_mapped_file = icudtl_mapped_file.release(); 156 g_icudtl_mapped_file = icudtl_mapped_file.release();
156 157
157 UErrorCode err = U_ZERO_ERROR; 158 UErrorCode err = U_ZERO_ERROR;
158 udata_setCommonData(const_cast<uint8*>(g_icudtl_mapped_file->data()), &err); 159 udata_setCommonData(const_cast<uint8_t*>(g_icudtl_mapped_file->data()), &err);
159 return err == U_ZERO_ERROR; 160 return err == U_ZERO_ERROR;
160 } 161 }
161 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 162 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
162 #endif // !defined(OS_NACL) 163 #endif // !defined(OS_NACL)
163 164
164 } // namespace 165 } // namespace
165 166
166 #if !defined(OS_NACL) 167 #if !defined(OS_NACL)
167 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 168 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
168 #if defined(OS_ANDROID) 169 #if defined(OS_ANDROID)
169 bool InitializeICUWithFileDescriptor( 170 bool InitializeICUWithFileDescriptor(
170 PlatformFile data_fd, 171 PlatformFile data_fd,
171 const MemoryMappedFile::Region& data_region) { 172 const MemoryMappedFile::Region& data_region) {
172 #if !defined(NDEBUG) 173 #if !defined(NDEBUG)
173 DCHECK(!g_check_called_once || !g_called_once); 174 DCHECK(!g_check_called_once || !g_called_once);
174 g_called_once = true; 175 g_called_once = true;
175 #endif 176 #endif
176 return InitializeICUWithFileDescriptorInternal(data_fd, data_region); 177 return InitializeICUWithFileDescriptorInternal(data_fd, data_region);
177 } 178 }
178 179
179 PlatformFile GetIcuDataFileHandle(MemoryMappedFile::Region* out_region) { 180 PlatformFile GetIcuDataFileHandle(MemoryMappedFile::Region* out_region) {
180 CHECK_NE(g_icudtl_pf, kInvalidPlatformFile); 181 CHECK_NE(g_icudtl_pf, kInvalidPlatformFile);
181 *out_region = g_icudtl_region; 182 *out_region = g_icudtl_region;
182 return g_icudtl_pf; 183 return g_icudtl_pf;
183 } 184 }
184 #endif 185 #endif
185 186
186 const uint8* GetRawIcuMemory() { 187 const uint8_t* GetRawIcuMemory() {
187 CHECK(g_icudtl_mapped_file); 188 CHECK(g_icudtl_mapped_file);
188 return g_icudtl_mapped_file->data(); 189 return g_icudtl_mapped_file->data();
189 } 190 }
190 191
191 bool InitializeICUFromRawMemory(const uint8* raw_memory) { 192 bool InitializeICUFromRawMemory(const uint8_t* raw_memory) {
192 #if !defined(COMPONENT_BUILD) 193 #if !defined(COMPONENT_BUILD)
193 #if !defined(NDEBUG) 194 #if !defined(NDEBUG)
194 DCHECK(!g_check_called_once || !g_called_once); 195 DCHECK(!g_check_called_once || !g_called_once);
195 g_called_once = true; 196 g_called_once = true;
196 #endif 197 #endif
197 198
198 UErrorCode err = U_ZERO_ERROR; 199 UErrorCode err = U_ZERO_ERROR;
199 udata_setCommonData(const_cast<uint8*>(raw_memory), &err); 200 udata_setCommonData(const_cast<uint8_t*>(raw_memory), &err);
200 return err == U_ZERO_ERROR; 201 return err == U_ZERO_ERROR;
201 #else 202 #else
202 return true; 203 return true;
203 #endif 204 #endif
204 } 205 }
205 206
206 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 207 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
207 208
208 bool InitializeICU() { 209 bool InitializeICU() {
209 #if !defined(NDEBUG) 210 #if !defined(NDEBUG)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 #endif // !defined(OS_NACL) 265 #endif // !defined(OS_NACL)
265 266
266 void AllowMultipleInitializeCallsForTesting() { 267 void AllowMultipleInitializeCallsForTesting() {
267 #if !defined(NDEBUG) && !defined(OS_NACL) 268 #if !defined(NDEBUG) && !defined(OS_NACL)
268 g_check_called_once = false; 269 g_check_called_once = false;
269 #endif 270 #endif
270 } 271 }
271 272
272 } // namespace i18n 273 } // namespace i18n
273 } // namespace base 274 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/icu_util.h ('k') | base/i18n/message_formatter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698