summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/fake_data_type_controller.h
blob: 173e9f9e269e4e255db9599423f5a745bd4df422 (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
65
66
67
68
69
// Copyright (c) 2012 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 CHROME_BROWSER_SYNC_GLUE_FAKE_DATA_TYPE_CONTROLLER_H__
#define CHROME_BROWSER_SYNC_GLUE_FAKE_DATA_TYPE_CONTROLLER_H__
#pragma once

#include "chrome/browser/sync/glue/data_type_controller.h"
#include "chrome/browser/sync/glue/data_type_manager.h"

namespace browser_sync {
// 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(syncable::ModelType type);

  virtual void LoadModels(
      const ModelLoadCallback& model_load_callback) OVERRIDE;

  virtual void OnModelLoaded() OVERRIDE;

  virtual void StartAssociating(const StartCallback& start_callback) OVERRIDE;

  void FinishStart(StartResult result);

  virtual void Stop() OVERRIDE;

  virtual syncable::ModelType type() const OVERRIDE;

  virtual std::string name() const OVERRIDE;

  virtual syncer::ModelSafeGroup model_safe_group() const OVERRIDE;

  virtual State state() const OVERRIDE;

  virtual void OnSingleDatatypeUnrecoverableError(
      const tracked_objects::Location& from_here,
      const std::string& message) OVERRIDE;

  virtual void RecordUnrecoverableError(
      const tracked_objects::Location& from_here,
      const std::string& message) OVERRIDE;

  virtual void SetDelayModelLoad();

  virtual void SimulateModelLoadFinishing();

 protected:
  virtual ~FakeDataTypeController();

 private:
  DataTypeController::State state_;
  bool model_load_delayed_;
  syncable::ModelType type_;
  StartCallback last_start_callback_;
  ModelLoadCallback model_load_callback_;
};

}  // namespace browser_sync
#endif  // CHROME_BROWSER_SYNC_GLUE_FAKE_DATA_TYPE_CONTROLLER_H__