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