bookmarks: Fix theoretical race when changing titles

A BookmarkNode's title can only be changed from the UI thread, but is
also read by the history backend thread via
HistoryBookmarkModel::GetBookmarks(). Hence, a lock must be acquired
before changing the title.

In practice, this race should be extremely unlikely (if not impossible)
since assignment of base::string16 may as well be atomic in practice.

Change-Id: I8b31b977efe8fdcb918be8692984b2eab9dd0411
Bug: None
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031041
Reviewed-by: Scott Violet <[email protected]>
Commit-Queue: Mikel Astiz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#737357}
diff --git a/components/bookmarks/browser/bookmark_model.cc b/components/bookmarks/browser/bookmark_model.cc
index 267563c..ad0c6f9 100644
--- a/components/bookmarks/browser/bookmark_model.cc
+++ b/components/bookmarks/browser/bookmark_model.cc
@@ -388,7 +388,7 @@
   // title changed but should be excluded from the index.
   if (node->is_url())
     titled_url_index_->Remove(node);
-  AsMutable(node)->SetTitle(title);
+  url_index_->SetTitle(AsMutable(node), title);
   if (node->is_url())
     titled_url_index_->Add(node);