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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 bool AllUpdatesApplied() const; | 48 bool AllUpdatesApplied() const; |
49 | 49 |
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 bool failed_update() const; |
| 59 |
58 private: | 60 private: |
59 // Track the status of all applications. | 61 // Track the status of all applications. |
60 // We treat encryption conflicts as nonblocking conflict items when we save | 62 // We treat encryption conflicts as nonblocking conflict items when we save |
61 // progress. | 63 // progress. |
62 class ResultTracker { | 64 class ResultTracker { |
63 public: | 65 public: |
64 explicit ResultTracker(size_t num_results); | 66 explicit ResultTracker(size_t num_results); |
65 virtual ~ResultTracker(); | 67 virtual ~ResultTracker(); |
66 void AddConflict(syncable::Id); | 68 void AddConflict(syncable::Id); |
67 void AddEncryptionConflict(syncable::Id); | 69 void AddEncryptionConflict(syncable::Id); |
68 void AddSuccess(syncable::Id); | 70 void AddSuccess(syncable::Id); |
69 void SaveProgress(sessions::ConflictProgress* conflict_progress, | 71 void SaveProgress(sessions::ConflictProgress* conflict_progress, |
70 sessions::UpdateProgress* update_progress); | 72 sessions::UpdateProgress* update_progress); |
71 void ClearConflicts(); | 73 void ClearConflicts(); |
| 74 void set_failed_update(); |
| 75 bool failed_udpate() const; |
72 | 76 |
73 // Returns true iff conflicting_ids_ is empty. Does not check | 77 // Returns true iff conflicting_ids_ is empty. Does not check |
74 // encryption_conflict_ids_. | 78 // encryption_conflict_ids_. |
75 bool no_conflicts() const; | 79 bool no_conflicts() const; |
76 private: | 80 private: |
77 std::vector<syncable::Id> conflicting_ids_; | 81 std::vector<syncable::Id> conflicting_ids_; |
78 std::vector<syncable::Id> successful_ids_; | 82 std::vector<syncable::Id> successful_ids_; |
79 std::vector<syncable::Id> encryption_conflict_ids_; | 83 std::vector<syncable::Id> encryption_conflict_ids_; |
| 84 bool failed_update_; |
80 }; | 85 }; |
81 | 86 |
82 // If true, AttemptOneApplication will skip over |entry| and return true. | 87 // If true, AttemptOneApplication will skip over |entry| and return true. |
83 bool SkipUpdate(const syncable::Entry& entry); | 88 bool SkipUpdate(const syncable::Entry& entry); |
84 | 89 |
85 // Adjusts the UpdateIterator members to move ahead by one update. | 90 // Adjusts the UpdateIterator members to move ahead by one update. |
86 void Advance(); | 91 void Advance(); |
87 | 92 |
88 // Used to resolve conflicts when trying to apply updates. | 93 // Used to resolve conflicts when trying to apply updates. |
89 ConflictResolver* const resolver_; | 94 ConflictResolver* const resolver_; |
(...skipping 11 matching lines...) Expand all Loading... |
101 | 106 |
102 // Track the result of the attempts to update applications. | 107 // Track the result of the attempts to update applications. |
103 ResultTracker application_results_; | 108 ResultTracker application_results_; |
104 | 109 |
105 DISALLOW_COPY_AND_ASSIGN(UpdateApplicator); | 110 DISALLOW_COPY_AND_ASSIGN(UpdateApplicator); |
106 }; | 111 }; |
107 | 112 |
108 } // namespace browser_sync | 113 } // namespace browser_sync |
109 | 114 |
110 #endif // CHROME_BROWSER_SYNC_ENGINE_UPDATE_APPLICATOR_H_ | 115 #endif // CHROME_BROWSER_SYNC_ENGINE_UPDATE_APPLICATOR_H_ |
OLD | NEW |