Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: components/sync_driver/generic_change_processor_unittest.cc

Issue 548373003: Move AttachmentStore ownership to datatype (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't create AttachmentService in GenericChangeProcessor if AttachmentStore is NULL Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/sync_driver/generic_change_processor_unittest.cc
diff --git a/components/sync_driver/generic_change_processor_unittest.cc b/components/sync_driver/generic_change_processor_unittest.cc
index bdd72662473f2e6e6591fa809c7a73f8fafe39e5..f4a77a03da4e7c4bcb39378a4147c4be96d04753 100644
--- a/components/sync_driver/generic_change_processor_unittest.cc
+++ b/components/sync_driver/generic_change_processor_unittest.cc
@@ -36,7 +36,8 @@ const char kTestData[] = "some data";
// A mock that keeps track of attachments passed to StoreAttachments.
class MockAttachmentService : public syncer::AttachmentServiceImpl {
public:
- MockAttachmentService();
+ MockAttachmentService(
+ const scoped_refptr<syncer::AttachmentStore>& attachment_store);
virtual ~MockAttachmentService();
virtual void StoreAttachments(const syncer::AttachmentList& attachments,
const StoreCallback& callback) OVERRIDE;
@@ -46,15 +47,14 @@ class MockAttachmentService : public syncer::AttachmentServiceImpl {
std::vector<syncer::AttachmentList> attachment_lists_;
};
-MockAttachmentService::MockAttachmentService()
- : AttachmentServiceImpl(
- scoped_ptr<syncer::AttachmentStore>(new syncer::FakeAttachmentStore(
- base::MessageLoopProxy::current())),
- scoped_ptr<syncer::AttachmentUploader>(
- new syncer::FakeAttachmentUploader),
- scoped_ptr<syncer::AttachmentDownloader>(
- new syncer::FakeAttachmentDownloader),
- NULL) {
+MockAttachmentService::MockAttachmentService(
+ const scoped_refptr<syncer::AttachmentStore>& attachment_store)
+ : AttachmentServiceImpl(attachment_store,
+ scoped_ptr<syncer::AttachmentUploader>(
+ new syncer::FakeAttachmentUploader),
+ scoped_ptr<syncer::AttachmentDownloader>(
+ new syncer::FakeAttachmentDownloader),
+ NULL) {
}
MockAttachmentService::~MockAttachmentService() {
@@ -87,6 +87,7 @@ class MockSyncApiComponentFactory : public SyncApiComponentFactory {
}
virtual scoped_ptr<syncer::AttachmentService> CreateAttachmentService(
+ const scoped_refptr<syncer::AttachmentStore>& attachment_store,
const syncer::UserShare& user_share,
syncer::AttachmentService::Delegate* delegate) OVERRIDE {
EXPECT_TRUE(attachment_service_ != NULL);
@@ -117,8 +118,11 @@ class SyncGenericChangeProcessorTest : public testing::Test {
test_user_share_.user_share());
}
test_user_share_.encryption_handler()->Init();
+ scoped_refptr<syncer::AttachmentStore> attachment_store(
+ new syncer::FakeAttachmentStore(base::MessageLoopProxy::current()));
+
scoped_ptr<MockAttachmentService> mock_attachment_service(
- new MockAttachmentService);
+ new MockAttachmentService(attachment_store));
// GenericChangeProcessor takes ownership of the AttachmentService, but we
// need to have a pointer to it so we can see that it was used properly.
// Take a pointer and trust that GenericChangeProcessor does not prematurely
@@ -131,7 +135,8 @@ class SyncGenericChangeProcessorTest : public testing::Test {
syncable_service_ptr_factory_.GetWeakPtr(),
merge_result_ptr_factory_.GetWeakPtr(),
test_user_share_.user_share(),
- sync_factory_.get()));
+ sync_factory_.get(),
+ attachment_store));
}
virtual void TearDown() OVERRIDE {

Powered by Google App Engine
This is Rietveld 408576698