| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync_driver/generic_change_processor.h" | 5 #include "components/sync_driver/generic_change_processor.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 // the compiler attempts to merge it with other calls, losing useful information | 487 // the compiler attempts to merge it with other calls, losing useful information |
| 488 // in breakpad uploads. | 488 // in breakpad uploads. |
| 489 syncer::SyncError GenericChangeProcessor::HandleActionAdd( | 489 syncer::SyncError GenericChangeProcessor::HandleActionAdd( |
| 490 const syncer::SyncChange& change, | 490 const syncer::SyncChange& change, |
| 491 const std::string& type_str, | 491 const std::string& type_str, |
| 492 const syncer::WriteTransaction& trans, | 492 const syncer::WriteTransaction& trans, |
| 493 syncer::WriteNode* sync_node, | 493 syncer::WriteNode* sync_node, |
| 494 syncer::AttachmentIdSet* new_attachments) { | 494 syncer::AttachmentIdSet* new_attachments) { |
| 495 // TODO(sync): Handle other types of creation (custom parents, folders, | 495 // TODO(sync): Handle other types of creation (custom parents, folders, |
| 496 // etc.). | 496 // etc.). |
| 497 syncer::ReadNode root_node(&trans); | |
| 498 const syncer::SyncDataLocal sync_data_local(change.sync_data()); | 497 const syncer::SyncDataLocal sync_data_local(change.sync_data()); |
| 499 if (root_node.InitTypeRoot(sync_data_local.GetDataType()) != | |
| 500 syncer::BaseNode::INIT_OK) { | |
| 501 syncer::SyncError error(FROM_HERE, | |
| 502 syncer::SyncError::DATATYPE_ERROR, | |
| 503 "Failed to look up root node for type " + type_str, | |
| 504 type_); | |
| 505 error_handler()->OnSingleDataTypeUnrecoverableError(error); | |
| 506 NOTREACHED(); | |
| 507 LOG(ERROR) << "Create: no root node."; | |
| 508 return error; | |
| 509 } | |
| 510 syncer::WriteNode::InitUniqueByCreationResult result = | 498 syncer::WriteNode::InitUniqueByCreationResult result = |
| 511 sync_node->InitUniqueByCreation( | 499 sync_node->InitUniqueByCreation(sync_data_local.GetDataType(), |
| 512 sync_data_local.GetDataType(), root_node, sync_data_local.GetTag()); | 500 sync_data_local.GetTag()); |
| 513 if (result != syncer::WriteNode::INIT_SUCCESS) { | 501 if (result != syncer::WriteNode::INIT_SUCCESS) { |
| 514 std::string error_prefix = "Failed to create " + type_str + " node: " + | 502 std::string error_prefix = "Failed to create " + type_str + " node: " + |
| 515 change.location().ToString() + ", "; | 503 change.location().ToString() + ", "; |
| 516 switch (result) { | 504 switch (result) { |
| 517 case syncer::WriteNode::INIT_FAILED_EMPTY_TAG: { | 505 case syncer::WriteNode::INIT_FAILED_EMPTY_TAG: { |
| 518 syncer::SyncError error; | 506 syncer::SyncError error; |
| 519 error.Reset(FROM_HERE, error_prefix + "empty tag", type_); | 507 error.Reset(FROM_HERE, error_prefix + "empty tag", type_); |
| 520 error_handler()->OnSingleDataTypeUnrecoverableError(error); | 508 error_handler()->OnSingleDataTypeUnrecoverableError(error); |
| 521 LOG(ERROR) << "Create: Empty tag."; | 509 LOG(ERROR) << "Create: Empty tag."; |
| 522 return error; | 510 return error; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 699 } |
| 712 } | 700 } |
| 713 | 701 |
| 714 scoped_ptr<syncer::AttachmentService> | 702 scoped_ptr<syncer::AttachmentService> |
| 715 GenericChangeProcessor::GetAttachmentService() const { | 703 GenericChangeProcessor::GetAttachmentService() const { |
| 716 return scoped_ptr<syncer::AttachmentService>( | 704 return scoped_ptr<syncer::AttachmentService>( |
| 717 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); | 705 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); |
| 718 } | 706 } |
| 719 | 707 |
| 720 } // namespace sync_driver | 708 } // namespace sync_driver |
| OLD | NEW |