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

Side by Side Diff: ui/base/resource/resource_bundle.cc

Issue 109273002: Convert base::MemoryMappedFile to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Posix GetSize Created 6 years, 12 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
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 "ui/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 std::string ResourceBundle::InitSharedInstanceLocaleOnly( 155 std::string ResourceBundle::InitSharedInstanceLocaleOnly(
156 const std::string& pref_locale, Delegate* delegate) { 156 const std::string& pref_locale, Delegate* delegate) {
157 InitSharedInstance(delegate); 157 InitSharedInstance(delegate);
158 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale); 158 std::string result = g_shared_instance_->LoadLocaleResources(pref_locale);
159 InitDefaultFontList(); 159 InitDefaultFontList();
160 return result; 160 return result;
161 } 161 }
162 162
163 // static 163 // static
164 void ResourceBundle::InitSharedInstanceWithPakFile( 164 void ResourceBundle::InitSharedInstanceWithPakFile(
165 base::PlatformFile pak_file, bool should_load_common_resources) { 165 base::File pak_file, bool should_load_common_resources) {
166 InitSharedInstance(NULL); 166 InitSharedInstance(NULL);
167 if (should_load_common_resources) 167 if (should_load_common_resources)
168 g_shared_instance_->LoadCommonResources(); 168 g_shared_instance_->LoadCommonResources();
169 169
170 scoped_ptr<DataPack> data_pack( 170 scoped_ptr<DataPack> data_pack(
171 new DataPack(SCALE_FACTOR_100P)); 171 new DataPack(SCALE_FACTOR_100P));
172 if (!data_pack->LoadFromFile(pak_file)) { 172 if (!data_pack->LoadFromFile(pak_file.Pass())) {
173 NOTREACHED() << "failed to load pak file"; 173 NOTREACHED() << "failed to load pak file";
174 return; 174 return;
175 } 175 }
176 g_shared_instance_->locale_resources_data_.reset(data_pack.release()); 176 g_shared_instance_->locale_resources_data_.reset(data_pack.release());
177 InitDefaultFontList(); 177 InitDefaultFontList();
178 } 178 }
179 179
180 // static 180 // static
181 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) { 181 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) {
182 InitSharedInstance(NULL); 182 InitSharedInstance(NULL);
(...skipping 29 matching lines...) Expand all
212 void ResourceBundle::AddDataPackFromPath(const base::FilePath& path, 212 void ResourceBundle::AddDataPackFromPath(const base::FilePath& path,
213 ScaleFactor scale_factor) { 213 ScaleFactor scale_factor) {
214 AddDataPackFromPathInternal(path, scale_factor, false); 214 AddDataPackFromPathInternal(path, scale_factor, false);
215 } 215 }
216 216
217 void ResourceBundle::AddOptionalDataPackFromPath(const base::FilePath& path, 217 void ResourceBundle::AddOptionalDataPackFromPath(const base::FilePath& path,
218 ScaleFactor scale_factor) { 218 ScaleFactor scale_factor) {
219 AddDataPackFromPathInternal(path, scale_factor, true); 219 AddDataPackFromPathInternal(path, scale_factor, true);
220 } 220 }
221 221
222 void ResourceBundle::AddDataPackFromFile(base::PlatformFile file, 222 void ResourceBundle::AddDataPackFromFile(base::File file,
223 ScaleFactor scale_factor) { 223 ScaleFactor scale_factor) {
224 scoped_ptr<DataPack> data_pack( 224 scoped_ptr<DataPack> data_pack(
225 new DataPack(scale_factor)); 225 new DataPack(scale_factor));
226 if (data_pack->LoadFromFile(file)) { 226 if (data_pack->LoadFromFile(file.Pass())) {
227 AddDataPack(data_pack.release()); 227 AddDataPack(data_pack.release());
228 } else { 228 } else {
229 LOG(ERROR) << "Failed to load data pack from file." 229 LOG(ERROR) << "Failed to load data pack from file."
230 << "\nSome features may not be available."; 230 << "\nSome features may not be available.";
231 } 231 }
232 } 232 }
233 233
234 #if !defined(OS_MACOSX) 234 #if !defined(OS_MACOSX)
235 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale, 235 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale,
236 bool test_file_exists) { 236 bool test_file_exists) {
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 // static 796 // static
797 bool ResourceBundle::DecodePNG(const unsigned char* buf, 797 bool ResourceBundle::DecodePNG(const unsigned char* buf,
798 size_t size, 798 size_t size,
799 SkBitmap* bitmap, 799 SkBitmap* bitmap,
800 bool* fell_back_to_1x) { 800 bool* fell_back_to_1x) {
801 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); 801 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size);
802 return gfx::PNGCodec::Decode(buf, size, bitmap); 802 return gfx::PNGCodec::Decode(buf, size, bitmap);
803 } 803 }
804 804
805 } // namespace ui 805 } // namespace ui
OLDNEW
« ui/base/resource/data_pack.cc ('K') | « ui/base/resource/resource_bundle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698