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

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

Issue 2209363002: Remove material design resource pak infrastructure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove another mac test file Created 4 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
« no previous file with comments | « ui/base/resource/data_pack.h ('k') | ui/base/resource/resource_bundle.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) 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/data_pack.h" 5 #include "ui/base/resource/data_pack.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 LOAD_ERRORS_COUNT, 60 LOAD_ERRORS_COUNT,
61 }; 61 };
62 62
63 } // namespace 63 } // namespace
64 64
65 namespace ui { 65 namespace ui {
66 66
67 DataPack::DataPack(ui::ScaleFactor scale_factor) 67 DataPack::DataPack(ui::ScaleFactor scale_factor)
68 : resource_count_(0), 68 : resource_count_(0),
69 text_encoding_type_(BINARY), 69 text_encoding_type_(BINARY),
70 scale_factor_(scale_factor), 70 scale_factor_(scale_factor) {
71 has_only_material_design_assets_(false) {
72 } 71 }
73 72
74 DataPack::~DataPack() { 73 DataPack::~DataPack() {
75 } 74 }
76 75
77 bool DataPack::LoadFromPath(const base::FilePath& path) { 76 bool DataPack::LoadFromPath(const base::FilePath& path) {
78 mmap_.reset(new base::MemoryMappedFile); 77 mmap_.reset(new base::MemoryMappedFile);
79 if (!mmap_->Initialize(path)) { 78 if (!mmap_->Initialize(path)) {
80 DLOG(ERROR) << "Failed to mmap datapack"; 79 DLOG(ERROR) << "Failed to mmap datapack";
81 UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED, 80 UMA_HISTOGRAM_ENUMERATION("DataPack.Load", INIT_FAILED,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 225 }
227 226
228 ResourceHandle::TextEncodingType DataPack::GetTextEncodingType() const { 227 ResourceHandle::TextEncodingType DataPack::GetTextEncodingType() const {
229 return text_encoding_type_; 228 return text_encoding_type_;
230 } 229 }
231 230
232 ui::ScaleFactor DataPack::GetScaleFactor() const { 231 ui::ScaleFactor DataPack::GetScaleFactor() const {
233 return scale_factor_; 232 return scale_factor_;
234 } 233 }
235 234
236 bool DataPack::HasOnlyMaterialDesignAssets() const {
237 return has_only_material_design_assets_;
238 }
239
240 #if DCHECK_IS_ON() 235 #if DCHECK_IS_ON()
241 void DataPack::CheckForDuplicateResources( 236 void DataPack::CheckForDuplicateResources(
242 const ScopedVector<ResourceHandle>& packs) { 237 const ScopedVector<ResourceHandle>& packs) {
243 for (size_t i = 0; i < resource_count_ + 1; ++i) { 238 for (size_t i = 0; i < resource_count_ + 1; ++i) {
244 const DataPackEntry* entry = reinterpret_cast<const DataPackEntry*>( 239 const DataPackEntry* entry = reinterpret_cast<const DataPackEntry*>(
245 mmap_->data() + kHeaderLength + (i * sizeof(DataPackEntry))); 240 mmap_->data() + kHeaderLength + (i * sizeof(DataPackEntry)));
246 const uint16_t resource_id = entry->resource_id; 241 const uint16_t resource_id = entry->resource_id;
247 const float resource_scale = GetScaleForScaleFactor(scale_factor_); 242 const float resource_scale = GetScaleForScaleFactor(scale_factor_);
248 for (const ResourceHandle* handle : packs) { 243 for (const ResourceHandle* handle : packs) {
249 if (HasOnlyMaterialDesignAssets() !=
250 handle->HasOnlyMaterialDesignAssets()) {
251 continue;
252 }
253 if (GetScaleForScaleFactor(handle->GetScaleFactor()) != resource_scale) 244 if (GetScaleForScaleFactor(handle->GetScaleFactor()) != resource_scale)
254 continue; 245 continue;
255 DCHECK(!handle->HasResource(resource_id)) << "Duplicate resource " 246 DCHECK(!handle->HasResource(resource_id)) << "Duplicate resource "
256 << resource_id << " with scale " 247 << resource_id << " with scale "
257 << resource_scale; 248 << resource_scale;
258 } 249 }
259 } 250 }
260 } 251 }
261 #endif // DCHECK_IS_ON() 252 #endif // DCHECK_IS_ON()
262 253
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 return false; 336 return false;
346 } 337 }
347 } 338 }
348 339
349 base::CloseFile(file); 340 base::CloseFile(file);
350 341
351 return true; 342 return true;
352 } 343 }
353 344
354 } // namespace ui 345 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/data_pack.h ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698