| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | |
| 9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "components/sync_driver/data_type_error_handler_mock.h" | 16 #include "components/sync_driver/data_type_error_handler_mock.h" |
| 17 #include "components/sync_driver/fake_sync_client.h" | 17 #include "components/sync_driver/fake_sync_client.h" |
| 18 #include "components/sync_driver/local_device_info_provider.h" | 18 #include "components/sync_driver/local_device_info_provider.h" |
| 19 #include "components/sync_driver/sync_api_component_factory.h" | 19 #include "components/sync_driver/sync_api_component_factory.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 49 void UploadAttachments( | 49 void UploadAttachments( |
| 50 const syncer::AttachmentIdList& attachment_ids) override; | 50 const syncer::AttachmentIdList& attachment_ids) override; |
| 51 std::vector<syncer::AttachmentIdList>* attachment_id_lists(); | 51 std::vector<syncer::AttachmentIdList>* attachment_id_lists(); |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 std::vector<syncer::AttachmentIdList> attachment_id_lists_; | 54 std::vector<syncer::AttachmentIdList> attachment_id_lists_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 MockAttachmentService::MockAttachmentService( | 57 MockAttachmentService::MockAttachmentService( |
| 58 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store) | 58 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store) |
| 59 : AttachmentServiceImpl(attachment_store.Pass(), | 59 : AttachmentServiceImpl(std::move(attachment_store), |
| 60 scoped_ptr<syncer::AttachmentUploader>( | 60 scoped_ptr<syncer::AttachmentUploader>( |
| 61 new syncer::FakeAttachmentUploader), | 61 new syncer::FakeAttachmentUploader), |
| 62 scoped_ptr<syncer::AttachmentDownloader>( | 62 scoped_ptr<syncer::AttachmentDownloader>( |
| 63 new syncer::FakeAttachmentDownloader), | 63 new syncer::FakeAttachmentDownloader), |
| 64 NULL, | 64 NULL, |
| 65 base::TimeDelta(), | 65 base::TimeDelta(), |
| 66 base::TimeDelta()) { | 66 base::TimeDelta()) {} |
| 67 } | |
| 68 | 67 |
| 69 MockAttachmentService::~MockAttachmentService() { | 68 MockAttachmentService::~MockAttachmentService() { |
| 70 } | 69 } |
| 71 | 70 |
| 72 void MockAttachmentService::UploadAttachments( | 71 void MockAttachmentService::UploadAttachments( |
| 73 const syncer::AttachmentIdList& attachment_ids) { | 72 const syncer::AttachmentIdList& attachment_ids) { |
| 74 attachment_id_lists_.push_back(attachment_ids); | 73 attachment_id_lists_.push_back(attachment_ids); |
| 75 AttachmentServiceImpl::UploadAttachments(attachment_ids); | 74 AttachmentServiceImpl::UploadAttachments(attachment_ids); |
| 76 } | 75 } |
| 77 | 76 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 return SyncComponents(nullptr, nullptr); | 112 return SyncComponents(nullptr, nullptr); |
| 114 } | 113 } |
| 115 | 114 |
| 116 scoped_ptr<syncer::AttachmentService> CreateAttachmentService( | 115 scoped_ptr<syncer::AttachmentService> CreateAttachmentService( |
| 117 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, | 116 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, |
| 118 const syncer::UserShare& user_share, | 117 const syncer::UserShare& user_share, |
| 119 const std::string& store_birthday, | 118 const std::string& store_birthday, |
| 120 syncer::ModelType model_type, | 119 syncer::ModelType model_type, |
| 121 syncer::AttachmentService::Delegate* delegate) override { | 120 syncer::AttachmentService::Delegate* delegate) override { |
| 122 scoped_ptr<MockAttachmentService> attachment_service( | 121 scoped_ptr<MockAttachmentService> attachment_service( |
| 123 new MockAttachmentService(attachment_store.Pass())); | 122 new MockAttachmentService(std::move(attachment_store))); |
| 124 // GenericChangeProcessor takes ownership of the AttachmentService, but we | 123 // GenericChangeProcessor takes ownership of the AttachmentService, but we |
| 125 // need to have a pointer to it so we can see that it was used properly. | 124 // need to have a pointer to it so we can see that it was used properly. |
| 126 // Take a pointer and trust that GenericChangeProcessor does not prematurely | 125 // Take a pointer and trust that GenericChangeProcessor does not prematurely |
| 127 // destroy it. | 126 // destroy it. |
| 128 mock_attachment_service_ = attachment_service.get(); | 127 mock_attachment_service_ = attachment_service.get(); |
| 129 return attachment_service.Pass(); | 128 return std::move(attachment_service); |
| 130 } | 129 } |
| 131 | 130 |
| 132 MockAttachmentService* GetMockAttachmentService() { | 131 MockAttachmentService* GetMockAttachmentService() { |
| 133 return mock_attachment_service_; | 132 return mock_attachment_service_; |
| 134 } | 133 } |
| 135 | 134 |
| 136 private: | 135 private: |
| 137 MockAttachmentService* mock_attachment_service_; | 136 MockAttachmentService* mock_attachment_service_; |
| 138 }; | 137 }; |
| 139 | 138 |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 syncer::SyncDataList sync_data = | 535 syncer::SyncDataList sync_data = |
| 537 change_processor()->GetAllSyncData(syncer::SESSIONS); | 536 change_processor()->GetAllSyncData(syncer::SESSIONS); |
| 538 ASSERT_EQ(sync_data.size(), 1U); | 537 ASSERT_EQ(sync_data.size(), 1U); |
| 539 ASSERT_EQ("session tag 2", | 538 ASSERT_EQ("session tag 2", |
| 540 sync_data[0].GetSpecifics().session().session_tag()); | 539 sync_data[0].GetSpecifics().session().session_tag()); |
| 541 } | 540 } |
| 542 | 541 |
| 543 } // namespace | 542 } // namespace |
| 544 | 543 |
| 545 } // namespace sync_driver | 544 } // namespace sync_driver |
| OLD | NEW |