Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/files/memory_mapped_file.h" | 16 #include "base/files/memory_mapped_file.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/sys_string_conversions.h" | 20 #include "base/strings/sys_string_conversions.h" |
| 21 #if defined(OS_WIN) | |
| 22 #include "base/strings/utf_string_conversions.h" | |
| 23 #endif | |
| 21 #include "third_party/icu/source/common/unicode/putil.h" | 24 #include "third_party/icu/source/common/unicode/putil.h" |
| 22 #include "third_party/icu/source/common/unicode/udata.h" | 25 #include "third_party/icu/source/common/unicode/udata.h" |
| 23 | 26 |
| 24 #if defined(OS_MACOSX) | 27 #if defined(OS_MACOSX) |
| 25 #include "base/mac/foundation_util.h" | 28 #include "base/mac/foundation_util.h" |
| 26 #endif | 29 #endif |
| 27 | 30 |
| 28 #define ICU_UTIL_DATA_FILE 0 | 31 #define ICU_UTIL_DATA_FILE 0 |
| 29 #define ICU_UTIL_DATA_SHARED 1 | 32 #define ICU_UTIL_DATA_SHARED 1 |
| 30 #define ICU_UTIL_DATA_STATIC 2 | 33 #define ICU_UTIL_DATA_STATIC 2 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 data_path = data_path.AppendASCII(ICU_UTIL_DATA_FILE_NAME); | 100 data_path = data_path.AppendASCII(ICU_UTIL_DATA_FILE_NAME); |
| 98 #else | 101 #else |
| 99 FilePath data_path = | 102 FilePath data_path = |
| 100 base::mac::PathForFrameworkBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME)); | 103 base::mac::PathForFrameworkBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME)); |
| 101 if (data_path.empty()) { | 104 if (data_path.empty()) { |
| 102 DLOG(ERROR) << ICU_UTIL_DATA_FILE_NAME << " not found in bundle"; | 105 DLOG(ERROR) << ICU_UTIL_DATA_FILE_NAME << " not found in bundle"; |
| 103 return false; | 106 return false; |
| 104 } | 107 } |
| 105 #endif // OS check | 108 #endif // OS check |
| 106 if (!mapped_file.Initialize(data_path)) { | 109 if (!mapped_file.Initialize(data_path)) { |
| 110 #if defined(OS_WIN) | |
| 111 DLOG(ERROR) << "Couldn't mmap " << base::UTF16ToUTF8(data_path.value()); | |
|
Mark Mentovai
2013/12/17 22:12:02
You can do this on all platforms, getting rid of t
jungshik at Google
2013/12/18 20:59:11
Thanks. I went with AsUTF8Unsafe.
| |
| 112 #else | |
| 107 DLOG(ERROR) << "Couldn't mmap " << data_path.value(); | 113 DLOG(ERROR) << "Couldn't mmap " << data_path.value(); |
| 114 #endif | |
| 108 return false; | 115 return false; |
| 109 } | 116 } |
| 110 } | 117 } |
| 111 UErrorCode err = U_ZERO_ERROR; | 118 UErrorCode err = U_ZERO_ERROR; |
| 112 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); | 119 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); |
| 113 return err == U_ZERO_ERROR; | 120 return err == U_ZERO_ERROR; |
| 114 #endif | 121 #endif |
| 115 } | 122 } |
| 116 | 123 |
| 117 } // namespace i18n | 124 } // namespace i18n |
| 118 } // namespace base | 125 } // namespace base |
| OLD | NEW |