Chromium Code Reviews| Index: base/i18n/icu_util.cc |
| diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc |
| index a9f0b129633cd596934b8cf7d680d1fcca7f7a8a..bdf41d86937d2fde518a67d083091ee172f284de 100644 |
| --- a/base/i18n/icu_util.cc |
| +++ b/base/i18n/icu_util.cc |
| @@ -23,6 +23,10 @@ |
| #include "third_party/icu/source/i18n/unicode/timezone.h" |
| #endif |
| +#if defined(OS_ANDROID) |
| +#include "base/android/apk_assets.h" |
| +#endif |
| + |
| #if defined(OS_MACOSX) |
| #include "base/mac/foundation_util.h" |
| #endif |
| @@ -118,7 +122,16 @@ bool InitializeICU() { |
| #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC) |
| // The ICU data is statically linked. |
| result = true; |
| -#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) |
| +#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) && defined(OS_ANDROID) |
| + base::MemoryMappedFile::Region region; |
| + int fd = base::android::OpenApkAsset(kIcuDataFileName, ®ion); |
| + CHECK(fd != -1); |
|
Lei Zhang
2015/06/02 20:31:15
CHECK_GE(fd, 0);
|
| + |
| +#if !defined(NDEBUG) |
| + g_called_once = false; |
|
Lei Zhang
2015/06/02 20:31:15
Can you explain what's going on here?
Yaron
2015/06/02 21:19:40
In comment or why this is happening? It was buggin
|
| +#endif |
| + result = InitializeICUWithFileDescriptor(fd, region); |
| +#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) && !defined(OS_ANDROID) |
| // If the ICU data directory is set, ICU won't actually load the data until |
| // it is needed. This can fail if the process is sandboxed at that time. |
| // Instead, we map the file in and hand off the data so the sandbox won't |
| @@ -137,8 +150,6 @@ bool InitializeICU() { |
| wcscpy_s(tmp_buffer, data_path.value().c_str()); |
| debug::Alias(tmp_buffer); |
| CHECK(path_ok); // TODO(scottmg): http://crbug.com/445616 |
| -#elif defined(OS_ANDROID) |
| - bool path_ok = PathService::Get(DIR_ANDROID_APP_DATA, &data_path); |
| #else |
| // For now, expect the data file to be alongside the executable. |
| // This is sufficient while we work on unit tests, but will eventually |