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

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

Issue 10933075: FYI: Remove PerModelSafeGroupState + move ConflictResolution (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « sync/engine/all_status.cc ('k') | sync/engine/apply_updates_command_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_updates_command.h" 5 #include "sync/engine/apply_updates_command.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "sync/engine/conflict_resolver.cc"
8 #include "sync/engine/update_applicator.h" 9 #include "sync/engine/update_applicator.h"
9 #include "sync/sessions/sync_session.h" 10 #include "sync/sessions/sync_session.h"
10 #include "sync/syncable/directory.h" 11 #include "sync/syncable/directory.h"
11 #include "sync/syncable/read_transaction.h" 12 #include "sync/syncable/read_transaction.h"
12 #include "sync/syncable/write_transaction.h" 13 #include "sync/syncable/write_transaction.h"
13 14
14 namespace syncer { 15 namespace syncer {
15 16
16 using sessions::SyncSession; 17 using sessions::SyncSession;
17 18
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 59 }
59 60
60 // Don't process control type updates here. They will be handled elsewhere. 61 // Don't process control type updates here. They will be handled elsewhere.
61 FullModelTypeSet control_types = ToFullModelTypeSet(ControlTypes()); 62 FullModelTypeSet control_types = ToFullModelTypeSet(ControlTypes());
62 server_type_restriction.RemoveAll(control_types); 63 server_type_restriction.RemoveAll(control_types);
63 64
64 std::vector<int64> handles; 65 std::vector<int64> handles;
65 dir->GetUnappliedUpdateMetaHandles( 66 dir->GetUnappliedUpdateMetaHandles(
66 &trans, server_type_restriction, &handles); 67 &trans, server_type_restriction, &handles);
67 68
69 // First set of update application passes.
70 std::set<syncable::Id> simple_conflict_ids;
68 UpdateApplicator applicator( 71 UpdateApplicator applicator(
69 session->context()->resolver(),
70 dir->GetCryptographer(&trans), 72 dir->GetCryptographer(&trans),
71 handles.begin(), handles.end(), session->routing_info(), 73 session->routing_info(),
72 session->status_controller().group_restriction()); 74 session->status_controller().group_restriction());
73 while (applicator.AttemptOneApplication(&trans)) {} 75 applicator.AttemptApplications(&trans, handles,
74 applicator.SaveProgressIntoSessionState( 76 &simple_conflict_ids /* out param */);
75 session->mutable_status_controller()->mutable_conflict_progress(), 77
76 session->mutable_status_controller()->mutable_update_progress()); 78 // Resolve all simple conflicts.
79 ConflictResolver resolver;
80 resolver.ResolveConflicts(&trans,
81 dir->GetCryptographer(&trans),
82 simple_conflict_ids,
83 session->mutable_status_controller());
84
85 // Conflict resolution may have cleared the way for more applications.
86 // FIXME: this will cause us to double-count encryption and hierarchy
87 // conflicts.
88 handles.clear();
89 simple_conflict_ids.clear();
90 dir->GetUnappliedUpdateMetaHandles(
91 &trans, server_type_restriction, &handles);
92 applicator.AttemptApplications(&trans, handles,
93 &simple_conflict_ids /* out param */);
94
95 // FIXME: This may not be correct. We ought to loop until no simple conflicts
96 // remain.
97 DCHECK(simple_conflict_ids.empty());
98
99 applicator.SaveStats(session->mutable_status_controller());
77 100
78 // This might be the first time we've fully completed a sync cycle, for 101 // This might be the first time we've fully completed a sync cycle, for
79 // some subset of the currently synced datatypes. 102 // some subset of the currently synced datatypes.
80 const sessions::StatusController& status(session->status_controller()); 103 const sessions::StatusController& status(session->status_controller());
81 if (status.ServerSaysNothingMoreToDownload()) { 104 if (status.ServerSaysNothingMoreToDownload()) {
82 for (ModelTypeSet::Iterator it = 105 for (ModelTypeSet::Iterator it =
83 status.updates_request_types().First(); it.Good(); it.Inc()) { 106 status.updates_request_types().First(); it.Good(); it.Inc()) {
84 // Don't set the flag for control types. We didn't process them here. 107 // Don't set the flag for control types. We didn't process them here.
85 if (IsControlType(it.Get())) 108 if (IsControlType(it.Get()))
86 continue; 109 continue;
87 110
88 // This gets persisted to the directory's backing store. 111 // This gets persisted to the directory's backing store.
89 dir->set_initial_sync_ended_for_type(it.Get(), true); 112 dir->set_initial_sync_ended_for_type(it.Get(), true);
90 } 113 }
91 } 114 }
92 115
93 return SYNCER_OK; 116 return SYNCER_OK;
94 } 117 }
95 118
96 } // namespace syncer 119 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/all_status.cc ('k') | sync/engine/apply_updates_command_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698