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
3 // found in the LICENSE file.
4
5 #include "components/sync_driver/fake_generic_change_processor.h"
6
7 #include "base/location.h"
8 #include "base/memory/weak_ptr.h"
9 #include "sync/api/syncable_service.h"
10 #include "sync/internal_api/public/attachments/attachment_service_impl.h"
11
12 namespace sync_driver {
13
FakeGenericChangeProcessor(syncer::ModelType type,SyncApiComponentFactory * sync_factory)14 FakeGenericChangeProcessor::FakeGenericChangeProcessor(
15 syncer::ModelType type,
16 SyncApiComponentFactory* sync_factory)
17 : GenericChangeProcessor(type,
18 NULL,
19 base::WeakPtr<syncer::SyncableService>(),
20 base::WeakPtr<syncer::SyncMergeResult>(),
21 NULL,
22 sync_factory,
23 scoped_refptr<syncer::AttachmentStore>()),
24 sync_model_has_user_created_nodes_(true),
25 sync_model_has_user_created_nodes_success_(true) {
26 }
27
~FakeGenericChangeProcessor()28 FakeGenericChangeProcessor::~FakeGenericChangeProcessor() {}
29
set_sync_model_has_user_created_nodes(bool has_nodes)30 void FakeGenericChangeProcessor::set_sync_model_has_user_created_nodes(
31 bool has_nodes) {
32 sync_model_has_user_created_nodes_ = has_nodes;
33 }
set_sync_model_has_user_created_nodes_success(bool success)34 void FakeGenericChangeProcessor::set_sync_model_has_user_created_nodes_success(
35 bool success) {
36 sync_model_has_user_created_nodes_success_ = success;
37 }
38
ProcessSyncChanges(const tracked_objects::Location & from_here,const syncer::SyncChangeList & change_list)39 syncer::SyncError FakeGenericChangeProcessor::ProcessSyncChanges(
40 const tracked_objects::Location& from_here,
41 const syncer::SyncChangeList& change_list) {
42 return syncer::SyncError();
43 }
44
GetAllSyncDataReturnError(syncer::SyncDataList * current_sync_data) const45 syncer::SyncError FakeGenericChangeProcessor::GetAllSyncDataReturnError(
46 syncer::SyncDataList* current_sync_data) const {
47 return syncer::SyncError();
48 }
49
GetDataTypeContext(std::string * context) const50 bool FakeGenericChangeProcessor::GetDataTypeContext(
51 std::string* context) const {
52 return false;
53 }
54
GetSyncCount()55 int FakeGenericChangeProcessor::GetSyncCount() {
56 return 0;
57 }
58
SyncModelHasUserCreatedNodes(bool * has_nodes)59 bool FakeGenericChangeProcessor::SyncModelHasUserCreatedNodes(bool* has_nodes) {
60 *has_nodes = sync_model_has_user_created_nodes_;
61 return sync_model_has_user_created_nodes_success_;
62 }
63
CryptoReadyIfNecessary()64 bool FakeGenericChangeProcessor::CryptoReadyIfNecessary() {
65 return true;
66 }
67
FakeGenericChangeProcessorFactory(scoped_ptr<FakeGenericChangeProcessor> processor)68 FakeGenericChangeProcessorFactory::FakeGenericChangeProcessorFactory(
69 scoped_ptr<FakeGenericChangeProcessor> processor)
70 : processor_(processor.Pass()) {}
71
~FakeGenericChangeProcessorFactory()72 FakeGenericChangeProcessorFactory::~FakeGenericChangeProcessorFactory() {}
73
74 scoped_ptr<GenericChangeProcessor>
CreateGenericChangeProcessor(syncer::ModelType type,syncer::UserShare * user_share,DataTypeErrorHandler * error_handler,const base::WeakPtr<syncer::SyncableService> & local_service,const base::WeakPtr<syncer::SyncMergeResult> & merge_result,SyncApiComponentFactory * sync_factory)75 FakeGenericChangeProcessorFactory::CreateGenericChangeProcessor(
76 syncer::ModelType type,
77 syncer::UserShare* user_share,
78 DataTypeErrorHandler* error_handler,
79 const base::WeakPtr<syncer::SyncableService>& local_service,
80 const base::WeakPtr<syncer::SyncMergeResult>& merge_result,
81 SyncApiComponentFactory* sync_factory) {
82 return processor_.PassAs<GenericChangeProcessor>();
83 }
84
85 } // namespace sync_driver
86