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

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

Issue 1076623004: Add temporary CHECKs in ICU init to attempt to more closely locate crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: #if win the checks 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 unified diff | Download patch
« 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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/debug/alias.h"
13 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
14 #include "base/files/memory_mapped_file.h" 15 #include "base/files/memory_mapped_file.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/path_service.h" 17 #include "base/path_service.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "base/strings/sys_string_conversions.h" 19 #include "base/strings/sys_string_conversions.h"
19 #include "third_party/icu/source/common/unicode/putil.h" 20 #include "third_party/icu/source/common/unicode/putil.h"
20 #include "third_party/icu/source/common/unicode/udata.h" 21 #include "third_party/icu/source/common/unicode/udata.h"
21 22
22 #if defined(OS_MACOSX) 23 #if defined(OS_MACOSX)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 124
124 // Chrome doesn't normally shut down ICU, so the mapped data shouldn't ever 125 // Chrome doesn't normally shut down ICU, so the mapped data shouldn't ever
125 // be released. 126 // be released.
126 CR_DEFINE_STATIC_LOCAL(base::MemoryMappedFile, mapped_file, ()); 127 CR_DEFINE_STATIC_LOCAL(base::MemoryMappedFile, mapped_file, ());
127 if (!mapped_file.IsValid()) { 128 if (!mapped_file.IsValid()) {
128 #if !defined(OS_MACOSX) 129 #if !defined(OS_MACOSX)
129 FilePath data_path; 130 FilePath data_path;
130 #if defined(OS_WIN) 131 #if defined(OS_WIN)
131 // The data file will be in the same directory as the current module. 132 // The data file will be in the same directory as the current module.
132 bool path_ok = PathService::Get(base::DIR_MODULE, &data_path); 133 bool path_ok = PathService::Get(base::DIR_MODULE, &data_path);
134 wchar_t tmp_buffer[_MAX_PATH] = {0};
135 wcscpy_s(tmp_buffer, data_path.value().c_str());
136 base::debug::Alias(tmp_buffer);
137 CHECK(path_ok); // TODO(scottmg): http://crbug.com/445616
133 #elif defined(OS_ANDROID) 138 #elif defined(OS_ANDROID)
134 bool path_ok = PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path); 139 bool path_ok = PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path);
135 #else 140 #else
136 // For now, expect the data file to be alongside the executable. 141 // For now, expect the data file to be alongside the executable.
137 // This is sufficient while we work on unit tests, but will eventually 142 // This is sufficient while we work on unit tests, but will eventually
138 // likely live in a data directory. 143 // likely live in a data directory.
139 bool path_ok = PathService::Get(base::DIR_EXE, &data_path); 144 bool path_ok = PathService::Get(base::DIR_EXE, &data_path);
140 #endif 145 #endif
141 DCHECK(path_ok); 146 DCHECK(path_ok);
142 data_path = data_path.AppendASCII(kIcuDataFileName); 147 data_path = data_path.AppendASCII(kIcuDataFileName);
148
149 #if defined(OS_WIN)
150 // TODO(scottmg): http://crbug.com/445616
151 wchar_t tmp_buffer2[_MAX_PATH] = {0};
152 wcscpy_s(tmp_buffer2, data_path.value().c_str());
153 base::debug::Alias(tmp_buffer2);
154 #endif
155
143 #else 156 #else
144 // Assume it is in the framework bundle's Resources directory. 157 // Assume it is in the framework bundle's Resources directory.
145 base::ScopedCFTypeRef<CFStringRef> data_file_name( 158 base::ScopedCFTypeRef<CFStringRef> data_file_name(
146 SysUTF8ToCFStringRef(kIcuDataFileName)); 159 SysUTF8ToCFStringRef(kIcuDataFileName));
147 FilePath data_path = 160 FilePath data_path =
148 base::mac::PathForFrameworkBundleResource(data_file_name); 161 base::mac::PathForFrameworkBundleResource(data_file_name);
149 if (data_path.empty()) { 162 if (data_path.empty()) {
150 LOG(ERROR) << kIcuDataFileName << " not found in bundle"; 163 LOG(ERROR) << kIcuDataFileName << " not found in bundle";
151 return false; 164 return false;
152 } 165 }
153 #endif // OS check 166 #endif // OS check
154 if (!mapped_file.Initialize(data_path)) { 167 if (!mapped_file.Initialize(data_path)) {
168 #if defined(OS_WIN)
169 CHECK(false); // TODO(scottmg): http://crbug.com/445616
170 #endif
155 LOG(ERROR) << "Couldn't mmap " << data_path.AsUTF8Unsafe(); 171 LOG(ERROR) << "Couldn't mmap " << data_path.AsUTF8Unsafe();
156 return false; 172 return false;
157 } 173 }
158 } 174 }
159 UErrorCode err = U_ZERO_ERROR; 175 UErrorCode err = U_ZERO_ERROR;
160 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); 176 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err);
177 #if defined(OS_WIN)
178 CHECK(err == U_ZERO_ERROR); // TODO(scottmg): http://crbug.com/445616
179 #endif
161 return err == U_ZERO_ERROR; 180 return err == U_ZERO_ERROR;
162 #endif 181 #endif
163 } 182 }
164 #endif 183 #endif
165 184
166 void AllowMultipleInitializeCallsForTesting() { 185 void AllowMultipleInitializeCallsForTesting() {
167 #if !defined(NDEBUG) 186 #if !defined(NDEBUG)
168 g_check_called_once = false; 187 g_check_called_once = false;
169 #endif 188 #endif
170 } 189 }
171 190
172 } // namespace i18n 191 } // namespace i18n
173 } // namespace base 192 } // 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