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

Unified Diff: ui/base/resource/data_pack.cc

Issue 1115033003: resources: Prevent including the same resource in multiple pack files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot-merge Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/resource/data_pack.h ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/data_pack.cc
diff --git a/ui/base/resource/data_pack.cc b/ui/base/resource/data_pack.cc
index f9fe9b8469eeb35d3369a4c32cb09ace5ba48b0f..82d33633693250777da3efdf90f5a488b25d0323 100644
--- a/ui/base/resource/data_pack.cc
+++ b/ui/base/resource/data_pack.cc
@@ -231,6 +231,23 @@ ui::ScaleFactor DataPack::GetScaleFactor() const {
return scale_factor_;
}
+#if DCHECK_IS_ON()
+void DataPack::CheckForDuplicateResources(
+ const ScopedVector<ResourceHandle>& packs) {
+ for (size_t i = 0; i < resource_count_ + 1; ++i) {
+ const DataPackEntry* entry = reinterpret_cast<const DataPackEntry*>(
+ mmap_->data() + kHeaderLength + (i * sizeof(DataPackEntry)));
+ const uint16 resource_id = entry->resource_id;
+ const float resource_scale = GetScaleForScaleFactor(scale_factor_);
+ for (const ResourceHandle* handle : packs) {
+ DCHECK_IMPLIES(
+ GetScaleForScaleFactor(handle->GetScaleFactor()) == resource_scale,
+ !handle->HasResource(resource_id));
+ }
+ }
+}
+#endif // DCHECK_IS_ON()
+
// static
bool DataPack::WritePack(const base::FilePath& path,
const std::map<uint16, base::StringPiece>& resources,
« no previous file with comments | « ui/base/resource/data_pack.h ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698