| 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_DATA_TYPE_CONTROLLER_H__ | 5 #ifndef COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__ |
| 6 #define COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__ | 6 #define COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "components/sync/driver/data_type_manager.h" | 11 #include "components/sync/driver/data_type_manager.h" |
| 12 #include "components/sync/driver/directory_data_type_controller.h" | 12 #include "components/sync/driver/directory_data_type_controller.h" |
| 13 | 13 |
| 14 namespace syncer { | 14 namespace sync_driver { |
| 15 | 15 |
| 16 // Fake DataTypeController implementation that simulates the state | 16 // Fake DataTypeController implementation that simulates the state |
| 17 // machine of a typical asynchronous data type. | 17 // machine of a typical asynchronous data type. |
| 18 // | 18 // |
| 19 // TODO(akalin): Consider using subclasses of | 19 // TODO(akalin): Consider using subclasses of |
| 20 // {Frontend,NonFrontend,NewNonFrontend}DataTypeController instead, so | 20 // {Frontend,NonFrontend,NewNonFrontend}DataTypeController instead, so |
| 21 // that we don't have to update this class if we change the expected | 21 // that we don't have to update this class if we change the expected |
| 22 // behavior of controllers. (It would be easier of the above classes | 22 // behavior of controllers. (It would be easier of the above classes |
| 23 // used delegation instead of subclassing for per-data-type | 23 // used delegation instead of subclassing for per-data-type |
| 24 // functionality.) | 24 // functionality.) |
| 25 class FakeDataTypeController : public DirectoryDataTypeController { | 25 class FakeDataTypeController : public DirectoryDataTypeController { |
| 26 public: | 26 public: |
| 27 explicit FakeDataTypeController(ModelType type); | 27 explicit FakeDataTypeController(syncer::ModelType type); |
| 28 ~FakeDataTypeController() override; | 28 ~FakeDataTypeController() override; |
| 29 | 29 |
| 30 // DirectoryDataTypeController implementation. | 30 // DirectoryDataTypeController implementation. |
| 31 bool ShouldLoadModelBeforeConfigure() const override; | 31 bool ShouldLoadModelBeforeConfigure() const override; |
| 32 void LoadModels(const ModelLoadCallback& model_load_callback) override; | 32 void LoadModels(const ModelLoadCallback& model_load_callback) override; |
| 33 void RegisterWithBackend(BackendDataTypeConfigurer* configurer) override; | 33 void RegisterWithBackend(BackendDataTypeConfigurer* configurer) override; |
| 34 void StartAssociating(const StartCallback& start_callback) override; | 34 void StartAssociating(const StartCallback& start_callback) override; |
| 35 void Stop() override; | 35 void Stop() override; |
| 36 std::string name() const override; | 36 std::string name() const override; |
| 37 ModelSafeGroup model_safe_group() const override; | 37 syncer::ModelSafeGroup model_safe_group() const override; |
| 38 ChangeProcessor* GetChangeProcessor() const override; | 38 ChangeProcessor* GetChangeProcessor() const override; |
| 39 State state() const override; | 39 State state() const override; |
| 40 bool ReadyForStart() const override; | 40 bool ReadyForStart() const override; |
| 41 std::unique_ptr<DataTypeErrorHandler> CreateErrorHandler() override; | 41 std::unique_ptr<syncer::DataTypeErrorHandler> CreateErrorHandler() override; |
| 42 | 42 |
| 43 void FinishStart(ConfigureResult result); | 43 void FinishStart(ConfigureResult result); |
| 44 | 44 |
| 45 void SetDelayModelLoad(); | 45 void SetDelayModelLoad(); |
| 46 | 46 |
| 47 void SetModelLoadError(SyncError error); | 47 void SetModelLoadError(syncer::SyncError error); |
| 48 | 48 |
| 49 void SimulateModelLoadFinishing(); | 49 void SimulateModelLoadFinishing(); |
| 50 | 50 |
| 51 void SetReadyForStart(bool ready); | 51 void SetReadyForStart(bool ready); |
| 52 | 52 |
| 53 void SetShouldLoadModelBeforeConfigure(bool value); | 53 void SetShouldLoadModelBeforeConfigure(bool value); |
| 54 | 54 |
| 55 int register_with_backend_call_count() const { | 55 int register_with_backend_call_count() const { |
| 56 return register_with_backend_call_count_; | 56 return register_with_backend_call_count_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 DataTypeController::State state_; | 60 DataTypeController::State state_; |
| 61 bool model_load_delayed_; | 61 bool model_load_delayed_; |
| 62 StartCallback last_start_callback_; | 62 StartCallback last_start_callback_; |
| 63 ModelLoadCallback model_load_callback_; | 63 ModelLoadCallback model_load_callback_; |
| 64 SyncError load_error_; | 64 syncer::SyncError load_error_; |
| 65 bool ready_for_start_; | 65 bool ready_for_start_; |
| 66 bool should_load_model_before_configure_; | 66 bool should_load_model_before_configure_; |
| 67 int register_with_backend_call_count_; | 67 int register_with_backend_call_count_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace syncer | 70 } // namespace sync_driver |
| 71 | 71 |
| 72 #endif // COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__ | 72 #endif // COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__ |
| OLD | NEW |