#ifndef COMPONENTS_SYNC_ENGINE_GET_UPDATES_PROCESSOR_H_
#define COMPONENTS_SYNC_ENGINE_GET_UPDATES_PROCESSOR_H_
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "components/sync/base/model_type.h"
#include "components/sync/base/syncer_error.h"
#include "components/sync/engine/model_type_registry.h"
namespace sync_pb {
class GetUpdatesResponse;
class ClientToServerMessage;
}
namespace syncer {
class GetUpdatesDelegate;
class StatusController;
class SyncCycle;
class GetUpdatesProcessor {
public:
explicit GetUpdatesProcessor(UpdateHandlerMap* update_handler_map,
const GetUpdatesDelegate& delegate);
GetUpdatesProcessor(const GetUpdatesProcessor&) = delete;
GetUpdatesProcessor& operator=(const GetUpdatesProcessor&) = delete;
~GetUpdatesProcessor();
SyncerError DownloadUpdates(ModelTypeSet* request_types, SyncCycle* cycle);
void ApplyUpdates(const ModelTypeSet& gu_types,
StatusController* status_controller);
private:
void PrepareGetUpdates(const ModelTypeSet& gu_types,
sync_pb::ClientToServerMessage* message);
SyncerError ExecuteDownloadUpdates(ModelTypeSet* request_types,
SyncCycle* cycle,
sync_pb::ClientToServerMessage* msg);
SyncerError ProcessResponse(const sync_pb::GetUpdatesResponse& gu_response,
const ModelTypeSet& gu_types,
StatusController* status_controller);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, BookmarkNudge);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NotifyNormalDelegate);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NotifyConfigureDelegate);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest,
NotifyPollGetUpdatesDelegate);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, InitialSyncRequest);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, ConfigureTest);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, PollTest);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, RetryTest);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NudgeWithRetryTest);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, InvalidResponse);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, MoreToDownloadResponse);
FRIEND_TEST_ALL_PREFIXES(GetUpdatesProcessorTest, NormalResponseTest);
FRIEND_TEST_ALL_PREFIXES(DownloadUpdatesDebugInfoTest,
VerifyCopyClientDebugInfo_Empty);
FRIEND_TEST_ALL_PREFIXES(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites);
raw_ptr<UpdateHandlerMap> update_handler_map_;
const raw_ref<const GetUpdatesDelegate> delegate_;
};
}
#endif