Commit faecb998 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Sync::USS] CHECKs to detect duplicate tombstones in bookmarks tracker

This CL add some CHECKs for debugging purpose to detect cases when
duplicate tombstones are tracked in the bookmarks tracker.

Bug: 963469
Change-Id: I2f0c23c5ece50264e9a7f07f2cf8abd956ff72d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1613182Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660053}
parent 0128a85f
...@@ -116,6 +116,10 @@ SyncedBookmarkTracker::SyncedBookmarkTracker( ...@@ -116,6 +116,10 @@ SyncedBookmarkTracker::SyncedBookmarkTracker(
// Otherwise, it must be a deletion so we must remember to deletion // Otherwise, it must be a deletion so we must remember to deletion
// ordering. // ordering.
DCHECK(entity->metadata()->is_deleted()); DCHECK(entity->metadata()->is_deleted());
// TODO(crbug.com/516866): The below CHECK is added to debug some crashes.
// Should be removed after figuring out the reason for the crash.
CHECK_EQ(0, std::count(ordered_local_tombstones_.begin(),
ordered_local_tombstones_.end(), entity.get()));
ordered_local_tombstones_.push_back(entity.get()); ordered_local_tombstones_.push_back(entity.get());
} }
// TODO(crbug.com/516866): The below CHECK is added to debug some crashes. // TODO(crbug.com/516866): The below CHECK is added to debug some crashes.
...@@ -284,6 +288,10 @@ void SyncedBookmarkTracker::MarkDeleted(const std::string& sync_id) { ...@@ -284,6 +288,10 @@ void SyncedBookmarkTracker::MarkDeleted(const std::string& sync_id) {
// Clear all references to the deleted bookmark node. // Clear all references to the deleted bookmark node.
bookmark_node_to_entities_map_.erase(entity->bookmark_node()); bookmark_node_to_entities_map_.erase(entity->bookmark_node());
entity->clear_bookmark_node(); entity->clear_bookmark_node();
// TODO(crbug.com/516866): The below CHECK is added to debug some crashes.
// Should be removed after figuring out the reason for the crash.
CHECK_EQ(0, std::count(ordered_local_tombstones_.begin(),
ordered_local_tombstones_.end(), entity));
ordered_local_tombstones_.push_back(entity); ordered_local_tombstones_.push_back(entity);
} }
...@@ -376,6 +384,10 @@ SyncedBookmarkTracker::GetEntitiesWithLocalChanges(size_t max_entries) const { ...@@ -376,6 +384,10 @@ SyncedBookmarkTracker::GetEntitiesWithLocalChanges(size_t max_entries) const {
std::vector<const SyncedBookmarkTracker::Entity*> ordered_local_changes = std::vector<const SyncedBookmarkTracker::Entity*> ordered_local_changes =
ReorderUnsyncedEntitiesExceptDeletions(entities_with_local_changes); ReorderUnsyncedEntitiesExceptDeletions(entities_with_local_changes);
for (const Entity* tombstone_entity : ordered_local_tombstones_) { for (const Entity* tombstone_entity : ordered_local_tombstones_) {
// TODO(crbug.com/516866): The below CHECK is added to debug some crashes.
// Should be removed after figuring out the reason for the crash.
CHECK_EQ(0, std::count(ordered_local_changes.begin(),
ordered_local_changes.end(), tombstone_entity));
ordered_local_changes.push_back(tombstone_entity); ordered_local_changes.push_back(tombstone_entity);
} }
if (ordered_local_changes.size() > max_entries) { if (ordered_local_changes.size() > max_entries) {
......
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