1 // Copyright (c) 2012 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 CHROME_BROWSER_SYNC_GLUE_FAKE_DATA_TYPE_CONTROLLER_H__
6 #define CHROME_BROWSER_SYNC_GLUE_FAKE_DATA_TYPE_CONTROLLER_H__
8 #include "chrome/browser/sync/glue/data_type_controller.h"
9 #include "chrome/browser/sync/glue/data_type_manager.h"
11 namespace browser_sync {
12 // Fake DataTypeController implementation that simulates the state
13 // machine of a typical asynchronous data type.
15 // TODO(akalin): Consider using subclasses of
16 // {Frontend,NonFrontend,NewNonFrontend}DataTypeController instead, so
17 // that we don't have to update this class if we change the expected
18 // behavior of controllers. (It would be easier of the above classes
19 // used delegation instead of subclassing for per-data-type
21 class FakeDataTypeController : public DataTypeController {
23 explicit FakeDataTypeController(syncer::ModelType type);
25 virtual void LoadModels(
26 const ModelLoadCallback& model_load_callback) OVERRIDE;
28 virtual void OnModelLoaded() OVERRIDE;
30 virtual void StartAssociating(const StartCallback& start_callback) OVERRIDE;
32 void FinishStart(StartResult result);
34 virtual void Stop() OVERRIDE;
36 virtual syncer::ModelType type() const OVERRIDE;
38 virtual std::string name() const OVERRIDE;
40 virtual syncer::ModelSafeGroup model_safe_group() const OVERRIDE;
42 virtual State state() const OVERRIDE;
44 virtual void OnSingleDatatypeUnrecoverableError(
45 const tracked_objects::Location& from_here,
46 const std::string& message) OVERRIDE;
48 virtual void RecordUnrecoverableError(
49 const tracked_objects::Location& from_here,
50 const std::string& message) OVERRIDE;
52 virtual void SetDelayModelLoad();
54 void SetModelLoadError(syncer::SyncError error);
56 virtual void SimulateModelLoadFinishing();
59 virtual ~FakeDataTypeController();
62 DataTypeController::State state_;
63 bool model_load_delayed_;
64 syncer::ModelType type_;
65 StartCallback last_start_callback_;
66 ModelLoadCallback model_load_callback_;
67 syncer::SyncError load_error_;
70 } // namespace browser_sync
71 #endif // CHROME_BROWSER_SYNC_GLUE_FAKE_DATA_TYPE_CONTROLLER_H__