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

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

Issue 1802713002: Capture more details about failure to load ICU data file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: non win Created 4 years, 9 months 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 | « no previous file | no next file » | 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Assert that we are not called more than once. Even though calling this 56 // Assert that we are not called more than once. Even though calling this
57 // function isn't harmful (ICU can handle it), being called twice probably 57 // function isn't harmful (ICU can handle it), being called twice probably
58 // indicates a programming error. 58 // indicates a programming error.
59 bool g_check_called_once = true; 59 bool g_check_called_once = true;
60 bool g_called_once = false; 60 bool g_called_once = false;
61 #endif // !defined(NDEBUG) 61 #endif // !defined(NDEBUG)
62 62
63 // To debug http://crbug.com/445616. 63 // To debug http://crbug.com/445616.
64 int g_debug_icu_last_error; 64 int g_debug_icu_last_error;
65 int g_debug_icu_load; 65 int g_debug_icu_load;
66 int g_debug_icu_pf_last_error;
67 int g_debug_icu_pf_error_details;
66 68
67 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 69 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
68 // Use an unversioned file name to simplify a icu version update down the road. 70 // Use an unversioned file name to simplify a icu version update down the road.
69 // No need to change the filename in multiple places (gyp files, windows 71 // No need to change the filename in multiple places (gyp files, windows
70 // build pkg configurations, etc). 'l' stands for Little Endian. 72 // build pkg configurations, etc). 'l' stands for Little Endian.
71 // This variable is exported through the header file. 73 // This variable is exported through the header file.
72 const char kIcuDataFileName[] = "icudtl.dat"; 74 const char kIcuDataFileName[] = "icudtl.dat";
73 #if defined(OS_ANDROID) 75 #if defined(OS_ANDROID)
74 const char kAndroidAssetsIcuDataFileName[] = "assets/icudtl.dat"; 76 const char kAndroidAssetsIcuDataFileName[] = "assets/icudtl.dat";
75 #endif 77 #endif
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 data_path = override_data_path; 140 data_path = override_data_path;
139 } 141 }
140 #endif // !defined(OS_IOS) 142 #endif // !defined(OS_IOS)
141 if (data_path.empty()) { 143 if (data_path.empty()) {
142 LOG(ERROR) << kIcuDataFileName << " not found in bundle"; 144 LOG(ERROR) << kIcuDataFileName << " not found in bundle";
143 return; 145 return;
144 } 146 }
145 #endif // !defined(OS_MACOSX) 147 #endif // !defined(OS_MACOSX)
146 File file(data_path, File::FLAG_OPEN | File::FLAG_READ); 148 File file(data_path, File::FLAG_OPEN | File::FLAG_READ);
147 if (file.IsValid()) { 149 if (file.IsValid()) {
150 // TODO(scottmg): http://crbug.com/445616.
151 g_debug_icu_pf_last_error = 0;
152 g_debug_icu_pf_error_details = 0;
153
148 g_icudtl_pf = file.TakePlatformFile(); 154 g_icudtl_pf = file.TakePlatformFile();
149 g_icudtl_region = MemoryMappedFile::Region::kWholeFile; 155 g_icudtl_region = MemoryMappedFile::Region::kWholeFile;
150 } 156 }
157 #if defined(OS_WIN)
158 else {
159 // TODO(scottmg): http://crbug.com/445616.
160 g_debug_icu_pf_last_error = ::GetLastError();
161 g_debug_icu_pf_error_details = file.error_details();
162 }
163 #endif // OS_WIN
151 } 164 }
152 165
153 bool InitializeICUWithFileDescriptorInternal( 166 bool InitializeICUWithFileDescriptorInternal(
154 PlatformFile data_fd, 167 PlatformFile data_fd,
155 const MemoryMappedFile::Region& data_region) { 168 const MemoryMappedFile::Region& data_region) {
156 // This can be called multiple times in tests. 169 // This can be called multiple times in tests.
157 if (g_icudtl_mapped_file) { 170 if (g_icudtl_mapped_file) {
158 g_debug_icu_load = 0; // To debug http://crbug.com/445616. 171 g_debug_icu_load = 0; // To debug http://crbug.com/445616.
159 return true; 172 return true;
160 } 173 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // Instead, we map the file in and hand off the data so the sandbox won't 278 // Instead, we map the file in and hand off the data so the sandbox won't
266 // cause any problems. 279 // cause any problems.
267 LazyInitIcuDataFile(); 280 LazyInitIcuDataFile();
268 result = 281 result =
269 InitializeICUWithFileDescriptorInternal(g_icudtl_pf, g_icudtl_region); 282 InitializeICUWithFileDescriptorInternal(g_icudtl_pf, g_icudtl_region);
270 #if defined(OS_WIN) 283 #if defined(OS_WIN)
271 int debug_icu_load = g_debug_icu_load; 284 int debug_icu_load = g_debug_icu_load;
272 debug::Alias(&debug_icu_load); 285 debug::Alias(&debug_icu_load);
273 int debug_icu_last_error = g_debug_icu_last_error; 286 int debug_icu_last_error = g_debug_icu_last_error;
274 debug::Alias(&debug_icu_last_error); 287 debug::Alias(&debug_icu_last_error);
288 int debug_icu_pf_last_error = g_debug_icu_pf_last_error;
289 debug::Alias(&debug_icu_pf_last_error);
290 int debug_icu_pf_error_details = g_debug_icu_pf_error_details;
291 debug::Alias(&debug_icu_pf_error_details);
275 CHECK(result); // TODO(scottmg): http://crbug.com/445616 292 CHECK(result); // TODO(scottmg): http://crbug.com/445616
276 #endif 293 #endif
277 #endif 294 #endif
278 295
279 // To respond to the timezone change properly, the default timezone 296 // To respond to the timezone change properly, the default timezone
280 // cache in ICU has to be populated on starting up. 297 // cache in ICU has to be populated on starting up.
281 // TODO(jungshik): Some callers do not care about tz at all. If necessary, 298 // TODO(jungshik): Some callers do not care about tz at all. If necessary,
282 // add a boolean argument to this function to init'd the default tz only 299 // add a boolean argument to this function to init'd the default tz only
283 // when requested. 300 // when requested.
284 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 301 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
285 if (result) 302 if (result)
286 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); 303 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
287 #endif 304 #endif
288 return result; 305 return result;
289 } 306 }
290 #endif // !defined(OS_NACL) 307 #endif // !defined(OS_NACL)
291 308
292 void AllowMultipleInitializeCallsForTesting() { 309 void AllowMultipleInitializeCallsForTesting() {
293 #if !defined(NDEBUG) && !defined(OS_NACL) 310 #if !defined(NDEBUG) && !defined(OS_NACL)
294 g_check_called_once = false; 311 g_check_called_once = false;
295 #endif 312 #endif
296 } 313 }
297 314
298 } // namespace i18n 315 } // namespace i18n
299 } // namespace base 316 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698