Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: sync/engine/directory_update_handler.h

Issue 161253002: sync: Add interfaces for per-type sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor fix Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SYNC_ENGINE_SYNC_DIRECTORY_UPDATE_HANDLER_H_ 5 #ifndef SYNC_ENGINE_DIRECTORY_UPDATE_HANDLER_H_
6 #define SYNC_ENGINE_SYNC_DIRECTORY_UPDATE_HANDLER_H_ 6 #define SYNC_ENGINE_DIRECTORY_UPDATE_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "sync/base/sync_export.h" 12 #include "sync/base/sync_export.h"
13 #include "sync/engine/process_updates_util.h" 13 #include "sync/engine/process_updates_util.h"
14 #include "sync/engine/update_handler.h"
14 #include "sync/internal_api/public/base/model_type.h" 15 #include "sync/internal_api/public/base/model_type.h"
15 #include "sync/internal_api/public/util/syncer_error.h" 16 #include "sync/internal_api/public/util/syncer_error.h"
16 17
17 namespace sync_pb { 18 namespace sync_pb {
18 class DataTypeProgressMarker; 19 class DataTypeProgressMarker;
19 class GetUpdatesResponse; 20 class GetUpdatesResponse;
20 } 21 }
21 22
22 namespace syncer { 23 namespace syncer {
23 24
24 namespace sessions { 25 namespace sessions {
25 class StatusController; 26 class StatusController;
26 } 27 }
27 28
28 namespace syncable { 29 namespace syncable {
29 class Directory; 30 class Directory;
30 } 31 }
31 32
32 class ModelSafeWorker; 33 class ModelSafeWorker;
33 34
34 // This class represents the syncable::Directory's processes for requesting and 35 // This class represents the syncable::Directory's processes for requesting and
35 // processing updates from the sync server. 36 // processing updates from the sync server.
36 // 37 //
37 // Each instance of this class represents a particular type in the 38 // Each instance of this class represents a particular type in the
38 // syncable::Directory. It can store and retreive that type's progress markers. 39 // syncable::Directory. It can store and retreive that type's progress markers.
39 // It can also process a set of received SyncEntities and store their data. 40 // It can also process a set of received SyncEntities and store their data.
40 class SYNC_EXPORT_PRIVATE SyncDirectoryUpdateHandler { 41 class SYNC_EXPORT_PRIVATE DirectoryUpdateHandler : public UpdateHandler {
41 public: 42 public:
42 SyncDirectoryUpdateHandler(syncable::Directory* dir, 43 DirectoryUpdateHandler(syncable::Directory* dir,
43 ModelType type, 44 ModelType type,
tim (not reviewing) 2014/02/18 19:15:01 nit - indent is off.
rlarocque 2014/02/18 20:01:13 Done.
44 scoped_refptr<ModelSafeWorker> worker); 45 scoped_refptr<ModelSafeWorker> worker);
45 ~SyncDirectoryUpdateHandler(); 46 virtual ~DirectoryUpdateHandler() OVERRIDE;
46 47
47 // Fills the given parameter with the stored progress marker for this type. 48 // Fills the given parameter with the stored progress marker for this type.
48 void GetDownloadProgress( 49 virtual void GetDownloadProgress(
49 sync_pb::DataTypeProgressMarker* progress_marker) const; 50 sync_pb::DataTypeProgressMarker* progress_marker) const OVERRIDE;
50 51
51 // Processes the contents of a GetUpdates response message. 52 // Processes the contents of a GetUpdates response message.
52 // 53 //
53 // Should be invoked with the progress marker and set of SyncEntities from a 54 // Should be invoked with the progress marker and set of SyncEntities from a
54 // single GetUpdates response message. The progress marker's type must match 55 // single GetUpdates response message. The progress marker's type must match
55 // this update handler's type, and the set of SyncEntities must include all 56 // this update handler's type, and the set of SyncEntities must include all
56 // entities of this type found in the response message. 57 // entities of this type found in the response message.
57 void ProcessGetUpdatesResponse( 58 virtual void ProcessGetUpdatesResponse(
58 const sync_pb::DataTypeProgressMarker& progress_marker, 59 const sync_pb::DataTypeProgressMarker& progress_marker,
59 const SyncEntityList& applicable_updates, 60 const SyncEntityList& applicable_updates,
60 sessions::StatusController* status); 61 sessions::StatusController* status) OVERRIDE;
61 62
62 // If there are updates to apply, apply them on the proper thread. 63 // If there are updates to apply, apply them on the proper thread.
63 // Delegates to ApplyUpdatesImpl(). 64 // Delegates to ApplyUpdatesImpl().
64 void ApplyUpdates(sessions::StatusController* status); 65 virtual void ApplyUpdates(sessions::StatusController* status) OVERRIDE;
65 66
66 // Apply updates on the sync thread. This is for use during initial sync 67 // Apply updates on the sync thread. This is for use during initial sync
67 // prior to model association. 68 // prior to model association.
68 void PassiveApplyUpdates(sessions::StatusController* status); 69 virtual void PassiveApplyUpdates(sessions::StatusController* status) OVERRIDE;
69 70
70 private: 71 private:
71 friend class SyncDirectoryUpdateHandlerApplyUpdateTest; 72 friend class DirectoryUpdateHandlerApplyUpdateTest;
72 friend class SyncDirectoryUpdateHandlerProcessUpdateTest; 73 friend class DirectoryUpdateHandlerProcessUpdateTest;
73 74
74 // Sometimes there is nothing to do, so we can return without doing anything. 75 // Sometimes there is nothing to do, so we can return without doing anything.
75 bool IsApplyUpdatesRequired(); 76 bool IsApplyUpdatesRequired();
76 77
77 // Processes the given SyncEntities and stores their data in the directory. 78 // Processes the given SyncEntities and stores their data in the directory.
78 // Their types must match this update handler's type. 79 // Their types must match this update handler's type.
79 void UpdateSyncEntities( 80 void UpdateSyncEntities(
80 syncable::ModelNeutralWriteTransaction* trans, 81 syncable::ModelNeutralWriteTransaction* trans,
81 const SyncEntityList& applicable_updates, 82 const SyncEntityList& applicable_updates,
82 sessions::StatusController* status); 83 sessions::StatusController* status);
83 84
84 // Stores the given progress marker in the directory. 85 // Stores the given progress marker in the directory.
85 // Its type must match this update handler's type. 86 // Its type must match this update handler's type.
86 void UpdateProgressMarker( 87 void UpdateProgressMarker(
87 const sync_pb::DataTypeProgressMarker& progress_marker); 88 const sync_pb::DataTypeProgressMarker& progress_marker);
88 89
89 // Skips all checks and goes straight to applying the updates. 90 // Skips all checks and goes straight to applying the updates.
90 SyncerError ApplyUpdatesImpl(sessions::StatusController* status); 91 SyncerError ApplyUpdatesImpl(sessions::StatusController* status);
91 92
92 syncable::Directory* dir_; 93 syncable::Directory* dir_;
93 ModelType type_; 94 ModelType type_;
94 scoped_refptr<ModelSafeWorker> worker_; 95 scoped_refptr<ModelSafeWorker> worker_;
95 96
96 DISALLOW_COPY_AND_ASSIGN(SyncDirectoryUpdateHandler); 97 DISALLOW_COPY_AND_ASSIGN(DirectoryUpdateHandler);
97 }; 98 };
98 99
99 } // namespace syncer 100 } // namespace syncer
100 101
101 #endif // SYNC_ENGINE_SYNC_DIRECTORY_UPDATE_HANDLER_H_ 102 #endif // SYNC_ENGINE_DIRECTORY_UPDATE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698