[Sync::USS] Fix for cache guid mismatch when loading bookmarks
Currently, if there is a mistmatch in the cache guid between the persisted
one and the one coming from sync, the bookmark model will stay in
the MODEL_STARTING state and effectively block sync machinery.
This patch makes sure that in such case, the BookmarkModelTypeProcessor
will consider the persisted data corrupted, and start clean.
Bug: 516866,820049, 816723
Change-Id: I06605b20f3357016d1b2d5a86009ce7abe0b392d
Reviewed-on: https://chromium-review.googlesource.com/c/1425501
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#624747}
diff --git a/components/sync_bookmarks/bookmark_model_type_processor.cc b/components/sync_bookmarks/bookmark_model_type_processor.cc
index 27d7af9..1e21c4f 100644
--- a/components/sync_bookmarks/bookmark_model_type_processor.cc
+++ b/components/sync_bookmarks/bookmark_model_type_processor.cc
@@ -331,11 +331,13 @@
if (bookmark_tracker_ &&
bookmark_tracker_->model_type_state().cache_guid() != cache_guid_) {
- // TODO(crbug.com/820049): Properly handle a mismatch between the loaded
- // cache guid stored in |bookmark_tracker_.model_type_state_| at
- // DecodeSyncMetadata() and the one received from sync at OnSyncStarting()
- // stored in |cache_guid_|.
- return;
+ // TODO(crbug.com/820049): Add basic unit testing consider using
+ // StopTrackingMetadata().
+ // In case of a cache guid mismatch, treat it as a corrupted metadata and
+ // start clean.
+ bookmark_model_->RemoveObserver(bookmark_model_observer_.get());
+ bookmark_model_observer_.reset();
+ bookmark_tracker_.reset();
}
auto activation_context =