summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authoragrieve <agrieve@chromium.org>2015-06-19 08:35:48 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-19 15:36:17 +0000
commitf3930cfae7a93c5065588c9ba7be5c6927f46588 (patch)
treebbfc5d0f5e8070abe3966b5698c90411bb5144da /base
parent97de162a0bd8dc7dc012c31e9c7b1a981ef23acb (diff)
downloadchromium_src-f3930cfae7a93c5065588c9ba7be5c6927f46588.zip
chromium_src-f3930cfae7a93c5065588c9ba7be5c6927f46588.tar.gz
chromium_src-f3930cfae7a93c5065588c9ba7be5c6927f46588.tar.bz2
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}
Diffstat (limited to 'base')
-rw-r--r--base/i18n/icu_util.cc16
1 files changed, 16 insertions, 0 deletions
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)