#ifndef SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_
#define SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_
#include <set>
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "sync/engine/model_changing_syncer_command.h"
#include "sync/protocol/sync.pb.h"
namespace syncer {
namespace sessions {
class OrderedCommitSet;
}
namespace syncable {
class Id;
class WriteTransaction;
class MutableEntry;
class Directory;
}
class ProcessCommitResponseCommand : public ModelChangingSyncerCommand {
public:
ProcessCommitResponseCommand(
const sessions::OrderedCommitSet& commit_set,
const sync_pb::ClientToServerMessage& commit_message,
const sync_pb::ClientToServerResponse& commit_response);
virtual ~ProcessCommitResponseCommand();
protected:
virtual std::set<ModelSafeGroup> GetGroupsToChange(
const sessions::SyncSession& session) const OVERRIDE;
virtual SyncerError ModelChangingExecuteImpl(
sessions::SyncSession* session) OVERRIDE;
private:
sync_pb::CommitResponse::ResponseType ProcessSingleCommitResponse(
syncable::WriteTransaction* trans,
const sync_pb::CommitResponse_EntryResponse& pb_commit_response,
const sync_pb::SyncEntity& pb_committed_entry,
const syncable::Id& pre_commit_id,
std::set<syncable::Id>* deleted_folders);
SyncerError ProcessCommitResponse(sessions::SyncSession* session);
void ProcessSuccessfulCommitResponse(
const sync_pb::SyncEntity& committed_entry,
const sync_pb::CommitResponse_EntryResponse& entry_response,
const syncable::Id& pre_commit_id, syncable::MutableEntry* local_entry,
bool syncing_was_set, std::set<syncable::Id>* deleted_folders);
bool UpdateVersionAfterCommit(
const sync_pb::SyncEntity& committed_entry,
const sync_pb::CommitResponse_EntryResponse& entry_response,
const syncable::Id& pre_commit_id,
syncable::MutableEntry* local_entry);
bool ChangeIdAfterCommit(
const sync_pb::CommitResponse_EntryResponse& entry_response,
const syncable::Id& pre_commit_id,
syncable::MutableEntry* local_entry);
void UpdateServerFieldsAfterCommit(
const sync_pb::SyncEntity& committed_entry,
const sync_pb::CommitResponse_EntryResponse& entry_response,
syncable::MutableEntry* local_entry);
void OverrideClientFieldsAfterCommit(
const sync_pb::SyncEntity& committed_entry,
const sync_pb::CommitResponse_EntryResponse& entry_response,
syncable::MutableEntry* local_entry);
const std::string& GetResultingPostCommitName(
const sync_pb::SyncEntity& committed_entry,
const sync_pb::CommitResponse_EntryResponse& entry_response);
void ClearSyncingBits(
syncable::Directory *dir,
const std::vector<syncable::Id>& commit_ids);
const sessions::OrderedCommitSet& commit_set_;
const sync_pb::ClientToServerMessage& commit_message_;
const sync_pb::ClientToServerResponse& commit_response_;
DISALLOW_COPY_AND_ASSIGN(ProcessCommitResponseCommand);
};
}
#endif