Commit 99ddaf5e authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

ProcessorEntityTracker: Make sure that there are no duplicate storage keys

Adds a DCHECK to ProcessorEntityTracker::UpdateOrOverrideStorageKey

Bug: none
Change-Id: Ie1379add4a6ac5e5fa024f7a6ce55140234cc78e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2115472
Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
Auto-Submit: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMaksim Moskvitin <mmoskvitin@google.com>
Cr-Commit-Position: refs/heads/master@{#752786}
parent 1804f313
......@@ -217,6 +217,7 @@ void ProcessorEntityTracker::UpdateOrOverrideStorageKey(
const std::string& storage_key) {
ProcessorEntity* entity = GetEntityForTagHash(client_tag_hash);
DCHECK(entity);
// If the entity already had a storage key, clear it.
const std::string previous_storage_key = entity->storage_key();
DCHECK_NE(previous_storage_key, storage_key);
if (!previous_storage_key.empty()) {
......@@ -227,6 +228,8 @@ void ProcessorEntityTracker::UpdateOrOverrideStorageKey(
storage_key_to_tag_hash_.end());
// Populate the new storage key in the existing entity.
entity->SetStorageKey(storage_key);
DCHECK(storage_key_to_tag_hash_.find(storage_key) ==
storage_key_to_tag_hash_.end());
storage_key_to_tag_hash_[storage_key] = client_tag_hash;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment