Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Unified Diff: chrome/browser/sync/glue/bookmark_change_processor.cc

Issue 9570055: [Sync] Add support for associating a new Synced Bookmarks node. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, address comments Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/sync/glue/bookmark_model_associator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/bookmark_change_processor.cc
diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc
index 5e5fede738a842aacd52ff4518985d9b7318336e..f7434476ff987d758b375c51aa629c89f6fb36d4 100644
--- a/chrome/browser/sync/glue/bookmark_change_processor.cc
+++ b/chrome/browser/sync/glue/bookmark_change_processor.cc
@@ -28,6 +28,8 @@ using content::BrowserThread;
namespace browser_sync {
+static const char kMobileBookmarksTag[] = "synced_bookmarks";
+
BookmarkChangeProcessor::BookmarkChangeProcessor(
BookmarkModelAssociator* model_associator,
DataTypeErrorHandler* error_handler)
@@ -449,11 +451,25 @@ void BookmarkChangeProcessor::ApplyChangesFromSyncModel(
}
if (!CreateOrUpdateBookmarkNode(&src, model)) {
- error_handler()->OnUnrecoverableError(FROM_HERE,
- "Failed to create bookmark node with title " +
- src.GetTitle() + " and url " +
- src.GetURL().possibly_invalid_spec());
- return;
+ // Because the Synced Bookmarks node can be created server side, it's
+ // possible it'll arrive at the client as an update. In that case it
+ // won't have been associated at startup, the GetChromeNodeFromSyncId
+ // call above will return NULL, and we won't detect it as a permanent
+ // node, resulting in us trying to create it here (which will
+ // fail). Therefore, we add special logic here just to detect the
+ // Synced Bookmarks folder.
+ sync_api::ReadNode synced_bookmarks(trans);
+ if (synced_bookmarks.InitByTagLookup(kMobileBookmarksTag) &&
+ synced_bookmarks.GetId() == it->id) {
+ // This is a newly created Synced Bookmarks node. Associate it.
+ model_associator_->Associate(model->mobile_node(), it->id);
+ } else {
+ // We ignore bookmarks we can't add. Chances are this is caused by
+ // a bookmark that was not fully associated.
+ LOG(ERROR) << "Failed to create bookmark node with title "
+ << src.GetTitle() + " and url "
+ << src.GetURL().possibly_invalid_spec();
+ }
}
}
}
« no previous file with comments | « no previous file | chrome/browser/sync/glue/bookmark_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698