Home | History | Annotate | Download | only in sync_driver
      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_GENERIC_CHANGE_PROCESSOR_H_
      6 #define COMPONENTS_SYNC_DRIVER_FAKE_GENERIC_CHANGE_PROCESSOR_H_
      7 
      8 #include "components/sync_driver/generic_change_processor.h"
      9 
     10 #include "components/sync_driver/generic_change_processor_factory.h"
     11 #include "components/sync_driver/sync_api_component_factory.h"
     12 #include "sync/api/sync_error.h"
     13 
     14 namespace browser_sync {
     15 
     16 // A fake GenericChangeProcessor that can return arbitrary values.
     17 class FakeGenericChangeProcessor : public GenericChangeProcessor {
     18  public:
     19   FakeGenericChangeProcessor(SyncApiComponentFactory* sync_factory);
     20   virtual ~FakeGenericChangeProcessor();
     21 
     22   // Setters for GenericChangeProcessor implementation results.
     23   void set_sync_model_has_user_created_nodes(bool has_nodes);
     24   void set_sync_model_has_user_created_nodes_success(bool success);
     25 
     26   // GenericChangeProcessor implementations.
     27   virtual syncer::SyncError ProcessSyncChanges(
     28       const tracked_objects::Location& from_here,
     29       const syncer::SyncChangeList& change_list) OVERRIDE;
     30   virtual syncer::SyncError GetAllSyncDataReturnError(
     31       syncer::ModelType type,
     32       syncer::SyncDataList* data) const OVERRIDE;
     33   virtual bool GetDataTypeContext(syncer::ModelType type,
     34                                   std::string* context) const OVERRIDE;
     35   virtual int GetSyncCountForType(syncer::ModelType type) OVERRIDE;
     36   virtual bool SyncModelHasUserCreatedNodes(syncer::ModelType type,
     37                                             bool* has_nodes) OVERRIDE;
     38   virtual bool CryptoReadyIfNecessary(syncer::ModelType type) OVERRIDE;
     39 
     40  private:
     41   bool sync_model_has_user_created_nodes_;
     42   bool sync_model_has_user_created_nodes_success_;
     43 };
     44 
     45 // Define a factory for FakeGenericChangeProcessor for convenience.
     46 class FakeGenericChangeProcessorFactory : public GenericChangeProcessorFactory {
     47  public:
     48   explicit FakeGenericChangeProcessorFactory(
     49       scoped_ptr<FakeGenericChangeProcessor> processor);
     50   virtual ~FakeGenericChangeProcessorFactory();
     51   virtual scoped_ptr<GenericChangeProcessor> CreateGenericChangeProcessor(
     52       syncer::UserShare* user_share,
     53       browser_sync::DataTypeErrorHandler* error_handler,
     54       const base::WeakPtr<syncer::SyncableService>& local_service,
     55       const base::WeakPtr<syncer::SyncMergeResult>& merge_result,
     56       SyncApiComponentFactory* sync_factory) OVERRIDE;
     57 
     58  private:
     59   scoped_ptr<FakeGenericChangeProcessor> processor_;
     60   DISALLOW_COPY_AND_ASSIGN(FakeGenericChangeProcessorFactory);
     61 };
     62 
     63 }  // namespace browser_sync
     64 
     65 #endif  // COMPONENTS_SYNC_DRIVER_FAKE_GENERIC_CHANGE_PROCESSOR_H_
     66