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

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

Issue 296293002: Log InitializeICU() failures in relase build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #endif 62 #endif
63 63
64 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) 64 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED)
65 // 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.
66 FilePath data_path; 66 FilePath data_path;
67 PathService::Get(base::DIR_MODULE, &data_path); 67 PathService::Get(base::DIR_MODULE, &data_path);
68 data_path = data_path.AppendASCII(ICU_UTIL_DATA_SHARED_MODULE_NAME); 68 data_path = data_path.AppendASCII(ICU_UTIL_DATA_SHARED_MODULE_NAME);
69 69
70 HMODULE module = LoadLibrary(data_path.value().c_str()); 70 HMODULE module = LoadLibrary(data_path.value().c_str());
71 if (!module) { 71 if (!module) {
72 DLOG(ERROR) << "Failed to load " << ICU_UTIL_DATA_SHARED_MODULE_NAME; 72 LOG(ERROR) << "Failed to load " << ICU_UTIL_DATA_SHARED_MODULE_NAME;
73 return false; 73 return false;
74 } 74 }
75 75
76 FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL); 76 FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL);
77 if (!addr) { 77 if (!addr) {
78 DLOG(ERROR) << ICU_UTIL_DATA_SYMBOL << ": not found in " 78 LOG(ERROR) << ICU_UTIL_DATA_SYMBOL << ": not found in "
79 << ICU_UTIL_DATA_SHARED_MODULE_NAME; 79 << ICU_UTIL_DATA_SHARED_MODULE_NAME;
80 return false; 80 return false;
81 } 81 }
82 82
83 UErrorCode err = U_ZERO_ERROR; 83 UErrorCode err = U_ZERO_ERROR;
84 udata_setCommonData(reinterpret_cast<void*>(addr), &err); 84 udata_setCommonData(reinterpret_cast<void*>(addr), &err);
85 return err == U_ZERO_ERROR; 85 return err == U_ZERO_ERROR;
86 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC) 86 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC)
87 // The ICU data is statically linked. 87 // The ICU data is statically linked.
88 return true; 88 return true;
(...skipping 20 matching lines...) Expand all
109 // likely live in a data directory. 109 // likely live in a data directory.
110 bool path_ok = PathService::Get(base::DIR_EXE, &data_path); 110 bool path_ok = PathService::Get(base::DIR_EXE, &data_path);
111 #endif 111 #endif
112 DCHECK(path_ok); 112 DCHECK(path_ok);
113 data_path = data_path.AppendASCII(ICU_UTIL_DATA_FILE_NAME); 113 data_path = data_path.AppendASCII(ICU_UTIL_DATA_FILE_NAME);
114 #else 114 #else
115 // Assume it is in the framework bundle's Resources directory. 115 // Assume it is in the framework bundle's Resources directory.
116 FilePath data_path = 116 FilePath data_path =
117 base::mac::PathForFrameworkBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME)); 117 base::mac::PathForFrameworkBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME));
118 if (data_path.empty()) { 118 if (data_path.empty()) {
119 DLOG(ERROR) << ICU_UTIL_DATA_FILE_NAME << " not found in bundle"; 119 LOG(ERROR) << ICU_UTIL_DATA_FILE_NAME << " not found in bundle";
120 return false; 120 return false;
121 } 121 }
122 #endif // OS check 122 #endif // OS check
123 if (!mapped_file.Initialize(data_path)) { 123 if (!mapped_file.Initialize(data_path)) {
124 DLOG(ERROR) << "Couldn't mmap " << data_path.AsUTF8Unsafe(); 124 LOG(ERROR) << "Couldn't mmap " << data_path.AsUTF8Unsafe();
125 return false; 125 return false;
126 } 126 }
127 } 127 }
128 UErrorCode err = U_ZERO_ERROR; 128 UErrorCode err = U_ZERO_ERROR;
129 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); 129 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err);
130 return err == U_ZERO_ERROR; 130 return err == U_ZERO_ERROR;
131 #endif 131 #endif
132 } 132 }
133 133
134 void AllowMultipleInitializeCallsForTesting() { 134 void AllowMultipleInitializeCallsForTesting() {
135 #if !defined(NDEBUG) 135 #if !defined(NDEBUG)
136 g_check_called_once = false; 136 g_check_called_once = false;
137 #endif 137 #endif
138 } 138 }
139 139
140 } // namespace i18n 140 } // namespace i18n
141 } // namespace base 141 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698