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

Side by Side Diff: base/i18n/icu_util.cc

Issue 190663012: Run ContentMain in a browser_test's browser process. This removes duplication of code in the browse… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: try to fix android by restoring old path just for it Created 6 years, 9 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
« no previous file with comments | « base/i18n/icu_util.h ('k') | chrome/browser/apps/web_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 26 matching lines...) Expand all
37 #elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED 37 #elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED
38 #define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat" 38 #define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
39 #if defined(OS_WIN) 39 #if defined(OS_WIN)
40 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll" 40 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
41 #endif 41 #endif
42 #endif 42 #endif
43 43
44 namespace base { 44 namespace base {
45 namespace i18n { 45 namespace i18n {
46 46
47 namespace {
48
49 #if !defined(NDEBUG)
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
52 // indicates a programming error.
53 bool g_called_once = false;
54 bool g_check_called_once = true;
55 #endif
56 }
57
47 bool InitializeICU() { 58 bool InitializeICU() {
48 #ifndef NDEBUG 59 #if !defined(NDEBUG)
49 // Assert that we are not called more than once. Even though calling this 60 DCHECK(!g_check_called_once || !g_called_once);
50 // function isn't harmful (ICU can handle it), being called twice probably 61 g_called_once = true;
51 // indicates a programming error.
52 static bool called_once = false;
53 DCHECK(!called_once);
54 called_once = true;
55 #endif 62 #endif
56 63
57 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) 64 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED)
58 // We expect to find the ICU data module alongside the current module. 65 // We expect to find the ICU data module alongside the current module.
59 FilePath data_path; 66 FilePath data_path;
60 PathService::Get(base::DIR_MODULE, &data_path); 67 PathService::Get(base::DIR_MODULE, &data_path);
61 data_path = data_path.AppendASCII(ICU_UTIL_DATA_SHARED_MODULE_NAME); 68 data_path = data_path.AppendASCII(ICU_UTIL_DATA_SHARED_MODULE_NAME);
62 69
63 HMODULE module = LoadLibrary(data_path.value().c_str()); 70 HMODULE module = LoadLibrary(data_path.value().c_str());
64 if (!module) { 71 if (!module) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 DLOG(ERROR) << "Couldn't mmap " << data_path.AsUTF8Unsafe(); 124 DLOG(ERROR) << "Couldn't mmap " << data_path.AsUTF8Unsafe();
118 return false; 125 return false;
119 } 126 }
120 } 127 }
121 UErrorCode err = U_ZERO_ERROR; 128 UErrorCode err = U_ZERO_ERROR;
122 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); 129 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err);
123 return err == U_ZERO_ERROR; 130 return err == U_ZERO_ERROR;
124 #endif 131 #endif
125 } 132 }
126 133
134 void AllowMultipleInitializeCallsForTesting() {
135 #if !defined(NDEBUG)
136 g_check_called_once = false;
137 #endif
138 }
139
127 } // namespace i18n 140 } // namespace i18n
128 } // namespace base 141 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/icu_util.h ('k') | chrome/browser/apps/web_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698