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

Unified Diff: base/i18n/icu_util.cc

Issue 1147213004: Store and load icudtl.dat directly from the apk rather than extracting on start-up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@load-from-apk
Patch Set: fix compile Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: base/i18n/icu_util.cc
diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc
index cd905fe2b6bf56b1f394686fb3172a1e69033bad..1dd54cd606d8b750663a471b4efd277e5ec4980f 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)

Powered by Google App Engine
This is Rietveld 408576698