Refactor initial merge of sync bookmarks

No behavioral changes: various minor refactorings are introduced to
improve code readability and simplify future patches.

Bug: 978430
Change-Id: Iafca6dd38e3c918b35417cd1c65b17cc37ec03d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1917361
Reviewed-by: Mohamed Amir Yosef <[email protected]>
Commit-Queue: Mikel Astiz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#715403}
diff --git a/components/sync_bookmarks/bookmark_model_merger.h b/components/sync_bookmarks/bookmark_model_merger.h
index 16e684d..41c19810 100644
--- a/components/sync_bookmarks/bookmark_model_merger.h
+++ b/components/sync_bookmarks/bookmark_model_merger.h
@@ -32,9 +32,9 @@
 // used by the BookmarkModelTypeProcessor().
 class BookmarkModelMerger {
  public:
-  // |updates|, |bookmark_model|, |favicon_service| and |bookmark_tracker| must
-  // not be null and must outlive this object.
-  BookmarkModelMerger(const syncer::UpdateResponseDataList* updates,
+  // |bookmark_model|, |favicon_service| and |bookmark_tracker| must not be
+  // null and must outlive this object.
+  BookmarkModelMerger(syncer::UpdateResponseDataList updates,
                       bookmarks::BookmarkModel* bookmark_model,
                       favicon::FaviconService* favicon_service,
                       SyncedBookmarkTracker* bookmark_tracker);
@@ -116,7 +116,11 @@
       const bookmarks::BookmarkNode* local_parent,
       size_t starting_child_index) const;
 
-  const syncer::UpdateResponseDataList* const updates_;
+  // Original updates as passed in the constructor, which may contain invalid
+  // updates. Needed to hold ownership of updates (other data structures such as
+  // |updates_tree_| point to these instances.
+  const syncer::UpdateResponseDataList original_updates_;
+
   bookmarks::BookmarkModel* const bookmark_model_;
   favicon::FaviconService* const favicon_service_;
   SyncedBookmarkTracker* const bookmark_tracker_;