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

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

Issue 109013004: Use icudat*.dat file on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add icudtl.dat only when icu_use_data_file_flag is set Created 7 years 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 | build/common.gypi » ('j') | build/common.gypi » ('J')
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 12 matching lines...) Expand all
23 23
24 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
25 #include "base/mac/foundation_util.h" 25 #include "base/mac/foundation_util.h"
26 #endif 26 #endif
27 27
28 #define ICU_UTIL_DATA_FILE 0 28 #define ICU_UTIL_DATA_FILE 0
29 #define ICU_UTIL_DATA_SHARED 1 29 #define ICU_UTIL_DATA_SHARED 1
30 #define ICU_UTIL_DATA_STATIC 2 30 #define ICU_UTIL_DATA_STATIC 2
31 31
32 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 32 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
33 #define ICU_UTIL_DATA_FILE_NAME "icudt" U_ICU_VERSION_SHORT "l.dat" 33 // Use an unversioned file name to simplify a icu version update down the road.
34 // No need to change the filename in multiple places (gyp files, windows
35 // build pkg configurations, etc).
36 #define ICU_UTIL_DATA_FILE_NAME "icudtl.dat"
Mark Mentovai 2013/12/18 19:04:04 For my own edification: what’s the l stand for?
jungshik at Google 2013/12/18 19:53:19 'l' is for Little Endian. I got this part out of
34 #elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED 37 #elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED
35 #define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat" 38 #define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
36 #if defined(OS_WIN) 39 #if defined(OS_WIN)
37 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll" 40 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
38 #endif 41 #endif
39 #endif 42 #endif
40 43
41 namespace base { 44 namespace base {
42 namespace i18n { 45 namespace i18n {
43 46
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) 82 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE)
80 // If the ICU data directory is set, ICU won't actually load the data until 83 // If the ICU data directory is set, ICU won't actually load the data until
81 // it is needed. This can fail if the process is sandboxed at that time. 84 // it is needed. This can fail if the process is sandboxed at that time.
82 // Instead, we map the file in and hand off the data so the sandbox won't 85 // Instead, we map the file in and hand off the data so the sandbox won't
83 // cause any problems. 86 // cause any problems.
84 87
85 // Chrome doesn't normally shut down ICU, so the mapped data shouldn't ever 88 // Chrome doesn't normally shut down ICU, so the mapped data shouldn't ever
86 // be released. 89 // be released.
87 CR_DEFINE_STATIC_LOCAL(base::MemoryMappedFile, mapped_file, ()); 90 CR_DEFINE_STATIC_LOCAL(base::MemoryMappedFile, mapped_file, ());
88 if (!mapped_file.IsValid()) { 91 if (!mapped_file.IsValid()) {
89 // Assume it is in the framework bundle's Resources directory.
90 #if !defined(OS_MACOSX) 92 #if !defined(OS_MACOSX)
91 // For now, expect the data file to be alongside the executable. 93 // For now, expect the data file to be alongside the executable.
92 // This is sufficient while we work on unit tests, but will eventually 94 // This is sufficient while we work on unit tests, but will eventually
93 // likely live in a data directory. 95 // likely live in a data directory.
94 FilePath data_path; 96 FilePath data_path;
95 bool path_ok = PathService::Get(base::DIR_EXE, &data_path); 97 bool path_ok = PathService::Get(base::DIR_EXE, &data_path);
96 DCHECK(path_ok); 98 DCHECK(path_ok);
97 data_path = data_path.AppendASCII(ICU_UTIL_DATA_FILE_NAME); 99 data_path = data_path.AppendASCII(ICU_UTIL_DATA_FILE_NAME);
98 #else 100 #else
101 // Assume it is in the framework bundle's Resources directory.
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)) {
107 DLOG(ERROR) << "Couldn't mmap " << data_path.value(); 110 DLOG(ERROR) << "Couldn't mmap " << data_path.value();
108 return false; 111 return false;
109 } 112 }
110 } 113 }
111 UErrorCode err = U_ZERO_ERROR; 114 UErrorCode err = U_ZERO_ERROR;
112 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err); 115 udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err);
113 return err == U_ZERO_ERROR; 116 return err == U_ZERO_ERROR;
114 #endif 117 #endif
115 } 118 }
116 119
117 } // namespace i18n 120 } // namespace i18n
118 } // namespace base 121 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | build/common.gypi » ('j') | build/common.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698