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