From f3930cfae7a93c5065588c9ba7be5c6927f46588 Mon Sep 17 00:00:00 2001 From: agrieve Date: Fri, 19 Jun 2015 08:35:48 -0700 Subject: Store and load icudtl.dat directly from the apk rather than extracting on start-up. Also changes so that browser process caches a FD to the file rather than re-opening it for each child process. We store icudtl.dat uncompressed in the apk now, increasing the apk size, but saving 6mb on-disk. BUG=394502 Review URL: https://codereview.chromium.org/1147213004 Cr-Commit-Position: refs/heads/master@{#335261} --- base/i18n/icu_util.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'base') diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc index cd905fe..1dd54cd 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 @@ -57,6 +61,9 @@ bool g_called_once = false; // build pkg configurations, etc). 'l' stands for Little Endian. // This variable is exported through the header file. const char kIcuDataFileName[] = "icudtl.dat"; +#if defined(OS_ANDROID) +const char kAndroidAssetsIcuDataFileName[] = "assets/icudtl.dat"; +#endif // File handle intentionally never closed. Not using File here because its // Windows implementation guards against two instances owning the same @@ -75,6 +82,15 @@ void LazyInitIcuDataFile() { if (g_icudtl_pf != kInvalidPlatformFile) { return; } +#if defined(OS_ANDROID) + int fd = base::android::OpenApkAsset(kAndroidAssetsIcuDataFileName, + &g_icudtl_region); + g_icudtl_pf = fd; + if (fd != -1) { + return; + } +// For unit tests, data file is located on disk, so try there as a fallback. +#endif // defined(OS_ANDROID) #if !defined(OS_MACOSX) FilePath data_path; #if defined(OS_WIN) -- cgit v1.1