OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "sync/engine/update_applicator.h" | 5 #include "sync/engine/update_applicator.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <vector> | 9 #include <vector> |
8 | 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "sync/engine/syncer_util.h" | 12 #include "sync/engine/syncer_util.h" |
11 #include "sync/syncable/entry.h" | 13 #include "sync/syncable/entry.h" |
12 #include "sync/syncable/mutable_entry.h" | 14 #include "sync/syncable/mutable_entry.h" |
13 #include "sync/syncable/syncable_id.h" | 15 #include "sync/syncable/syncable_id.h" |
14 #include "sync/syncable/syncable_write_transaction.h" | 16 #include "sync/syncable/syncable_write_transaction.h" |
15 | 17 |
16 using std::vector; | 18 using std::vector; |
(...skipping 21 matching lines...) Expand all Loading... |
38 // | 40 // |
39 // The update applicator also has to deal with simple conflicts, which occur | 41 // The update applicator also has to deal with simple conflicts, which occur |
40 // when an item is modified on both the server and the local model. We remember | 42 // when an item is modified on both the server and the local model. We remember |
41 // their IDs so they can be passed to the conflict resolver after all the other | 43 // their IDs so they can be passed to the conflict resolver after all the other |
42 // applications are complete. | 44 // applications are complete. |
43 // | 45 // |
44 // Finally, there are encryption conflicts, which can occur when we don't have | 46 // Finally, there are encryption conflicts, which can occur when we don't have |
45 // access to all the Nigori keys. There's nothing we can do about them here. | 47 // access to all the Nigori keys. There's nothing we can do about them here. |
46 void UpdateApplicator::AttemptApplications( | 48 void UpdateApplicator::AttemptApplications( |
47 syncable::WriteTransaction* trans, | 49 syncable::WriteTransaction* trans, |
48 const std::vector<int64>& handles) { | 50 const std::vector<int64_t>& handles) { |
49 std::vector<int64> to_apply = handles; | 51 std::vector<int64_t> to_apply = handles; |
50 | 52 |
51 DVLOG(1) << "UpdateApplicator running over " << to_apply.size() << " items."; | 53 DVLOG(1) << "UpdateApplicator running over " << to_apply.size() << " items."; |
52 while (!to_apply.empty()) { | 54 while (!to_apply.empty()) { |
53 std::vector<int64> to_reapply; | 55 std::vector<int64_t> to_reapply; |
54 | 56 |
55 for (std::vector<int64>::iterator i = to_apply.begin(); | 57 for (std::vector<int64_t>::iterator i = to_apply.begin(); |
56 i != to_apply.end(); ++i) { | 58 i != to_apply.end(); ++i) { |
57 syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, *i); | 59 syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, *i); |
58 UpdateAttemptResponse result = AttemptToUpdateEntry( | 60 UpdateAttemptResponse result = AttemptToUpdateEntry( |
59 trans, &entry, cryptographer_); | 61 trans, &entry, cryptographer_); |
60 | 62 |
61 switch (result) { | 63 switch (result) { |
62 case SUCCESS: | 64 case SUCCESS: |
63 updates_applied_++; | 65 updates_applied_++; |
64 break; | 66 break; |
65 case CONFLICT_SIMPLE: | 67 case CONFLICT_SIMPLE: |
(...skipping 22 matching lines...) Expand all Loading... |
88 | 90 |
89 // We made some progress, so prepare for what might be another iteration. | 91 // We made some progress, so prepare for what might be another iteration. |
90 // If everything went well, to_reapply will be empty and we'll break out on | 92 // If everything went well, to_reapply will be empty and we'll break out on |
91 // the while condition. | 93 // the while condition. |
92 to_apply.swap(to_reapply); | 94 to_apply.swap(to_reapply); |
93 to_reapply.clear(); | 95 to_reapply.clear(); |
94 } | 96 } |
95 } | 97 } |
96 | 98 |
97 } // namespace syncer | 99 } // namespace syncer |
OLD | NEW |