• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SYNC_ENGINE_UPDATE_HANDLER_H_
6 #define SYNC_ENGINE_UPDATE_HANDLER_H_
7 
8 #include <vector>
9 
10 #include "sync/base/sync_export.h"
11 #include "sync/internal_api/public/util/syncer_error.h"
12 
13 namespace sync_pb {
14 class DataTypeContext;
15 class DataTypeProgressMarker;
16 class SyncEntity;
17 }
18 
19 typedef std::vector<const sync_pb::SyncEntity*> SyncEntityList;
20 
21 namespace syncer {
22 
23 namespace sessions {
24 class StatusController;
25 }
26 
27 class ModelSafeWorker;
28 
29 // This class represents an entity that can request, receive, and apply updates
30 // from the sync server.
31 class SYNC_EXPORT_PRIVATE UpdateHandler {
32  public:
33   UpdateHandler();
34   virtual ~UpdateHandler() = 0;
35 
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;
39 
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;
43 
44   // Processes the contents of a GetUpdates response message.
45   //
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.
50   //
51   // In this context, "applicable_updates" means the set of updates belonging to
52   // this type.
53   //
54   // Returns SYNCER_OK if the all data was processed successfully, a syncer
55   // error otherwise.
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;
61 
62   // Called at the end of a non-configure GetUpdates loop to apply any unapplied
63   // updates.
64   virtual void ApplyUpdates(sessions::StatusController* status) = 0;
65 
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;
69 };
70 
71 }  // namespace syncer
72 
73 #endif  // SYNC_ENGINE_UPDATE_HANDLER_H_
74