| 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 ec57895e5d315253c9a848692b6fd167a7486666..6e0ba5cd7a0f6d42983326a2c316d7daa7fe5dd8 100644
|
| --- a/chrome/browser/sync/glue/bookmark_model_associator.cc
|
| +++ b/chrome/browser/sync/glue/bookmark_model_associator.cc
|
| @@ -14,6 +14,7 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/bookmarks/bookmark_model.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/sync/api/sync_error.h"
|
| #include "chrome/browser/sync/engine/syncapi.h"
|
| #include "chrome/browser/sync/glue/bookmark_change_processor.h"
|
| #include "chrome/browser/sync/syncable/nigori_util.h"
|
| @@ -44,6 +45,9 @@ namespace browser_sync {
|
| static const char kBookmarkBarTag[] = "bookmark_bar";
|
| static const char kSyncedBookmarksTag[] = "synced_bookmarks";
|
| static const char kOtherBookmarksTag[] = "other_bookmarks";
|
| +static const char kServerError[] =
|
| + "Server did not create top-level nodes. Possibly we are running against "
|
| + "an out-of-date server?";
|
|
|
| // Bookmark comparer for map of bookmark nodes.
|
| class BookmarkComparer {
|
| @@ -178,7 +182,7 @@ BookmarkModelAssociator::~BookmarkModelAssociator() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| }
|
|
|
| -bool BookmarkModelAssociator::DisassociateModels() {
|
| +bool BookmarkModelAssociator::DisassociateModels(SyncError* error) {
|
| id_map_.clear();
|
| id_map_inverse_.clear();
|
| dirty_associations_sync_ids_.clear();
|
| @@ -315,20 +319,20 @@ bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag,
|
| return true;
|
| }
|
|
|
| -bool BookmarkModelAssociator::AssociateModels() {
|
| +bool BookmarkModelAssociator::AssociateModels(SyncError* error) {
|
| // 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;
|
|
|
| - DisassociateModels();
|
| + DisassociateModels(error);
|
|
|
| // We couldn't load model associations from persisted associations. So build
|
| // them.
|
| - return BuildAssociations();
|
| + return BuildAssociations(error);
|
| }
|
|
|
| -bool BookmarkModelAssociator::BuildAssociations() {
|
| +bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
|
| // Algorithm description:
|
| // Match up the roots and recursively do the following:
|
| // * For each sync node for the current sync parent node, find the best
|
| @@ -352,14 +356,12 @@ bool BookmarkModelAssociator::BuildAssociations() {
|
| // and Other Bookmarks.
|
| if (!AssociateTaggedPermanentNode(bookmark_model_->other_node(),
|
| kOtherBookmarksTag)) {
|
| - LOG(ERROR) << "Server did not create top-level nodes. Possibly we "
|
| - << "are running against an out-of-date server?";
|
| + error->Reset(FROM_HERE, kServerError, model_type());
|
| return false;
|
| }
|
| if (!AssociateTaggedPermanentNode(bookmark_model_->bookmark_bar_node(),
|
| kBookmarkBarTag)) {
|
| - LOG(ERROR) << "Server did not create top-level nodes. Possibly we "
|
| - << "are running against an out-of-date server?";
|
| + error->Reset(FROM_HERE, kServerError, model_type());
|
| return false;
|
| }
|
| if (!AssociateTaggedPermanentNode(bookmark_model_->synced_node(),
|
| @@ -368,8 +370,7 @@ bool BookmarkModelAssociator::BuildAssociations() {
|
| // server if the command line flag is set.
|
| CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kEnableSyncedBookmarksFolder)) {
|
| - LOG(ERROR) << "Server did not create top-level synced nodes. Possibly "
|
| - << "we are running against an out-of-date server?";
|
| + error->Reset(FROM_HERE, kServerError, model_type());
|
| return false;
|
| }
|
| int64 bookmark_bar_sync_id = GetSyncIdFromChromeId(
|
| @@ -399,6 +400,7 @@ bool BookmarkModelAssociator::BuildAssociations() {
|
|
|
| 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;
|
| }
|
| // Only folder nodes are pushed on to the stack.
|
| @@ -414,6 +416,7 @@ bool BookmarkModelAssociator::BuildAssociations() {
|
| 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;
|
| }
|
|
|
|
|