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

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: . Created 5 years, 8 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
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..b3891c2968de9fad66a27f135a9a89f0b83e39ac 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(GetScaleForScaleFactor(handle->GetScaleFactor()) !=
+ resource_scale ||
+ !handle->HasResource(resource_id));
Nico 2015/05/06 01:06:35 (nit: if you want I think you can use dcheck_impli
sadrul 2015/05/06 17:29:24 Done.
+ }
+ }
+}
+#endif // DCHECK_IS_ON()
+
// static
bool DataPack::WritePack(const base::FilePath& path,
const std::map<uint16, base::StringPiece>& resources,

Powered by Google App Engine
This is Rietveld 408576698