OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // This class does not automatically save its progress into the | 50 // This class does not automatically save its progress into the |
51 // SyncSession -- to get that to happen, call this method after update | 51 // SyncSession -- to get that to happen, call this method after update |
52 // application is finished (i.e., when AttemptOneAllocation stops returning | 52 // application is finished (i.e., when AttemptOneAllocation stops returning |
53 // true). | 53 // true). |
54 void SaveProgressIntoSessionState( | 54 void SaveProgressIntoSessionState( |
55 sessions::ConflictProgress* conflict_progress, | 55 sessions::ConflictProgress* conflict_progress, |
56 sessions::UpdateProgress* update_progress); | 56 sessions::UpdateProgress* update_progress); |
57 | 57 |
58 private: | 58 private: |
59 // Track the status of all applications. | 59 // Track the status of all applications. |
60 // We treat encryption conflicts as nonblocking conflict items when we save | |
61 // progress. | |
62 class ResultTracker { | 60 class ResultTracker { |
63 public: | 61 public: |
64 explicit ResultTracker(size_t num_results); | 62 explicit ResultTracker(size_t num_results); |
65 virtual ~ResultTracker(); | 63 virtual ~ResultTracker(); |
66 void AddConflict(syncable::Id); | 64 void AddSimpleConflict(syncable::Id); |
67 void AddEncryptionConflict(syncable::Id); | 65 void AddEncryptionConflict(syncable::Id); |
| 66 void AddHierarchyConflict(syncable::Id); |
68 void AddSuccess(syncable::Id); | 67 void AddSuccess(syncable::Id); |
69 void SaveProgress(sessions::ConflictProgress* conflict_progress, | 68 void SaveProgress(sessions::ConflictProgress* conflict_progress, |
70 sessions::UpdateProgress* update_progress); | 69 sessions::UpdateProgress* update_progress); |
71 void ClearConflicts(); | 70 void ClearConflicts(); |
72 | 71 |
73 // Returns true iff conflicting_ids_ is empty. Does not check | 72 // Returns true iff conflicting_ids_ is empty. Does not check |
74 // encryption_conflict_ids_. | 73 // encryption_conflict_ids_. |
75 bool no_conflicts() const; | 74 bool no_conflicts() const; |
76 private: | 75 private: |
77 std::vector<syncable::Id> conflicting_ids_; | 76 std::vector<syncable::Id> conflicting_ids_; |
78 std::vector<syncable::Id> successful_ids_; | 77 std::vector<syncable::Id> successful_ids_; |
79 std::vector<syncable::Id> encryption_conflict_ids_; | 78 std::vector<syncable::Id> encryption_conflict_ids_; |
| 79 std::vector<syncable::Id> hierarchy_conflict_ids_; |
80 }; | 80 }; |
81 | 81 |
82 // If true, AttemptOneApplication will skip over |entry| and return true. | 82 // If true, AttemptOneApplication will skip over |entry| and return true. |
83 bool SkipUpdate(const syncable::Entry& entry); | 83 bool SkipUpdate(const syncable::Entry& entry); |
84 | 84 |
85 // Adjusts the UpdateIterator members to move ahead by one update. | 85 // Adjusts the UpdateIterator members to move ahead by one update. |
86 void Advance(); | 86 void Advance(); |
87 | 87 |
88 // Used to resolve conflicts when trying to apply updates. | 88 // Used to resolve conflicts when trying to apply updates. |
89 ConflictResolver* const resolver_; | 89 ConflictResolver* const resolver_; |
(...skipping 11 matching lines...) Expand all Loading... |
101 | 101 |
102 // Track the result of the attempts to update applications. | 102 // Track the result of the attempts to update applications. |
103 ResultTracker application_results_; | 103 ResultTracker application_results_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(UpdateApplicator); | 105 DISALLOW_COPY_AND_ASSIGN(UpdateApplicator); |
106 }; | 106 }; |
107 | 107 |
108 } // namespace browser_sync | 108 } // namespace browser_sync |
109 | 109 |
110 #endif // CHROME_BROWSER_SYNC_ENGINE_UPDATE_APPLICATOR_H_ | 110 #endif // CHROME_BROWSER_SYNC_ENGINE_UPDATE_APPLICATOR_H_ |
OLD | NEW |