fake_data_type_controller.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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. 4 5#ifndef COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__ 6#define COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__ 7 8#include "components/sync_driver/data_type_controller.h" 9#include "components/sync_driver/data_type_manager.h" 10 11namespace browser_sync { 12// Fake DataTypeController implementation that simulates the state 13// machine of a typical asynchronous data type. 14// 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 20// functionality.) 21class FakeDataTypeController : public DataTypeController { 22 public: 23 explicit FakeDataTypeController(syncer::ModelType type); 24 25 virtual void LoadModels( 26 const ModelLoadCallback& model_load_callback) OVERRIDE; 27 28 virtual void OnModelLoaded() OVERRIDE; 29 30 virtual void StartAssociating(const StartCallback& start_callback) OVERRIDE; 31 32 void FinishStart(StartResult result); 33 34 virtual void Stop() OVERRIDE; 35 36 virtual syncer::ModelType type() const OVERRIDE; 37 38 virtual std::string name() const OVERRIDE; 39 40 virtual syncer::ModelSafeGroup model_safe_group() const OVERRIDE; 41 42 virtual ChangeProcessor* GetChangeProcessor() const OVERRIDE; 43 44 virtual State state() const OVERRIDE; 45 46 virtual void OnSingleDatatypeUnrecoverableError( 47 const tracked_objects::Location& from_here, 48 const std::string& message) OVERRIDE; 49 50 virtual void SetDelayModelLoad(); 51 52 void SetModelLoadError(syncer::SyncError error); 53 54 virtual void SimulateModelLoadFinishing(); 55 56 protected: 57 virtual ~FakeDataTypeController(); 58 59 private: 60 DataTypeController::State state_; 61 bool model_load_delayed_; 62 syncer::ModelType type_; 63 StartCallback last_start_callback_; 64 ModelLoadCallback model_load_callback_; 65 syncer::SyncError load_error_; 66}; 67 68} // namespace browser_sync 69#endif // COMPONENTS_SYNC_DRIVER_FAKE_DATA_TYPE_CONTROLLER_H__ 70