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

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

Issue 1393633003: Sync: fix for the code that checks whether the initial download has completed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback Created 5 years, 2 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
« no previous file with comments | « no previous file | sync/engine/apply_control_data_updates_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 14 matching lines...) Expand all
25 &trans, ToFullModelTypeSet(ControlTypes()), &handles); 25 &trans, ToFullModelTypeSet(ControlTypes()), &handles);
26 26
27 // First, go through and manually apply any new top level datatype nodes (so 27 // First, go through and manually apply any new top level datatype nodes (so
28 // that we don't have to worry about hitting a CONFLICT_HIERARCHY with an 28 // that we don't have to worry about hitting a CONFLICT_HIERARCHY with an
29 // entry because we haven't applied its parent yet). 29 // entry because we haven't applied its parent yet).
30 // TODO(sync): if at some point we support control datatypes with actual 30 // TODO(sync): if at some point we support control datatypes with actual
31 // hierarchies we'll need to revisit this logic. 31 // hierarchies we'll need to revisit this logic.
32 ModelTypeSet control_types = ControlTypes(); 32 ModelTypeSet control_types = ControlTypes();
33 for (ModelTypeSet::Iterator iter = control_types.First(); iter.Good(); 33 for (ModelTypeSet::Iterator iter = control_types.First(); iter.Good();
34 iter.Inc()) { 34 iter.Inc()) {
35 syncable::MutableEntry entry(&trans, syncable::GET_TYPE_ROOT, iter.Get()); 35 ModelType type = iter.Get();
36 syncable::MutableEntry entry(&trans, syncable::GET_TYPE_ROOT, type);
36 if (!entry.good()) 37 if (!entry.good())
37 continue; 38 continue;
38 if (!entry.GetIsUnappliedUpdate()) 39
40 if (!entry.GetIsUnappliedUpdate()) {
41 // If this is a type with client generated root, the root node has been
42 // created locally and might never be updated by the server. In that case
43 // it has to be marked as having the initial download completed (which is
44 // done by changing the root's base version to a value other than
45 // CHANGES_VERSION). This does nothing if the root's base version is
46 // already other than CHANGES_VERSION.
47 if (IsTypeWithClientGeneratedRoot(type)) {
48 dir->MarkInitialSyncEndedForType(&trans, type);
49 }
39 continue; 50 continue;
51 }
40 52
41 ModelType type = entry.GetServerModelType(); 53 DCHECK_EQ(type, entry.GetServerModelType());
42 if (type == NIGORI) { 54 if (type == NIGORI) {
43 // Nigori node applications never fail. 55 // Nigori node applications never fail.
44 ApplyNigoriUpdate(&trans, 56 ApplyNigoriUpdate(&trans,
45 &entry, 57 &entry,
46 dir->GetCryptographer(&trans)); 58 dir->GetCryptographer(&trans));
47 } else { 59 } else {
48 ApplyControlUpdate(&trans, 60 ApplyControlUpdate(&trans,
49 &entry, 61 &entry,
50 dir->GetCryptographer(&trans)); 62 dir->GetCryptographer(&trans));
51 } 63 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 ConflictResolver::OVERWRITE_LOCAL, 215 ConflictResolver::OVERWRITE_LOCAL,
204 ConflictResolver::CONFLICT_RESOLUTION_SIZE); 216 ConflictResolver::CONFLICT_RESOLUTION_SIZE);
205 } 217 }
206 218
207 UpdateAttemptResponse response = AttemptToUpdateEntry( 219 UpdateAttemptResponse response = AttemptToUpdateEntry(
208 trans, entry, cryptographer); 220 trans, entry, cryptographer);
209 DCHECK_EQ(SUCCESS, response); 221 DCHECK_EQ(SUCCESS, response);
210 } 222 }
211 223
212 } // namespace syncer 224 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | sync/engine/apply_control_data_updates_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698