#ifndef CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_
#define CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "chrome/browser/sync/glue/change_processor.h"
#include "components/sync_driver/data_type_controller.h"
#include "components/sync_driver/data_type_error_handler.h"
#include "sync/api/attachments/attachment_service.h"
#include "sync/api/attachments/attachment_service_proxy.h"
#include "sync/api/sync_change_processor.h"
#include "sync/api/sync_merge_result.h"
namespace syncer {
class SyncData;
class SyncableService;
class WriteNode;
class WriteTransaction;
typedef std::vector<syncer::SyncData> SyncDataList;
}
namespace browser_sync {
class GenericChangeProcessor : public ChangeProcessor,
public syncer::SyncChangeProcessor,
public base::NonThreadSafe {
public:
GenericChangeProcessor(
DataTypeErrorHandler* error_handler,
const base::WeakPtr<syncer::SyncableService>& local_service,
const base::WeakPtr<syncer::SyncMergeResult>& merge_result,
syncer::UserShare* user_share,
scoped_ptr<syncer::AttachmentService> attachment_service);
virtual ~GenericChangeProcessor();
virtual void ApplyChangesFromSyncModel(
const syncer::BaseTransaction* trans,
int64 version,
const syncer::ImmutableChangeRecordList& changes) OVERRIDE;
virtual void CommitChangesFromSyncModel() OVERRIDE;
virtual syncer::SyncError ProcessSyncChanges(
const tracked_objects::Location& from_here,
const syncer::SyncChangeList& change_list) OVERRIDE;
virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type)
const OVERRIDE;
virtual syncer::SyncError UpdateDataTypeContext(
syncer::ModelType type,
const std::string& context) OVERRIDE;
virtual syncer::SyncError GetAllSyncDataReturnError(
syncer::ModelType type,
syncer::SyncDataList* data) const;
virtual int GetSyncCountForType(syncer::ModelType type);
virtual bool SyncModelHasUserCreatedNodes(syncer::ModelType type,
bool* has_nodes);
virtual bool CryptoReadyIfNecessary(syncer::ModelType type);
protected:
virtual void StartImpl(Profile* profile) OVERRIDE;
virtual syncer::UserShare* share_handle() const OVERRIDE;
private:
syncer::SyncError HandleActionAdd(const syncer::SyncChange& change,
const std::string& type_str,
const syncer::ModelType& type,
const syncer::WriteTransaction& trans,
syncer::WriteNode* sync_node);
syncer::SyncError HandleActionUpdate(const syncer::SyncChange& change,
const std::string& type_str,
const syncer::ModelType& type,
const syncer::WriteTransaction& trans,
syncer::WriteNode* sync_node);
const base::WeakPtr<syncer::SyncableService> local_service_;
const base::WeakPtr<syncer::SyncMergeResult> merge_result_;
syncer::SyncChangeList syncer_changes_;
syncer::UserShare* const share_handle_;
scoped_ptr<syncer::AttachmentService> attachment_service_;
base::WeakPtrFactory<syncer::AttachmentService>
attachment_service_weak_ptr_factory_;
syncer::AttachmentServiceProxy attachment_service_proxy_;
DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor);
};
}
#endif