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.
5 #ifndef SYNC_ENGINE_UPDATE_HANDLER_H_
6 #define SYNC_ENGINE_UPDATE_HANDLER_H_
10 #include "sync/base/sync_export.h"
11 #include "sync/internal_api/public/util/syncer_error.h"
14 class DataTypeContext
;
15 class DataTypeProgressMarker
;
19 typedef std::vector
<const sync_pb::SyncEntity
*> SyncEntityList
;
24 class StatusController
;
27 class ModelSafeWorker
;
29 // This class represents an entity that can request, receive, and apply updates
30 // from the sync server.
31 class SYNC_EXPORT_PRIVATE UpdateHandler
{
34 virtual ~UpdateHandler() = 0;
36 // Fills the given parameter with the stored progress marker for this type.
37 virtual void GetDownloadProgress(
38 sync_pb::DataTypeProgressMarker
* progress_marker
) const = 0;
40 // Fills |context| with the per-client datatype context, if one exists. Clears
41 // |context| otherwise.
42 virtual void GetDataTypeContext(sync_pb::DataTypeContext
* context
) const = 0;
44 // Processes the contents of a GetUpdates response message.
46 // Should be invoked with the progress marker and set of SyncEntities from a
47 // single GetUpdates response message. The progress marker's type must match
48 // this update handler's type, and the set of SyncEntities must include all
49 // entities of this type found in the response message.
51 // In this context, "applicable_updates" means the set of updates belonging to
54 // Returns SYNCER_OK if the all data was processed successfully, a syncer
56 virtual SyncerError
ProcessGetUpdatesResponse(
57 const sync_pb::DataTypeProgressMarker
& progress_marker
,
58 const sync_pb::DataTypeContext
& mutated_context
,
59 const SyncEntityList
& applicable_updates
,
60 sessions::StatusController
* status
) = 0;
62 // Called at the end of a non-configure GetUpdates loop to apply any unapplied
64 virtual void ApplyUpdates(sessions::StatusController
* status
) = 0;
66 // Called at the end of a configure GetUpdates loop to perform any required
67 // post-initial-download update application.
68 virtual void PassiveApplyUpdates(sessions::StatusController
* status
) = 0;
73 #endif // SYNC_ENGINE_UPDATE_HANDLER_H_