OLD | NEW |
| (Empty) |
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 #ifndef COMPONENTS_SYNC_DRIVER_FAKE_GENERIC_CHANGE_PROCESSOR_H_ | |
6 #define COMPONENTS_SYNC_DRIVER_FAKE_GENERIC_CHANGE_PROCESSOR_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/macros.h" | |
11 #include "components/sync/api/sync_error.h" | |
12 #include "components/sync/base/model_type.h" | |
13 #include "components/sync_driver/generic_change_processor.h" | |
14 #include "components/sync_driver/generic_change_processor_factory.h" | |
15 #include "components/sync_driver/sync_api_component_factory.h" | |
16 | |
17 namespace sync_driver { | |
18 | |
19 // A fake GenericChangeProcessor that can return arbitrary values. | |
20 class FakeGenericChangeProcessor : public GenericChangeProcessor { | |
21 public: | |
22 FakeGenericChangeProcessor(syncer::ModelType type, | |
23 SyncClient* sync_client); | |
24 ~FakeGenericChangeProcessor() override; | |
25 | |
26 // Setters for GenericChangeProcessor implementation results. | |
27 void set_sync_model_has_user_created_nodes(bool has_nodes); | |
28 void set_sync_model_has_user_created_nodes_success(bool success); | |
29 | |
30 // GenericChangeProcessor implementations. | |
31 syncer::SyncError ProcessSyncChanges( | |
32 const tracked_objects::Location& from_here, | |
33 const syncer::SyncChangeList& change_list) override; | |
34 syncer::SyncError GetAllSyncDataReturnError( | |
35 syncer::SyncDataList* data) const override; | |
36 bool GetDataTypeContext(std::string* context) const override; | |
37 int GetSyncCount() override; | |
38 bool SyncModelHasUserCreatedNodes(bool* has_nodes) override; | |
39 bool CryptoReadyIfNecessary() override; | |
40 | |
41 private: | |
42 bool sync_model_has_user_created_nodes_; | |
43 bool sync_model_has_user_created_nodes_success_; | |
44 }; | |
45 | |
46 // Define a factory for FakeGenericChangeProcessor for convenience. | |
47 class FakeGenericChangeProcessorFactory : public GenericChangeProcessorFactory { | |
48 public: | |
49 explicit FakeGenericChangeProcessorFactory( | |
50 std::unique_ptr<FakeGenericChangeProcessor> processor); | |
51 ~FakeGenericChangeProcessorFactory() override; | |
52 std::unique_ptr<GenericChangeProcessor> CreateGenericChangeProcessor( | |
53 syncer::ModelType type, | |
54 syncer::UserShare* user_share, | |
55 syncer::DataTypeErrorHandler* error_handler, | |
56 const base::WeakPtr<syncer::SyncableService>& local_service, | |
57 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, | |
58 SyncClient* sync_client) override; | |
59 | |
60 private: | |
61 std::unique_ptr<FakeGenericChangeProcessor> processor_; | |
62 DISALLOW_COPY_AND_ASSIGN(FakeGenericChangeProcessorFactory); | |
63 }; | |
64 | |
65 } // namespace sync_driver | |
66 | |
67 #endif // COMPONENTS_SYNC_DRIVER_FAKE_GENERIC_CHANGE_PROCESSOR_H_ | |
OLD | NEW |