Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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_SYNC_DIRECTORY_UPDATE_HANDLER_H_ | |
| 6 #define SYNC_ENGINE_SYNC_DIRECTORY_UPDATE_HANDLER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/gtest_prod_util.h" | |
|
Nicolas Zea
2013/10/25 21:04:41
this isn't needed is it?
rlarocque
2013/10/25 22:29:47
Nope. Removed.
| |
| 12 #include "sync/base/sync_export.h" | |
| 13 #include "sync/engine/process_updates_util.h" | |
| 14 #include "sync/internal_api/public/base/model_type.h" | |
| 15 | |
| 16 namespace sync_pb { | |
| 17 class DataTypeProgressMarker; | |
| 18 class GetUpdatesResponse; | |
| 19 } | |
| 20 | |
| 21 namespace syncer { | |
| 22 | |
| 23 namespace sessions { | |
| 24 class StatusController; | |
| 25 } | |
| 26 | |
| 27 namespace syncable { | |
| 28 class Directory; | |
| 29 } | |
| 30 | |
| 31 // This class represents the syncable::Directory's processes for requesting and | |
| 32 // processing updates from the sync server. | |
| 33 // | |
| 34 // Each instance of this class represents a particular type in the | |
| 35 // syncable::Directory. It can store and retreive that type's progress markers. | |
| 36 // It can also process a set of received SyncEntities and store their data. | |
| 37 class SYNC_EXPORT_PRIVATE SyncDirectoryUpdateHandler { | |
|
Nicolas Zea
2013/10/25 21:04:41
Out of curiosity, is this eventually going to impl
rlarocque
2013/10/25 22:29:47
Mostly yes.
The final interface might need to be
| |
| 38 public: | |
| 39 SyncDirectoryUpdateHandler(syncable::Directory* dir, ModelType type); | |
| 40 ~SyncDirectoryUpdateHandler(); | |
| 41 | |
| 42 // Returns the stored progress marker for this type. | |
| 43 void GetDownloadProgress( | |
|
Nicolas Zea
2013/10/25 21:04:41
Return rather than fill output parameter? Also, pe
rlarocque
2013/10/25 22:29:47
Fixed the comment.
The syncable::Directory's func
| |
| 44 sync_pb::DataTypeProgressMarker* progress_marker) const; | |
| 45 | |
| 46 // Processes the contents of a GetUpdates response message. | |
| 47 // | |
| 48 // Should be invoked with the progress marker and set of SyncEntities from a | |
| 49 // single GetUpdates response message. The progress marker's type must match | |
| 50 // this update processor's type, and the set of SyncEntities must include all | |
|
Nicolas Zea
2013/10/25 21:04:41
s/update processor/update handler/ ?
rlarocque
2013/10/25 22:29:47
Done. (Here and elsewhere.)
| |
| 51 // entities of this type found in the response message. | |
| 52 void ProcessGetUpdatesResponse( | |
| 53 const sync_pb::DataTypeProgressMarker& progress_marker, | |
| 54 const SyncEntityList& applicable_updates, | |
| 55 sessions::StatusController* status); | |
| 56 | |
| 57 private: | |
| 58 friend class SyncDirectoryUpdateHandlerTest; | |
| 59 | |
| 60 // Processes the given SyncEntities and stores their data in the directory. | |
| 61 // Their types must match this update processor's type. | |
| 62 void UpdateSyncEntities( | |
| 63 syncable::ModelNeutralWriteTransaction* trans, | |
| 64 const SyncEntityList& applicable_updates, | |
| 65 sessions::StatusController* status); | |
| 66 | |
| 67 // Stores the given progress marker in the directory. | |
| 68 // Its type must match this update processor's type. | |
| 69 void UpdateProgressMarkers( | |
|
Nicolas Zea
2013/10/25 21:04:41
Given that this only updates a single progress mar
rlarocque
2013/10/25 22:29:47
Done.
| |
| 70 const sync_pb::DataTypeProgressMarker& progress_marker); | |
| 71 | |
| 72 syncable::Directory* dir_; | |
| 73 ModelType type_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(SyncDirectoryUpdateHandler); | |
| 76 }; | |
| 77 | |
| 78 // TODO(rlarocque): Find a better place to define this. | |
| 79 typedef std::map<ModelType, SyncDirectoryUpdateHandler*> UpdateHandlerMap; | |
| 80 | |
| 81 } // namespace syncer | |
| 82 | |
| 83 #endif // SYNC_ENGINE_SYNC_DIRECTORY_UPDATE_HANDLER_H_ | |
| OLD | NEW |