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

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

Issue 9187053: Transition to base/mac/bundle_locations.h step 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review comments. Created 8 years, 11 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 | base/mac/foundation_util.h » ('j') | 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) 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 #else 102 #else
103 // If the ICU data directory is set, ICU won't actually load the data until 103 // If the ICU data directory is set, ICU won't actually load the data until
104 // it is needed. This can fail if the process is sandboxed at that time. 104 // it is needed. This can fail if the process is sandboxed at that time.
105 // Instead, Mac maps the file in and hands off the data so the sandbox won't 105 // Instead, Mac maps the file in and hands off the data so the sandbox won't
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 framework bundle's Resources directory.
113 FilePath data_path = 113 FilePath data_path =
114 base::mac::PathForMainAppBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME)); 114 base::mac::PathForFrameworkBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME));
115 if (data_path.empty()) { 115 if (data_path.empty()) {
116 DLOG(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 DLOG(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
OLDNEW
« no previous file with comments | « no previous file | base/mac/foundation_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698