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/apply_control_data_updates.h" | 5 #include "sync/engine/apply_control_data_updates.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <vector> | 9 #include <vector> |
8 | 10 |
9 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
10 #include "sync/engine/conflict_resolver.h" | 12 #include "sync/engine/conflict_resolver.h" |
11 #include "sync/engine/conflict_util.h" | 13 #include "sync/engine/conflict_util.h" |
12 #include "sync/engine/syncer_util.h" | 14 #include "sync/engine/syncer_util.h" |
13 #include "sync/syncable/directory.h" | 15 #include "sync/syncable/directory.h" |
14 #include "sync/syncable/mutable_entry.h" | 16 #include "sync/syncable/mutable_entry.h" |
15 #include "sync/syncable/nigori_handler.h" | 17 #include "sync/syncable/nigori_handler.h" |
16 #include "sync/syncable/nigori_util.h" | 18 #include "sync/syncable/nigori_util.h" |
17 #include "sync/syncable/syncable_write_transaction.h" | 19 #include "sync/syncable/syncable_write_transaction.h" |
18 #include "sync/util/cryptographer.h" | 20 #include "sync/util/cryptographer.h" |
19 | 21 |
20 namespace syncer { | 22 namespace syncer { |
21 | 23 |
22 void ApplyControlDataUpdates(syncable::Directory* dir) { | 24 void ApplyControlDataUpdates(syncable::Directory* dir) { |
23 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); | 25 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); |
24 | 26 |
25 std::vector<int64> handles; | 27 std::vector<int64_t> handles; |
26 dir->GetUnappliedUpdateMetaHandles( | 28 dir->GetUnappliedUpdateMetaHandles( |
27 &trans, ToFullModelTypeSet(ControlTypes()), &handles); | 29 &trans, ToFullModelTypeSet(ControlTypes()), &handles); |
28 | 30 |
29 // First, go through and manually apply any new top level datatype nodes (so | 31 // First, go through and manually apply any new top level datatype nodes (so |
30 // that we don't have to worry about hitting a CONFLICT_HIERARCHY with an | 32 // that we don't have to worry about hitting a CONFLICT_HIERARCHY with an |
31 // entry because we haven't applied its parent yet). | 33 // entry because we haven't applied its parent yet). |
32 // TODO(sync): if at some point we support control datatypes with actual | 34 // TODO(sync): if at some point we support control datatypes with actual |
33 // hierarchies we'll need to revisit this logic. | 35 // hierarchies we'll need to revisit this logic. |
34 ModelTypeSet control_types = ControlTypes(); | 36 ModelTypeSet control_types = ControlTypes(); |
35 for (ModelTypeSet::Iterator iter = control_types.First(); iter.Good(); | 37 for (ModelTypeSet::Iterator iter = control_types.First(); iter.Good(); |
(...skipping 24 matching lines...) Expand all Loading... |
60 dir->GetCryptographer(&trans)); | 62 dir->GetCryptographer(&trans)); |
61 } else { | 63 } else { |
62 ApplyControlUpdate(&trans, | 64 ApplyControlUpdate(&trans, |
63 &entry, | 65 &entry, |
64 dir->GetCryptographer(&trans)); | 66 dir->GetCryptographer(&trans)); |
65 } | 67 } |
66 } | 68 } |
67 | 69 |
68 // Go through the rest of the unapplied control updates, skipping over any | 70 // Go through the rest of the unapplied control updates, skipping over any |
69 // top level folders. | 71 // top level folders. |
70 for (std::vector<int64>::const_iterator iter = handles.begin(); | 72 for (std::vector<int64_t>::const_iterator iter = handles.begin(); |
71 iter != handles.end(); ++iter) { | 73 iter != handles.end(); ++iter) { |
72 syncable::MutableEntry entry(&trans, syncable::GET_BY_HANDLE, *iter); | 74 syncable::MutableEntry entry(&trans, syncable::GET_BY_HANDLE, *iter); |
73 CHECK(entry.good()); | 75 CHECK(entry.good()); |
74 ModelType type = entry.GetServerModelType(); | 76 ModelType type = entry.GetServerModelType(); |
75 CHECK(ControlTypes().Has(type)); | 77 CHECK(ControlTypes().Has(type)); |
76 if (!entry.GetUniqueServerTag().empty()) { | 78 if (!entry.GetUniqueServerTag().empty()) { |
77 // We should have already applied all top level control nodes. | 79 // We should have already applied all top level control nodes. |
78 DCHECK(!entry.GetIsUnappliedUpdate()); | 80 DCHECK(!entry.GetIsUnappliedUpdate()); |
79 continue; | 81 continue; |
80 } | 82 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 ConflictResolver::OVERWRITE_LOCAL, | 219 ConflictResolver::OVERWRITE_LOCAL, |
218 ConflictResolver::CONFLICT_RESOLUTION_SIZE); | 220 ConflictResolver::CONFLICT_RESOLUTION_SIZE); |
219 } | 221 } |
220 | 222 |
221 UpdateAttemptResponse response = AttemptToUpdateEntry( | 223 UpdateAttemptResponse response = AttemptToUpdateEntry( |
222 trans, entry, cryptographer); | 224 trans, entry, cryptographer); |
223 DCHECK_EQ(SUCCESS, response); | 225 DCHECK_EQ(SUCCESS, response); |
224 } | 226 } |
225 | 227 |
226 } // namespace syncer | 228 } // namespace syncer |
OLD | NEW |