Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: sync/engine/apply_control_data_updates.cc

Issue 302173004: sync: Specialize functions that fetch type root (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/GET_BY_SERVER_TAG_DEPRECATED/GET_BY_SERVER_TAG/ Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "sync/engine/conflict_resolver.h" 8 #include "sync/engine/conflict_resolver.h"
9 #include "sync/engine/conflict_util.h" 9 #include "sync/engine/conflict_util.h"
10 #include "sync/engine/syncer_util.h" 10 #include "sync/engine/syncer_util.h"
11 #include "sync/syncable/directory.h" 11 #include "sync/syncable/directory.h"
12 #include "sync/syncable/mutable_entry.h" 12 #include "sync/syncable/mutable_entry.h"
13 #include "sync/syncable/nigori_handler.h" 13 #include "sync/syncable/nigori_handler.h"
14 #include "sync/syncable/nigori_util.h" 14 #include "sync/syncable/nigori_util.h"
15 #include "sync/syncable/syncable_write_transaction.h" 15 #include "sync/syncable/syncable_write_transaction.h"
16 #include "sync/util/cryptographer.h" 16 #include "sync/util/cryptographer.h"
17 17
18 namespace syncer { 18 namespace syncer {
19 19
20 using syncable::GET_BY_SERVER_TAG; 20 using syncable::GET_TYPE_ROOT;
21 using syncable::IS_UNAPPLIED_UPDATE; 21 using syncable::IS_UNAPPLIED_UPDATE;
22 using syncable::IS_UNSYNCED; 22 using syncable::IS_UNSYNCED;
23 using syncable::SERVER_SPECIFICS; 23 using syncable::SERVER_SPECIFICS;
24 using syncable::SPECIFICS; 24 using syncable::SPECIFICS;
25 using syncable::SYNCER; 25 using syncable::SYNCER;
26 26
27 void ApplyControlDataUpdates(syncable::Directory* dir) { 27 void ApplyControlDataUpdates(syncable::Directory* dir) {
28 syncable::WriteTransaction trans(FROM_HERE, SYNCER, dir); 28 syncable::WriteTransaction trans(FROM_HERE, SYNCER, dir);
29 29
30 std::vector<int64> handles; 30 std::vector<int64> handles;
31 dir->GetUnappliedUpdateMetaHandles( 31 dir->GetUnappliedUpdateMetaHandles(
32 &trans, ToFullModelTypeSet(ControlTypes()), &handles); 32 &trans, ToFullModelTypeSet(ControlTypes()), &handles);
33 33
34 // First, go through and manually apply any new top level datatype nodes (so 34 // First, go through and manually apply any new top level datatype nodes (so
35 // that we don't have to worry about hitting a CONFLICT_HIERARCHY with an 35 // that we don't have to worry about hitting a CONFLICT_HIERARCHY with an
36 // entry because we haven't applied its parent yet). 36 // entry because we haven't applied its parent yet).
37 // TODO(sync): if at some point we support control datatypes with actual 37 // TODO(sync): if at some point we support control datatypes with actual
38 // hierarchies we'll need to revisit this logic. 38 // hierarchies we'll need to revisit this logic.
39 ModelTypeSet control_types = ControlTypes(); 39 ModelTypeSet control_types = ControlTypes();
40 for (ModelTypeSet::Iterator iter = control_types.First(); iter.Good(); 40 for (ModelTypeSet::Iterator iter = control_types.First(); iter.Good();
41 iter.Inc()) { 41 iter.Inc()) {
42 syncable::MutableEntry entry(&trans, 42 syncable::MutableEntry entry(&trans, syncable::GET_TYPE_ROOT, iter.Get());
43 syncable::GET_BY_SERVER_TAG,
44 ModelTypeToRootTag(iter.Get()));
45 if (!entry.good()) 43 if (!entry.good())
46 continue; 44 continue;
47 if (!entry.GetIsUnappliedUpdate()) 45 if (!entry.GetIsUnappliedUpdate())
48 continue; 46 continue;
49 47
50 ModelType type = entry.GetServerModelType(); 48 ModelType type = entry.GetServerModelType();
51 if (type == NIGORI) { 49 if (type == NIGORI) {
52 // Nigori node applications never fail. 50 // Nigori node applications never fail.
53 ApplyNigoriUpdate(&trans, 51 ApplyNigoriUpdate(&trans,
54 &entry, 52 &entry,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ConflictResolver::OVERWRITE_LOCAL, 210 ConflictResolver::OVERWRITE_LOCAL,
213 ConflictResolver::CONFLICT_RESOLUTION_SIZE); 211 ConflictResolver::CONFLICT_RESOLUTION_SIZE);
214 } 212 }
215 213
216 UpdateAttemptResponse response = AttemptToUpdateEntry( 214 UpdateAttemptResponse response = AttemptToUpdateEntry(
217 trans, entry, cryptographer); 215 trans, entry, cryptographer);
218 DCHECK_EQ(SUCCESS, response); 216 DCHECK_EQ(SUCCESS, response);
219 } 217 }
220 218
221 } // namespace syncer 219 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync_driver/generic_change_processor_unittest.cc ('k') | sync/engine/apply_control_data_updates_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698