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 "components/sync_driver/sync_api_component_factory.h" | 10 #include "components/sync_driver/sync_api_component_factory.h" |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 syncer::SyncError error( | 464 syncer::SyncError error( |
465 FROM_HERE, | 465 FROM_HERE, |
466 syncer::SyncError::DATATYPE_ERROR, | 466 syncer::SyncError::DATATYPE_ERROR, |
467 "Datatype performs attachment operation without initializing " | 467 "Datatype performs attachment operation without initializing " |
468 "attachment store", | 468 "attachment store", |
469 type_); | 469 type_); |
470 error_handler()->OnSingleDataTypeUnrecoverableError(error); | 470 error_handler()->OnSingleDataTypeUnrecoverableError(error); |
471 NOTREACHED(); | 471 NOTREACHED(); |
472 return error; | 472 return error; |
473 } | 473 } |
474 attachment_service_->UploadAttachments(new_attachments); | 474 syncer::AttachmentIdList ids_to_upload; |
| 475 ids_to_upload.reserve(new_attachments.size()); |
| 476 std::copy(new_attachments.begin(), new_attachments.end(), |
| 477 std::back_inserter(ids_to_upload)); |
| 478 attachment_service_->UploadAttachments(ids_to_upload); |
475 } | 479 } |
476 | 480 |
477 return syncer::SyncError(); | 481 return syncer::SyncError(); |
478 } | 482 } |
479 | 483 |
480 // WARNING: this code is sensitive to compiler optimizations. Be careful | 484 // WARNING: this code is sensitive to compiler optimizations. Be careful |
481 // modifying any code around an OnSingleDataTypeUnrecoverableError call, else | 485 // modifying any code around an OnSingleDataTypeUnrecoverableError call, else |
482 // the compiler attempts to merge it with other calls, losing useful information | 486 // the compiler attempts to merge it with other calls, losing useful information |
483 // in breakpad uploads. | 487 // in breakpad uploads. |
484 syncer::SyncError GenericChangeProcessor::HandleActionAdd( | 488 syncer::SyncError GenericChangeProcessor::HandleActionAdd( |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 } | 702 } |
699 | 703 |
700 syncer::UserShare* GenericChangeProcessor::share_handle() const { | 704 syncer::UserShare* GenericChangeProcessor::share_handle() const { |
701 DCHECK(CalledOnValidThread()); | 705 DCHECK(CalledOnValidThread()); |
702 return share_handle_; | 706 return share_handle_; |
703 } | 707 } |
704 | 708 |
705 void GenericChangeProcessor::UploadAllAttachmentsNotOnServer() { | 709 void GenericChangeProcessor::UploadAllAttachmentsNotOnServer() { |
706 DCHECK(CalledOnValidThread()); | 710 DCHECK(CalledOnValidThread()); |
707 DCHECK(attachment_service_.get()); | 711 DCHECK(attachment_service_.get()); |
708 syncer::AttachmentIdSet id_set; | 712 syncer::AttachmentIdList ids; |
709 { | 713 { |
710 syncer::ReadTransaction trans(FROM_HERE, share_handle()); | 714 syncer::ReadTransaction trans(FROM_HERE, share_handle()); |
711 trans.GetAttachmentIdsToUpload(type_, &id_set); | 715 trans.GetAttachmentIdsToUpload(type_, &ids); |
712 } | 716 } |
713 if (!id_set.empty()) { | 717 if (!ids.empty()) { |
714 attachment_service_->UploadAttachments(id_set); | 718 attachment_service_->UploadAttachments(ids); |
715 } | 719 } |
716 } | 720 } |
717 | 721 |
718 scoped_ptr<syncer::AttachmentService> | 722 scoped_ptr<syncer::AttachmentService> |
719 GenericChangeProcessor::GetAttachmentService() const { | 723 GenericChangeProcessor::GetAttachmentService() const { |
720 return scoped_ptr<syncer::AttachmentService>( | 724 return scoped_ptr<syncer::AttachmentService>( |
721 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); | 725 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); |
722 } | 726 } |
723 | 727 |
724 } // namespace sync_driver | 728 } // namespace sync_driver |
OLD | NEW |