diff options
Diffstat (limited to 'chrome/browser/sync/glue')
7 files changed, 59 insertions, 21 deletions
diff --git a/chrome/browser/sync/glue/generic_change_processor.cc b/chrome/browser/sync/glue/generic_change_processor.cc index 0c9ac04..3cde180 100644 --- a/chrome/browser/sync/glue/generic_change_processor.cc +++ b/chrome/browser/sync/glue/generic_change_processor.cc @@ -253,16 +253,43 @@ SyncError GenericChangeProcessor::ProcessSyncChanges( error.message()); return error; } - if (!sync_node.InitUniqueByCreation(change.sync_data().GetDataType(), + sync_api::WriteNode::InitUniqueByCreationResult result = + sync_node.InitUniqueByCreation(change.sync_data().GetDataType(), root_node, - change.sync_data().GetTag())) { + change.sync_data().GetTag()); + if (result != sync_api::WriteNode::INIT_SUCCESS) { NOTREACHED(); - SyncError error(FROM_HERE, - "Failed to create " + type_str + " node.", + std::string error_prefix = "Failed to create " + type_str + " node: "; + SyncError error; + switch (result) { + case sync_api::WriteNode::INIT_FAILED_EMPTY_TAG: + error.Reset(FROM_HERE, error_prefix + "empty tag", type); + error_handler()->OnSingleDatatypeUnrecoverableError( + error.location(), error.message()); + return error; + case sync_api::WriteNode::INIT_FAILED_ENTRY_ALREADY_EXISTS: + error.Reset(FROM_HERE, error_prefix + "entry already exists", type); + error_handler()->OnSingleDatatypeUnrecoverableError( + error.location(), error.message()); + return error; + case sync_api::WriteNode::INIT_FAILED_COULD_NOT_CREATE_ENTRY: + error.Reset(FROM_HERE, error_prefix + "failed to create entry", type); - error_handler()->OnSingleDatatypeUnrecoverableError(error.location(), - error.message()); - return error; + error_handler()->OnSingleDatatypeUnrecoverableError( + error.location(), error.message()); + return error; + case sync_api::WriteNode::INIT_FAILED_SET_PREDECESSOR: + error.Reset(FROM_HERE, error_prefix + "failed to set predecessor", + type); + error_handler()->OnSingleDatatypeUnrecoverableError( + error.location(), error.message()); + return error; + default: + error.Reset(FROM_HERE, error_prefix + "unknown error", type); + error_handler()->OnSingleDatatypeUnrecoverableError( + error.location(), error.message()); + return error; + } } sync_node.SetTitle(UTF8ToWide(change.sync_data().GetTitle())); sync_node.SetEntitySpecifics(change.sync_data().GetSpecifics()); diff --git a/chrome/browser/sync/glue/password_change_processor.cc b/chrome/browser/sync/glue/password_change_processor.cc index ad3572c..870d3a3 100644 --- a/chrome/browser/sync/glue/password_change_processor.cc +++ b/chrome/browser/sync/glue/password_change_processor.cc @@ -82,8 +82,10 @@ void PasswordChangeProcessor::Observe( switch (change->type()) { case PasswordStoreChange::ADD: { sync_api::WriteNode sync_node(&trans); - if (sync_node.InitUniqueByCreation(syncable::PASSWORDS, - password_root, tag)) { + sync_api::WriteNode::InitUniqueByCreationResult result = + sync_node.InitUniqueByCreation(syncable::PASSWORDS, password_root, + tag); + if (result == sync_api::WriteNode::INIT_SUCCESS) { PasswordModelAssociator::WriteToSyncNode(change->form(), &sync_node); model_associator_->Associate(&tag, sync_node.GetId()); break; diff --git a/chrome/browser/sync/glue/password_model_associator.cc b/chrome/browser/sync/glue/password_model_associator.cc index 6565c27..8836f67 100644 --- a/chrome/browser/sync/glue/password_model_associator.cc +++ b/chrome/browser/sync/glue/password_model_associator.cc @@ -117,8 +117,9 @@ SyncError PasswordModelAssociator::AssociateModels() { Associate(&tag, node.GetId()); } else { sync_api::WriteNode node(&trans); - if (!node.InitUniqueByCreation(syncable::PASSWORDS, - password_root, tag)) { + sync_api::WriteNode::InitUniqueByCreationResult result = + node.InitUniqueByCreation(syncable::PASSWORDS, password_root, tag); + if (result != sync_api::WriteNode::INIT_SUCCESS) { STLDeleteElements(&passwords); return error_handler_->CreateAndUploadError( FROM_HERE, diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc index d89576b..d7f58b0 100644 --- a/chrome/browser/sync/glue/session_model_associator.cc +++ b/chrome/browser/sync/glue/session_model_associator.cc @@ -765,9 +765,9 @@ SyncError SessionModelAssociator::AssociateModels() { if (local_session_syncid_ == sync_api::kInvalidId) { // The sync db didn't have a header node for us, we need to create one. sync_api::WriteNode write_node(&trans); - if (!write_node.InitUniqueByCreation(SESSIONS, - root, - current_machine_tag_)) { + sync_api::WriteNode::InitUniqueByCreationResult result = + write_node.InitUniqueByCreation(SESSIONS, root, current_machine_tag_); + if (result != sync_api::WriteNode::INIT_SUCCESS) { // If we can't look it up, and we can't create it, chances are there's // a pre-existing node that has encryption issues. But, since we can't // load the item, we can't remove it, and error out at this point. @@ -1354,7 +1354,9 @@ int64 SessionModelAssociator::TabNodePool::GetFreeTabNode() { size_t tab_node_id = tab_syncid_pool_.size(); std::string tab_node_tag = TabIdToTag(machine_tag_, tab_node_id); sync_api::WriteNode tab_node(&trans); - if (!tab_node.InitUniqueByCreation(SESSIONS, root, tab_node_tag)) { + sync_api::WriteNode::InitUniqueByCreationResult result = + tab_node.InitUniqueByCreation(SESSIONS, root, tab_node_tag); + if (result != sync_api::WriteNode::INIT_SUCCESS) { LOG(ERROR) << "Could not create new node with tag " << tab_node_tag << "!"; return sync_api::kInvalidId; diff --git a/chrome/browser/sync/glue/theme_model_associator.cc b/chrome/browser/sync/glue/theme_model_associator.cc index 8ea538a3..1d9682e 100644 --- a/chrome/browser/sync/glue/theme_model_associator.cc +++ b/chrome/browser/sync/glue/theme_model_associator.cc @@ -68,8 +68,10 @@ SyncError ThemeModelAssociator::AssociateModels() { } else { // Set the sync data from the current theme. sync_api::WriteNode node(&trans); - if (!node.InitUniqueByCreation(syncable::THEMES, root, - kCurrentThemeClientTag)) { + sync_api::WriteNode::InitUniqueByCreationResult result = + node.InitUniqueByCreation(syncable::THEMES, root, + kCurrentThemeClientTag); + if (result != sync_api::WriteNode::INIT_SUCCESS) { return error_handler_->CreateAndUploadError( FROM_HERE, "Could not create current theme node.", diff --git a/chrome/browser/sync/glue/typed_url_change_processor.cc b/chrome/browser/sync/glue/typed_url_change_processor.cc index b1fdd59..34b1223 100644 --- a/chrome/browser/sync/glue/typed_url_change_processor.cc +++ b/chrome/browser/sync/glue/typed_url_change_processor.cc @@ -162,8 +162,10 @@ bool TypedUrlChangeProcessor::CreateOrUpdateSyncNode( } } else { sync_api::WriteNode create_node(trans); - if (!create_node.InitUniqueByCreation(syncable::TYPED_URLS, - typed_url_root, tag)) { + sync_api::WriteNode::InitUniqueByCreationResult result = + create_node.InitUniqueByCreation(syncable::TYPED_URLS, + typed_url_root, tag); + if (result != sync_api::WriteNode::INIT_SUCCESS) { error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Failed to create typed_url sync node."); return false; diff --git a/chrome/browser/sync/glue/typed_url_model_associator.cc b/chrome/browser/sync/glue/typed_url_model_associator.cc index ad90e63..45e9b79 100644 --- a/chrome/browser/sync/glue/typed_url_model_associator.cc +++ b/chrome/browser/sync/glue/typed_url_model_associator.cc @@ -273,8 +273,10 @@ SyncError TypedUrlModelAssociator::DoAssociateModels() { } else { // Sync has never seen this URL before. sync_api::WriteNode node(&trans); - if (!node.InitUniqueByCreation(syncable::TYPED_URLS, - typed_url_root, tag)) { + sync_api::WriteNode::InitUniqueByCreationResult result = + node.InitUniqueByCreation(syncable::TYPED_URLS, + typed_url_root, tag); + if (result != sync_api::WriteNode::INIT_SUCCESS) { return error_handler_->CreateAndUploadError( FROM_HERE, "Failed to create typed_url sync node: " + tag, |