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.
5 #ifndef COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__
6 #define COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__
8 #include "components/sync_driver/data_type_manager.h"
9 #include "components/sync_driver/directory_data_type_controller.h"
11 namespace sync_driver
{
13 // Fake DataTypeController implementation that simulates the state
14 // machine of a typical asynchronous data type.
16 // TODO(akalin): Consider using subclasses of
17 // {Frontend,NonFrontend,NewNonFrontend}DataTypeController instead, so
18 // that we don't have to update this class if we change the expected
19 // behavior of controllers. (It would be easier of the above classes
20 // used delegation instead of subclassing for per-data-type
22 class FakeDataTypeController
: public DirectoryDataTypeController
{
24 explicit FakeDataTypeController(syncer::ModelType type
);
26 void LoadModels(const ModelLoadCallback
& model_load_callback
) override
;
27 void OnModelLoaded() override
;
28 void StartAssociating(const StartCallback
& start_callback
) override
;
30 syncer::ModelType
type() const override
;
31 std::string
name() const override
;
32 syncer::ModelSafeGroup
model_safe_group() const override
;
33 ChangeProcessor
* GetChangeProcessor() const override
;
34 State
state() const override
;
35 void OnSingleDataTypeUnrecoverableError(
36 const syncer::SyncError
& error
) override
;
37 bool ReadyForStart() const override
;
39 void FinishStart(ConfigureResult result
);
41 void SetDelayModelLoad();
43 void SetModelLoadError(syncer::SyncError error
);
45 void SimulateModelLoadFinishing();
47 void SetReadyForStart(bool ready
);
50 ~FakeDataTypeController() override
;
53 DataTypeController::State state_
;
54 bool model_load_delayed_
;
55 syncer::ModelType type_
;
56 StartCallback last_start_callback_
;
57 ModelLoadCallback model_load_callback_
;
58 syncer::SyncError load_error_
;
59 bool ready_for_start_
;
62 } // namespace sync_driver
64 #endif // COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__