| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 // An UpdateApplicator is used to iterate over a number of unapplied updates, | |
| 6 // applying them to the client using the given syncer session. | |
| 7 // | |
| 8 // UpdateApplicator might resemble an iterator, but it actually keeps retrying | |
| 9 // failed updates until no remaining updates can be successfully applied. | |
| 10 | |
| 11 #ifndef SYNC_ENGINE_UPDATE_APPLICATOR_H_ | |
| 12 #define SYNC_ENGINE_UPDATE_APPLICATOR_H_ | |
| 13 | |
| 14 #include <stdint.h> | |
| 15 | |
| 16 #include <set> | |
| 17 #include <vector> | |
| 18 | |
| 19 #include "base/macros.h" | |
| 20 #include "sync/internal_api/public/engine/model_safe_worker.h" | |
| 21 #include "sync/sessions/status_controller.h" | |
| 22 #include "sync/syncable/syncable_id.h" | |
| 23 | |
| 24 namespace syncer { | |
| 25 | |
| 26 namespace sessions { | |
| 27 class StatusController; | |
| 28 } | |
| 29 | |
| 30 namespace syncable { | |
| 31 class WriteTransaction; | |
| 32 class Entry; | |
| 33 } | |
| 34 | |
| 35 class ConflictResolver; | |
| 36 class Cryptographer; | |
| 37 | |
| 38 class UpdateApplicator { | |
| 39 public: | |
| 40 explicit UpdateApplicator(Cryptographer* cryptographer); | |
| 41 ~UpdateApplicator(); | |
| 42 | |
| 43 // Attempt to apply the specified updates. | |
| 44 void AttemptApplications(syncable::WriteTransaction* trans, | |
| 45 const std::vector<int64_t>& handles); | |
| 46 | |
| 47 int updates_applied() { | |
| 48 return updates_applied_; | |
| 49 } | |
| 50 | |
| 51 int encryption_conflicts() { | |
| 52 return encryption_conflicts_; | |
| 53 } | |
| 54 | |
| 55 int hierarchy_conflicts() { | |
| 56 return hierarchy_conflicts_; | |
| 57 } | |
| 58 | |
| 59 const std::set<syncable::Id>& simple_conflict_ids() { | |
| 60 return simple_conflict_ids_; | |
| 61 } | |
| 62 | |
| 63 private: | |
| 64 // If true, AttemptOneApplication will skip over |entry| and return true. | |
| 65 bool SkipUpdate(const syncable::Entry& entry); | |
| 66 | |
| 67 // Used to decrypt sensitive sync nodes. | |
| 68 Cryptographer* cryptographer_; | |
| 69 | |
| 70 int updates_applied_; | |
| 71 int encryption_conflicts_; | |
| 72 int hierarchy_conflicts_; | |
| 73 std::set<syncable::Id> simple_conflict_ids_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(UpdateApplicator); | |
| 76 }; | |
| 77 | |
| 78 } // namespace syncer | |
| 79 | |
| 80 #endif // SYNC_ENGINE_UPDATE_APPLICATOR_H_ | |
| OLD | NEW |