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

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

Issue 394313002: Add support for loading pak files from arbitrary file regions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move Region to MemoryMappedFile Created 6 years, 4 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
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 <limits> 7 #include <limits>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/big_endian.h" 10 #include "base/big_endian.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 AddDataPackFromPathInternal(path, scale_factor, false); 227 AddDataPackFromPathInternal(path, scale_factor, false);
228 } 228 }
229 229
230 void ResourceBundle::AddOptionalDataPackFromPath(const base::FilePath& path, 230 void ResourceBundle::AddOptionalDataPackFromPath(const base::FilePath& path,
231 ScaleFactor scale_factor) { 231 ScaleFactor scale_factor) {
232 AddDataPackFromPathInternal(path, scale_factor, true); 232 AddDataPackFromPathInternal(path, scale_factor, true);
233 } 233 }
234 234
235 void ResourceBundle::AddDataPackFromFile(base::File file, 235 void ResourceBundle::AddDataPackFromFile(base::File file,
236 ScaleFactor scale_factor) { 236 ScaleFactor scale_factor) {
237 AddDataPackFromFileRegion(
238 file.Pass(), base::MemoryMappedFile::Region::kWholeFile, scale_factor);
239 }
240
241 void ResourceBundle::AddDataPackFromFileRegion(
242 base::File file,
243 const base::MemoryMappedFile::Region& region,
244 ScaleFactor scale_factor) {
237 scoped_ptr<DataPack> data_pack( 245 scoped_ptr<DataPack> data_pack(
238 new DataPack(scale_factor)); 246 new DataPack(scale_factor));
239 if (data_pack->LoadFromFile(file.Pass())) { 247 if (data_pack->LoadFromFileRegion(file.Pass(), region)) {
240 AddDataPack(data_pack.release()); 248 AddDataPack(data_pack.release());
241 } else { 249 } else {
242 LOG(ERROR) << "Failed to load data pack from file." 250 LOG(ERROR) << "Failed to load data pack from file."
243 << "\nSome features may not be available."; 251 << "\nSome features may not be available.";
244 } 252 }
245 } 253 }
246 254
247 #if !defined(OS_MACOSX) 255 #if !defined(OS_MACOSX)
248 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale, 256 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale,
249 bool test_file_exists) { 257 bool test_file_exists) {
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 // static 841 // static
834 bool ResourceBundle::DecodePNG(const unsigned char* buf, 842 bool ResourceBundle::DecodePNG(const unsigned char* buf,
835 size_t size, 843 size_t size,
836 SkBitmap* bitmap, 844 SkBitmap* bitmap,
837 bool* fell_back_to_1x) { 845 bool* fell_back_to_1x) {
838 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); 846 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size);
839 return gfx::PNGCodec::Decode(buf, size, bitmap); 847 return gfx::PNGCodec::Decode(buf, size, bitmap);
840 } 848 }
841 849
842 } // namespace ui 850 } // namespace ui
OLDNEW
« base/files/memory_mapped_file.h ('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