Commit 01334e45 authored by zea@chromium.org's avatar zea@chromium.org

[Sync] Dont upload an unrecoverable error for missing synced bookmark node

We were uploading when failing to associate the synced bookmarks node,
regardless of whether we expected it or not. Now we do the upload
at a layer above, where we know whether we care or not.

BUG=142387
TEST=Signing into sync on an account with no mobile devices should not
trigger an unrecoverable error upload.


Review URL: https://chromiumcodereview.appspot.com/10825325

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151356 0039d316-1c4b-4281-b951-d872f2087c98
parent 1554a331
...@@ -331,20 +331,17 @@ bool BookmarkModelAssociator::NodesMatch( ...@@ -331,20 +331,17 @@ bool BookmarkModelAssociator::NodesMatch(
return true; return true;
} }
syncer::SyncError BookmarkModelAssociator::AssociateTaggedPermanentNode( bool BookmarkModelAssociator::AssociateTaggedPermanentNode(
const BookmarkNode* permanent_node, const std::string&tag) { const BookmarkNode* permanent_node, const std::string&tag) {
// Do nothing if |permanent_node| is already initialized and associated. // Do nothing if |permanent_node| is already initialized and associated.
int64 sync_id = GetSyncIdFromChromeId(permanent_node->id()); int64 sync_id = GetSyncIdFromChromeId(permanent_node->id());
if (sync_id != syncer::kInvalidId) if (sync_id != syncer::kInvalidId)
return syncer::SyncError(); return true;
if (!GetSyncIdForTaggedNode(tag, &sync_id)) if (!GetSyncIdForTaggedNode(tag, &sync_id))
return unrecoverable_error_handler_->CreateAndUploadError( return false;
FROM_HERE,
"Permanent node not found",
model_type());
Associate(permanent_node, sync_id); Associate(permanent_node, sync_id);
return syncer::SyncError(); return true;
} }
bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag, bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag,
...@@ -390,26 +387,34 @@ syncer::SyncError BookmarkModelAssociator::BuildAssociations() { ...@@ -390,26 +387,34 @@ syncer::SyncError BookmarkModelAssociator::BuildAssociations() {
// This algorithm will not do well if the folder name has changes but the // This algorithm will not do well if the folder name has changes but the
// children under them are all the same. // children under them are all the same.
syncer::SyncError error;
DCHECK(bookmark_model_->IsLoaded()); DCHECK(bookmark_model_->IsLoaded());
// To prime our association, we associate the top-level nodes, Bookmark Bar // To prime our association, we associate the top-level nodes, Bookmark Bar
// and Other Bookmarks. // and Other Bookmarks.
error = AssociateTaggedPermanentNode(bookmark_model_->other_node(), if (!AssociateTaggedPermanentNode(bookmark_model_->other_node(),
kOtherBookmarksTag); kOtherBookmarksTag)) {
if (error.IsSet()) return unrecoverable_error_handler_->CreateAndUploadError(
return error; FROM_HERE,
"Other bookmarks node not found",
error = AssociateTaggedPermanentNode(bookmark_model_->bookmark_bar_node(), model_type());
kBookmarkBarTag); }
if (error.IsSet())
return error; if (!AssociateTaggedPermanentNode(bookmark_model_->bookmark_bar_node(),
kBookmarkBarTag)) {
error = AssociateTaggedPermanentNode(bookmark_model_->mobile_node(), return unrecoverable_error_handler_->CreateAndUploadError(
kMobileBookmarksTag); FROM_HERE,
if (error.IsSet() && expect_mobile_bookmarks_folder_) "Bookmark bar node not found",
return error; model_type());
error = syncer::SyncError(); }
if (!AssociateTaggedPermanentNode(bookmark_model_->mobile_node(),
kMobileBookmarksTag) &&
expect_mobile_bookmarks_folder_) {
return unrecoverable_error_handler_->CreateAndUploadError(
FROM_HERE,
"Mobile bookmarks node not found",
model_type());
}
int64 bookmark_bar_sync_id = GetSyncIdFromChromeId( int64 bookmark_bar_sync_id = GetSyncIdFromChromeId(
bookmark_model_->bookmark_bar_node()->id()); bookmark_model_->bookmark_bar_node()->id());
......
...@@ -124,7 +124,8 @@ class BookmarkModelAssociator ...@@ -124,7 +124,8 @@ class BookmarkModelAssociator
// well known to the server and the client, and is unique within a particular // well known to the server and the client, and is unique within a particular
// user's share. For example, "other_bookmarks" is the tag for the Other // user's share. For example, "other_bookmarks" is the tag for the Other
// Bookmarks folder. The sync nodes are server-created. // Bookmarks folder. The sync nodes are server-created.
syncer::SyncError AssociateTaggedPermanentNode( // Returns true on success, false if association failed.
bool AssociateTaggedPermanentNode(
const BookmarkNode* permanent_node, const BookmarkNode* permanent_node,
const std::string& tag) WARN_UNUSED_RESULT; const std::string& tag) WARN_UNUSED_RESULT;
......
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