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

Unified Diff: base/i18n/icu_util.cc

Issue 317833006: [ICU] Avoid reading ICU data files in render process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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
« no previous file with comments | « base/i18n/icu_util.h ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/icu_util.cc
diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc
index 6001ea10d050e502b07b8c53b71c493a0e5956f9..e0bd62cc50b0fe824d25beacbc94bb42e20908b7 100644
--- a/base/i18n/icu_util.cc
+++ b/base/i18n/icu_util.cc
@@ -4,8 +4,6 @@
#include "base/i18n/icu_util.h"
-#include "build/build_config.h"
-
#if defined(OS_WIN)
#include <windows.h>
#endif
@@ -55,6 +53,33 @@ bool g_check_called_once = true;
#endif
}
+
+#if defined(OS_ANDROID)
+bool InitializeICUWithFileDescriptor(int data_fd) {
+#if !defined(NDEBUG)
+ DCHECK(!g_check_called_once || !g_called_once);
+ g_called_once = true;
+#endif
+
+#if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC)
+ // The ICU data is statically linked.
+ return true;
+#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE)
+ CR_DEFINE_STATIC_LOCAL(base::MemoryMappedFile, mapped_file, ());
+ if (!mapped_file.IsValid()) {
+ if (!mapped_file.Initialize(base::File(data_fd))) {
+ LOG(ERROR) << "Couldn't mmap icu data file";
+ return false;
+ }
+ }
+ UErrorCode err = U_ZERO_ERROR;
+ udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err);
+ return err == U_ZERO_ERROR;
+#endif // ICU_UTIL_DATA_FILE
+}
+#endif
+
+
bool InitializeICU() {
#if !defined(NDEBUG)
DCHECK(!g_check_called_once || !g_called_once);
« no previous file with comments | « base/i18n/icu_util.h ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698