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

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

Issue 1539583003: Convert Pass()→std::move() in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « ui/base/resource/data_pack_unittest.cc ('k') | ui/compositor/compositor.cc » ('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) 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 <utility>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/big_endian.h" 11 #include "base/big_endian.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/files/file.h" 13 #include "base/files/file.h"
13 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/memory/ref_counted_memory.h" 16 #include "base/memory/ref_counted_memory.h"
16 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
17 #include "base/path_service.h" 18 #include "base/path_service.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 g_shared_instance_->InitDefaultFontList(); 171 g_shared_instance_->InitDefaultFontList();
171 return result; 172 return result;
172 } 173 }
173 174
174 // static 175 // static
175 void ResourceBundle::InitSharedInstanceWithPakFileRegion( 176 void ResourceBundle::InitSharedInstanceWithPakFileRegion(
176 base::File pak_file, 177 base::File pak_file,
177 const base::MemoryMappedFile::Region& region) { 178 const base::MemoryMappedFile::Region& region) {
178 InitSharedInstance(NULL); 179 InitSharedInstance(NULL);
179 scoped_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P)); 180 scoped_ptr<DataPack> data_pack(new DataPack(SCALE_FACTOR_100P));
180 if (!data_pack->LoadFromFileRegion(pak_file.Pass(), region)) { 181 if (!data_pack->LoadFromFileRegion(std::move(pak_file), region)) {
181 NOTREACHED() << "failed to load pak file"; 182 NOTREACHED() << "failed to load pak file";
182 return; 183 return;
183 } 184 }
184 g_shared_instance_->locale_resources_data_.reset(data_pack.release()); 185 g_shared_instance_->locale_resources_data_.reset(data_pack.release());
185 g_shared_instance_->InitDefaultFontList(); 186 g_shared_instance_->InitDefaultFontList();
186 } 187 }
187 188
188 // static 189 // static
189 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) { 190 void ResourceBundle::InitSharedInstanceWithPakPath(const base::FilePath& path) {
190 InitSharedInstance(NULL); 191 InitSharedInstance(NULL);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 237 }
237 238
238 void ResourceBundle::AddOptionalMaterialDesignDataPackFromPath( 239 void ResourceBundle::AddOptionalMaterialDesignDataPackFromPath(
239 const base::FilePath& path, 240 const base::FilePath& path,
240 ScaleFactor scale_factor) { 241 ScaleFactor scale_factor) {
241 AddDataPackFromPathInternal(path, scale_factor, true, true); 242 AddDataPackFromPathInternal(path, scale_factor, true, true);
242 } 243 }
243 244
244 void ResourceBundle::AddDataPackFromFile(base::File file, 245 void ResourceBundle::AddDataPackFromFile(base::File file,
245 ScaleFactor scale_factor) { 246 ScaleFactor scale_factor) {
246 AddDataPackFromFileRegion( 247 AddDataPackFromFileRegion(std::move(file),
247 file.Pass(), base::MemoryMappedFile::Region::kWholeFile, scale_factor); 248 base::MemoryMappedFile::Region::kWholeFile,
249 scale_factor);
248 } 250 }
249 251
250 void ResourceBundle::AddDataPackFromFileRegion( 252 void ResourceBundle::AddDataPackFromFileRegion(
251 base::File file, 253 base::File file,
252 const base::MemoryMappedFile::Region& region, 254 const base::MemoryMappedFile::Region& region,
253 ScaleFactor scale_factor) { 255 ScaleFactor scale_factor) {
254 scoped_ptr<DataPack> data_pack( 256 scoped_ptr<DataPack> data_pack(
255 new DataPack(scale_factor)); 257 new DataPack(scale_factor));
256 if (data_pack->LoadFromFileRegion(file.Pass(), region)) { 258 if (data_pack->LoadFromFileRegion(std::move(file), region)) {
257 AddDataPack(data_pack.release()); 259 AddDataPack(data_pack.release());
258 } else { 260 } else {
259 LOG(ERROR) << "Failed to load data pack from file." 261 LOG(ERROR) << "Failed to load data pack from file."
260 << "\nSome features may not be available."; 262 << "\nSome features may not be available.";
261 } 263 }
262 } 264 }
263 265
264 #if !defined(OS_MACOSX) 266 #if !defined(OS_MACOSX)
265 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale, 267 base::FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale,
266 bool test_file_exists) { 268 bool test_file_exists) {
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 // static 915 // static
914 bool ResourceBundle::DecodePNG(const unsigned char* buf, 916 bool ResourceBundle::DecodePNG(const unsigned char* buf,
915 size_t size, 917 size_t size,
916 SkBitmap* bitmap, 918 SkBitmap* bitmap,
917 bool* fell_back_to_1x) { 919 bool* fell_back_to_1x) {
918 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); 920 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size);
919 return gfx::PNGCodec::Decode(buf, size, bitmap); 921 return gfx::PNGCodec::Decode(buf, size, bitmap);
920 } 922 }
921 923
922 } // namespace ui 924 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/data_pack_unittest.cc ('k') | ui/compositor/compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698