| Index: chrome/browser/sync/glue/bookmark_model_associator.cc
|
| diff --git a/chrome/browser/sync/glue/bookmark_model_associator.cc b/chrome/browser/sync/glue/bookmark_model_associator.cc
|
| index 2d3358447b3bed868ebb4bc3b23f6770cf6abd8f..219f31465fe1d2032550d53c19fc6cfc556b14ce 100644
|
| --- a/chrome/browser/sync/glue/bookmark_model_associator.cc
|
| +++ b/chrome/browser/sync/glue/bookmark_model_associator.cc
|
| @@ -213,11 +213,11 @@ void BookmarkModelAssociator::UpdatePermanentNodeVisibility() {
|
| id_map_.find(bookmark_model_->mobile_node()->id()) != id_map_.end());
|
| }
|
|
|
| -bool BookmarkModelAssociator::DisassociateModels(SyncError* error) {
|
| +SyncError BookmarkModelAssociator::DisassociateModels() {
|
| id_map_.clear();
|
| id_map_inverse_.clear();
|
| dirty_associations_sync_ids_.clear();
|
| - return true;
|
| + return SyncError();
|
| }
|
|
|
| int64 BookmarkModelAssociator::GetSyncIdFromChromeId(const int64& node_id) {
|
| @@ -328,17 +328,20 @@ bool BookmarkModelAssociator::NodesMatch(
|
| return true;
|
| }
|
|
|
| -bool BookmarkModelAssociator::AssociateTaggedPermanentNode(
|
| +SyncError BookmarkModelAssociator::AssociateTaggedPermanentNode(
|
| const BookmarkNode* permanent_node, const std::string&tag) {
|
| // Do nothing if |permanent_node| is already initialized and associated.
|
| int64 sync_id = GetSyncIdFromChromeId(permanent_node->id());
|
| if (sync_id != sync_api::kInvalidId)
|
| - return true;
|
| + return SyncError();
|
| if (!GetSyncIdForTaggedNode(tag, &sync_id))
|
| - return false;
|
| + return unrecoverable_error_handler_->CreateAndUploadError(
|
| + FROM_HERE,
|
| + "Permanent node not found",
|
| + model_type());
|
|
|
| Associate(permanent_node, sync_id);
|
| - return true;
|
| + return SyncError();
|
| }
|
|
|
| bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag,
|
| @@ -351,22 +354,22 @@ bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag,
|
| return true;
|
| }
|
|
|
| -bool BookmarkModelAssociator::AssociateModels(SyncError* error) {
|
| +SyncError BookmarkModelAssociator::AssociateModels() {
|
| scoped_ptr<ScopedAssociationUpdater> association_updater(
|
| new ScopedAssociationUpdater(bookmark_model_));
|
| // Try to load model associations from persisted associations first. If that
|
| // succeeds, we don't need to run the complex model matching algorithm.
|
| if (LoadAssociations())
|
| - return true;
|
| + return SyncError();
|
|
|
| - DisassociateModels(error);
|
| + DisassociateModels();
|
|
|
| // We couldn't load model associations from persisted associations. So build
|
| // them.
|
| - return BuildAssociations(error);
|
| + return BuildAssociations();
|
| }
|
|
|
| -bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
|
| +SyncError BookmarkModelAssociator::BuildAssociations() {
|
| // Algorithm description:
|
| // Match up the roots and recursively do the following:
|
| // * For each sync node for the current sync parent node, find the best
|
| @@ -384,25 +387,29 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
|
| // This algorithm will not do well if the folder name has changes but the
|
| // children under them are all the same.
|
|
|
| + SyncError error;
|
| DCHECK(bookmark_model_->IsLoaded());
|
|
|
| // To prime our association, we associate the top-level nodes, Bookmark Bar
|
| // and Other Bookmarks.
|
| - if (!AssociateTaggedPermanentNode(bookmark_model_->other_node(),
|
| - kOtherBookmarksTag)) {
|
| - error->Reset(FROM_HERE, kServerError, model_type());
|
| - return false;
|
| + error = AssociateTaggedPermanentNode(bookmark_model_->other_node(),
|
| + kOtherBookmarksTag);
|
| + if (error.IsSet()) {
|
| + return error;
|
| }
|
| - if (!AssociateTaggedPermanentNode(bookmark_model_->bookmark_bar_node(),
|
| - kBookmarkBarTag)) {
|
| - error->Reset(FROM_HERE, kServerError, model_type());
|
| - return false;
|
| +
|
| + error = AssociateTaggedPermanentNode(bookmark_model_->bookmark_bar_node(),
|
| + kBookmarkBarTag);
|
| + if (error.IsSet()) {
|
| + return error;
|
| }
|
| - if (!AssociateTaggedPermanentNode(bookmark_model_->mobile_node(),
|
| - kMobileBookmarksTag) &&
|
| - expect_mobile_bookmarks_folder_) {
|
| - error->Reset(FROM_HERE, kServerError, model_type());
|
| - return false;
|
| +
|
| + if (expect_mobile_bookmarks_folder_) {
|
| + error = AssociateTaggedPermanentNode(bookmark_model_->mobile_node(),
|
| + kMobileBookmarksTag);
|
| + if (error.IsSet()) {
|
| + return error;
|
| + }
|
| }
|
|
|
| int64 bookmark_bar_sync_id = GetSyncIdFromChromeId(
|
| @@ -431,8 +438,10 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
|
|
|
| sync_api::ReadNode sync_parent(&trans);
|
| if (!sync_parent.InitByIdLookup(sync_parent_id)) {
|
| - error->Reset(FROM_HERE, "Failed to lookup node.", model_type());
|
| - return false;
|
| + return unrecoverable_error_handler_->CreateAndUploadError(
|
| + FROM_HERE,
|
| + "Failed to lookup node.",
|
| + model_type());
|
| }
|
| // Only folder nodes are pushed on to the stack.
|
| DCHECK(sync_parent.GetIsFolder());
|
| @@ -447,8 +456,10 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
|
| while (sync_child_id != sync_api::kInvalidId) {
|
| sync_api::WriteNode sync_child_node(&trans);
|
| if (!sync_child_node.InitByIdLookup(sync_child_id)) {
|
| - error->Reset(FROM_HERE, "Failed to lookup node.", model_type());
|
| - return false;
|
| + return unrecoverable_error_handler_->CreateAndUploadError(
|
| + FROM_HERE,
|
| + "Failed to lookup node.",
|
| + model_type());
|
| }
|
|
|
| const BookmarkNode* child_node = NULL;
|
| @@ -494,8 +505,10 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
|
| parent_node, bookmark_model_, i, &trans, this,
|
| unrecoverable_error_handler_);
|
| if (sync_api::kInvalidId == sync_child_id) {
|
| - error->Reset(FROM_HERE, "Failed to create sync node.", model_type());
|
| - return false; // Creation failed.
|
| + return unrecoverable_error_handler_->CreateAndUploadError(
|
| + FROM_HERE,
|
| + "Failed to create sync node.",
|
| + model_type());
|
| }
|
| if (parent_node->GetChild(i)->is_folder())
|
| dfs_stack.push(sync_child_id);
|
| @@ -503,7 +516,7 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
|
| }
|
| }
|
|
|
| - return true;
|
| + return SyncError();
|
| }
|
|
|
| void BookmarkModelAssociator::PostPersistAssociationsTask() {
|
|
|