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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 virtual ~MockAttachmentService(); | 40 virtual ~MockAttachmentService(); |
41 virtual void StoreAttachments(const syncer::AttachmentList& attachments, | 41 virtual void StoreAttachments(const syncer::AttachmentList& attachments, |
42 const StoreCallback& callback) OVERRIDE; | 42 const StoreCallback& callback) OVERRIDE; |
43 std::vector<syncer::AttachmentList>* attachment_lists(); | 43 std::vector<syncer::AttachmentList>* attachment_lists(); |
44 | 44 |
45 private: | 45 private: |
46 std::vector<syncer::AttachmentList> attachment_lists_; | 46 std::vector<syncer::AttachmentList> attachment_lists_; |
47 }; | 47 }; |
48 | 48 |
49 MockAttachmentService::MockAttachmentService() | 49 MockAttachmentService::MockAttachmentService() |
50 : AttachmentServiceImpl( | 50 : AttachmentServiceImpl(scoped_refptr<syncer::AttachmentStore>( |
51 scoped_ptr<syncer::AttachmentStore>(new syncer::FakeAttachmentStore( | 51 new syncer::FakeAttachmentStore( |
52 base::MessageLoopProxy::current())), | 52 base::MessageLoopProxy::current())), |
53 scoped_ptr<syncer::AttachmentUploader>( | 53 scoped_ptr<syncer::AttachmentUploader>( |
54 new syncer::FakeAttachmentUploader), | 54 new syncer::FakeAttachmentUploader), |
55 scoped_ptr<syncer::AttachmentDownloader>( | 55 scoped_ptr<syncer::AttachmentDownloader>( |
56 new syncer::FakeAttachmentDownloader), | 56 new syncer::FakeAttachmentDownloader), |
57 NULL) { | 57 NULL) { |
58 } | 58 } |
59 | 59 |
60 MockAttachmentService::~MockAttachmentService() { | 60 MockAttachmentService::~MockAttachmentService() { |
61 } | 61 } |
62 | 62 |
63 void MockAttachmentService::StoreAttachments( | 63 void MockAttachmentService::StoreAttachments( |
64 const syncer::AttachmentList& attachments, | 64 const syncer::AttachmentList& attachments, |
65 const StoreCallback& callback) { | 65 const StoreCallback& callback) { |
66 attachment_lists_.push_back(attachments); | 66 attachment_lists_.push_back(attachments); |
67 AttachmentServiceImpl::StoreAttachments(attachments, callback); | 67 AttachmentServiceImpl::StoreAttachments(attachments, callback); |
(...skipping 12 matching lines...) Expand all Loading... |
80 : attachment_service_(attachment_service.Pass()) {} | 80 : attachment_service_(attachment_service.Pass()) {} |
81 | 81 |
82 virtual base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( | 82 virtual base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( |
83 syncer::ModelType type) OVERRIDE { | 83 syncer::ModelType type) OVERRIDE { |
84 // Shouldn't be called for this test. | 84 // Shouldn't be called for this test. |
85 NOTREACHED(); | 85 NOTREACHED(); |
86 return base::WeakPtr<syncer::SyncableService>(); | 86 return base::WeakPtr<syncer::SyncableService>(); |
87 } | 87 } |
88 | 88 |
89 virtual scoped_ptr<syncer::AttachmentService> CreateAttachmentService( | 89 virtual scoped_ptr<syncer::AttachmentService> CreateAttachmentService( |
| 90 const scoped_refptr<syncer::AttachmentStore>& attachment_store, |
90 const syncer::UserShare& user_share, | 91 const syncer::UserShare& user_share, |
91 syncer::AttachmentService::Delegate* delegate) OVERRIDE { | 92 syncer::AttachmentService::Delegate* delegate) OVERRIDE { |
92 EXPECT_TRUE(attachment_service_ != NULL); | 93 EXPECT_TRUE(attachment_service_ != NULL); |
93 return attachment_service_.Pass(); | 94 return attachment_service_.Pass(); |
94 } | 95 } |
95 | 96 |
96 private: | 97 private: |
97 scoped_ptr<syncer::AttachmentService> attachment_service_; | 98 scoped_ptr<syncer::AttachmentService> attachment_service_; |
98 }; | 99 }; |
99 | 100 |
(...skipping 24 matching lines...) Expand all Loading... |
124 // Take a pointer and trust that GenericChangeProcessor does not prematurely | 125 // Take a pointer and trust that GenericChangeProcessor does not prematurely |
125 // destroy it. | 126 // destroy it. |
126 mock_attachment_service_ = mock_attachment_service.get(); | 127 mock_attachment_service_ = mock_attachment_service.get(); |
127 sync_factory_.reset(new MockSyncApiComponentFactory( | 128 sync_factory_.reset(new MockSyncApiComponentFactory( |
128 mock_attachment_service.PassAs<syncer::AttachmentService>())); | 129 mock_attachment_service.PassAs<syncer::AttachmentService>())); |
129 change_processor_.reset( | 130 change_processor_.reset( |
130 new GenericChangeProcessor(&data_type_error_handler_, | 131 new GenericChangeProcessor(&data_type_error_handler_, |
131 syncable_service_ptr_factory_.GetWeakPtr(), | 132 syncable_service_ptr_factory_.GetWeakPtr(), |
132 merge_result_ptr_factory_.GetWeakPtr(), | 133 merge_result_ptr_factory_.GetWeakPtr(), |
133 test_user_share_.user_share(), | 134 test_user_share_.user_share(), |
134 sync_factory_.get())); | 135 sync_factory_.get(), |
| 136 scoped_refptr<syncer::AttachmentStore>())); |
135 } | 137 } |
136 | 138 |
137 virtual void TearDown() OVERRIDE { | 139 virtual void TearDown() OVERRIDE { |
138 mock_attachment_service_ = NULL; | 140 mock_attachment_service_ = NULL; |
139 test_user_share_.TearDown(); | 141 test_user_share_.TearDown(); |
140 } | 142 } |
141 | 143 |
142 void BuildChildNodes(int n) { | 144 void BuildChildNodes(int n) { |
143 syncer::WriteTransaction trans(FROM_HERE, user_share()); | 145 syncer::WriteTransaction trans(FROM_HERE, user_share()); |
144 syncer::ReadNode root(&trans); | 146 syncer::ReadNode root(&trans); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 syncer::ReadNode node(&read_transaction); | 415 syncer::ReadNode node(&read_transaction); |
414 ASSERT_EQ(node.InitByClientTagLookup(syncer::PREFERENCES, tag), | 416 ASSERT_EQ(node.InitByClientTagLookup(syncer::PREFERENCES, tag), |
415 syncer::BaseNode::INIT_OK); | 417 syncer::BaseNode::INIT_OK); |
416 syncer::AttachmentIdList attachment_ids = node.GetAttachmentIds(); | 418 syncer::AttachmentIdList attachment_ids = node.GetAttachmentIds(); |
417 EXPECT_EQ(1U, attachment_ids.size()); | 419 EXPECT_EQ(1U, attachment_ids.size()); |
418 } | 420 } |
419 | 421 |
420 } // namespace | 422 } // namespace |
421 | 423 |
422 } // namespace sync_driver | 424 } // namespace sync_driver |
OLD | NEW |