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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/i18n/icu_util.h" 5 #include "base/i18n/icu_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 #if !defined(NDEBUG) 49 #if !defined(NDEBUG)
50 // Assert that we are not called more than once. Even though calling this 50 // Assert that we are not called more than once. Even though calling this
51 // function isn't harmful (ICU can handle it), being called twice probably 51 // function isn't harmful (ICU can handle it), being called twice probably
52 // indicates a programming error. 52 // indicates a programming error.
53 bool g_called_once = false; 53 bool g_called_once = false;
54 bool g_check_called_once = true; 54 bool g_check_called_once = true;
55 #endif 55 #endif
56 } 56 }
57 57
58
59 #if defined(OS_ANDROID)
60 bool InitializeICU(int data_fd) {
jungshik at Google 2014/06/05 23:30:57 This should be no-op if DATA_STATIC is used.
Feng Qian 2014/06/06 17:40:31 What about DATA_SHARED case? Would it be the same
61 #if !defined(NDEBUG)
62 DCHECK(!g_check_called_once || !g_called_once);
63 g_called_once = true;
64 #endif
65
66 CR_DEFINE_STATIC_LOCAL(base::MemoryMappedFile, mapped_file, ());
67 if (!mapped_file.IsValid()) {
68 if (!mapped_file.Initialize(base::File(data_fd))) {
69 LOG(ERROR) << "Couldn't mmap icu data file";
70 return false;
71 }
72 }
73 UErrorCode err = U_ZERO_ERROR;
74 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err);
75 return err == U_ZERO_ERROR;
76 }
77 #endif
78
79
58 bool InitializeICU() { 80 bool InitializeICU() {
59 #if !defined(NDEBUG) 81 #if !defined(NDEBUG)
60 DCHECK(!g_check_called_once || !g_called_once); 82 DCHECK(!g_check_called_once || !g_called_once);
61 g_called_once = true; 83 g_called_once = true;
62 #endif 84 #endif
63 85
64 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) 86 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED)
65 // We expect to find the ICU data module alongside the current module. 87 // We expect to find the ICU data module alongside the current module.
66 FilePath data_path; 88 FilePath data_path;
67 PathService::Get(base::DIR_MODULE, &data_path); 89 PathService::Get(base::DIR_MODULE, &data_path);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 154 }
133 155
134 void AllowMultipleInitializeCallsForTesting() { 156 void AllowMultipleInitializeCallsForTesting() {
135 #if !defined(NDEBUG) 157 #if !defined(NDEBUG)
136 g_check_called_once = false; 158 g_check_called_once = false;
137 #endif 159 #endif
138 } 160 }
139 161
140 } // namespace i18n 162 } // namespace i18n
141 } // namespace base 163 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698