OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #endif | 61 #endif |
62 | 62 |
63 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) | 63 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED) |
64 // We expect to find the ICU data module alongside the current module. | 64 // We expect to find the ICU data module alongside the current module. |
65 FilePath data_path; | 65 FilePath data_path; |
66 PathService::Get(base::DIR_MODULE, &data_path); | 66 PathService::Get(base::DIR_MODULE, &data_path); |
67 data_path = data_path.AppendASCII(ICU_UTIL_DATA_SHARED_MODULE_NAME); | 67 data_path = data_path.AppendASCII(ICU_UTIL_DATA_SHARED_MODULE_NAME); |
68 | 68 |
69 HMODULE module = LoadLibrary(data_path.value().c_str()); | 69 HMODULE module = LoadLibrary(data_path.value().c_str()); |
70 if (!module) { | 70 if (!module) { |
71 LOG(ERROR) << "Failed to load " << ICU_UTIL_DATA_SHARED_MODULE_NAME; | 71 DLOG(ERROR) << "Failed to load " << ICU_UTIL_DATA_SHARED_MODULE_NAME; |
72 return false; | 72 return false; |
73 } | 73 } |
74 | 74 |
75 FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL); | 75 FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL); |
76 if (!addr) { | 76 if (!addr) { |
77 LOG(ERROR) << ICU_UTIL_DATA_SYMBOL << ": not found in " | 77 DLOG(ERROR) << ICU_UTIL_DATA_SYMBOL << ": not found in " |
78 << ICU_UTIL_DATA_SHARED_MODULE_NAME; | 78 << ICU_UTIL_DATA_SHARED_MODULE_NAME; |
79 return false; | 79 return false; |
80 } | 80 } |
81 | 81 |
82 UErrorCode err = U_ZERO_ERROR; | 82 UErrorCode err = U_ZERO_ERROR; |
83 udata_setCommonData(reinterpret_cast<void*>(addr), &err); | 83 udata_setCommonData(reinterpret_cast<void*>(addr), &err); |
84 return err == U_ZERO_ERROR; | 84 return err == U_ZERO_ERROR; |
85 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC) | 85 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC) |
86 // Mac/Linux bundle the ICU data in. | 86 // Mac/Linux bundle the ICU data in. |
87 return true; | 87 return true; |
(...skipping 18 matching lines...) Expand all Loading... |
106 // cause any problems. | 106 // cause any problems. |
107 | 107 |
108 // Chrome doesn't normally shut down ICU, so the mapped data shouldn't ever | 108 // Chrome doesn't normally shut down ICU, so the mapped data shouldn't ever |
109 // be released. | 109 // be released. |
110 static file_util::MemoryMappedFile mapped_file; | 110 static file_util::MemoryMappedFile mapped_file; |
111 if (!mapped_file.IsValid()) { | 111 if (!mapped_file.IsValid()) { |
112 // Assume it is in the MainBundle's Resources directory. | 112 // Assume it is in the MainBundle's Resources directory. |
113 FilePath data_path = | 113 FilePath data_path = |
114 base::mac::PathForMainAppBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME)); | 114 base::mac::PathForMainAppBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME)); |
115 if (data_path.empty()) { | 115 if (data_path.empty()) { |
116 LOG(ERROR) << ICU_UTIL_DATA_FILE_NAME << " not found in bundle"; | 116 DLOG(ERROR) << ICU_UTIL_DATA_FILE_NAME << " not found in bundle"; |
117 return false; | 117 return false; |
118 } | 118 } |
119 if (!mapped_file.Initialize(data_path)) { | 119 if (!mapped_file.Initialize(data_path)) { |
120 LOG(ERROR) << "Couldn't mmap " << data_path.value(); | 120 DLOG(ERROR) << "Couldn't mmap " << data_path.value(); |
121 return false; | 121 return false; |
122 } | 122 } |
123 } | 123 } |
124 UErrorCode err = U_ZERO_ERROR; | 124 UErrorCode err = U_ZERO_ERROR; |
125 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); | 125 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); |
126 return err == U_ZERO_ERROR; | 126 return err == U_ZERO_ERROR; |
127 #endif // OS check | 127 #endif // OS check |
128 #endif | 128 #endif |
129 } | 129 } |
130 | 130 |
131 } // namespace icu_util | 131 } // namespace icu_util |
OLD | NEW |