blob: 20b8204e31e51d777742322b1857c8749a8b0498 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__
#define COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__
#include "components/sync_driver/data_type_controller.h"
#include "components/sync_driver/data_type_manager.h"
namespace sync_driver {
// Fake DataTypeController implementation that simulates the state
// machine of a typical asynchronous data type.
//
// TODO(akalin): Consider using subclasses of
// {Frontend,NonFrontend,NewNonFrontend}DataTypeController instead, so
// that we don't have to update this class if we change the expected
// behavior of controllers. (It would be easier of the above classes
// used delegation instead of subclassing for per-data-type
// functionality.)
class FakeDataTypeController : public DataTypeController {
public:
explicit FakeDataTypeController(syncer::ModelType type);
void LoadModels(const ModelLoadCallback& model_load_callback) override;
void OnModelLoaded() override;
void StartAssociating(const StartCallback& start_callback) override;
void Stop() override;
syncer::ModelType type() const override;
std::string name() const override;
syncer::ModelSafeGroup model_safe_group() const override;
ChangeProcessor* GetChangeProcessor() const override;
State state() const override;
void OnSingleDataTypeUnrecoverableError(
const syncer::SyncError& error) override;
bool ReadyForStart() const override;
void FinishStart(ConfigureResult result);
void SetDelayModelLoad();
void SetModelLoadError(syncer::SyncError error);
void SimulateModelLoadFinishing();
void SetReadyForStart(bool ready);
protected:
~FakeDataTypeController() override;
private:
DataTypeController::State state_;
bool model_load_delayed_;
syncer::ModelType type_;
StartCallback last_start_callback_;
ModelLoadCallback model_load_callback_;
syncer::SyncError load_error_;
bool ready_for_start_;
};
} // namespace sync_driver
#endif // COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__
|