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

Unified Diff: base/i18n/icu_util.cc

Issue 697203006: Update the ICU's default timezone in render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: init tz only when icu data load succ. Created 5 years, 8 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 8bbbc049e8ae2d3606d3781eef13d49e30b32ff1..beec249534fda38bddd9941996d4e14f64c9933d 100644
--- a/base/i18n/icu_util.cc
+++ b/base/i18n/icu_util.cc
@@ -18,6 +18,9 @@
#include "base/strings/sys_string_conversions.h"
#include "third_party/icu/source/common/unicode/putil.h"
#include "third_party/icu/source/common/unicode/udata.h"
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#include "third_party/icu/source/i18n/unicode/timezone.h"
+#endif
#if defined(OS_MACOSX)
#include "base/mac/foundation_util.h"
@@ -90,6 +93,7 @@ bool InitializeICU() {
g_called_once = true;
#endif
+ bool result;
#if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED)
// We expect to find the ICU data module alongside the current module.
FilePath data_path;
@@ -111,10 +115,10 @@ bool InitializeICU() {
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
- return err == U_ZERO_ERROR;
+ result = (err == U_ZERO_ERROR);
#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC)
// The ICU data is statically linked.
- return true;
+ result = true;
#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE)
// 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.
@@ -158,8 +162,19 @@ bool InitializeICU() {
}
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err);
- return err == U_ZERO_ERROR;
+ result = (err == U_ZERO_ERROR);
+#endif
+
+// To respond to the timezone change properly, the default timezone
+// cache in ICU has to be populated on starting up.
+// TODO(jungshik): Some callers do not care about tz at all. If necessary,
+// add a boolean argument to this function to init'd the default tz only
+// when requested.
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ if (result)
+ scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
#endif
+ return result;
}
#endif
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.h » ('j') | content/browser/time_zone_monitor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698