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

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

Issue 10964057: sync: Refactor update application (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modify comments and rebase Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sync/engine/syncer_util.h » ('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/update_applicator.h" 8 #include "sync/engine/update_applicator.h"
9 #include "sync/sessions/sync_session.h" 9 #include "sync/sessions/sync_session.h"
10 #include "sync/syncable/directory.h" 10 #include "sync/syncable/directory.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // Don't process control type updates here. They will be handled elsewhere. 60 // Don't process control type updates here. They will be handled elsewhere.
61 FullModelTypeSet control_types = ToFullModelTypeSet(ControlTypes()); 61 FullModelTypeSet control_types = ToFullModelTypeSet(ControlTypes());
62 server_type_restriction.RemoveAll(control_types); 62 server_type_restriction.RemoveAll(control_types);
63 63
64 std::vector<int64> handles; 64 std::vector<int64> handles;
65 dir->GetUnappliedUpdateMetaHandles( 65 dir->GetUnappliedUpdateMetaHandles(
66 &trans, server_type_restriction, &handles); 66 &trans, server_type_restriction, &handles);
67 67
68 UpdateApplicator applicator( 68 UpdateApplicator applicator(
69 session->context()->resolver(),
70 dir->GetCryptographer(&trans), 69 dir->GetCryptographer(&trans),
71 handles.begin(), handles.end(), session->routing_info(), 70 session->routing_info(),
72 session->status_controller().group_restriction()); 71 session->status_controller().group_restriction());
73 while (applicator.AttemptOneApplication(&trans)) {} 72 applicator.AttemptApplications(&trans, handles);
74 applicator.SaveProgressIntoSessionState( 73 applicator.SaveProgressIntoSessionState(
75 session->mutable_status_controller()->mutable_conflict_progress(), 74 session->mutable_status_controller()->mutable_conflict_progress(),
76 session->mutable_status_controller()->mutable_update_progress()); 75 session->mutable_status_controller()->mutable_update_progress());
77 76
78 // This might be the first time we've fully completed a sync cycle, for 77 // This might be the first time we've fully completed a sync cycle, for
79 // some subset of the currently synced datatypes. 78 // some subset of the currently synced datatypes.
80 const sessions::StatusController& status(session->status_controller()); 79 const sessions::StatusController& status(session->status_controller());
81 if (status.ServerSaysNothingMoreToDownload()) { 80 if (status.ServerSaysNothingMoreToDownload()) {
82 for (ModelTypeSet::Iterator it = 81 for (ModelTypeSet::Iterator it =
83 status.updates_request_types().First(); it.Good(); it.Inc()) { 82 status.updates_request_types().First(); it.Good(); it.Inc()) {
84 // Don't set the flag for control types. We didn't process them here. 83 // Don't set the flag for control types. We didn't process them here.
85 if (IsControlType(it.Get())) 84 if (IsControlType(it.Get()))
86 continue; 85 continue;
87 86
88 // This gets persisted to the directory's backing store. 87 // This gets persisted to the directory's backing store.
89 dir->set_initial_sync_ended_for_type(it.Get(), true); 88 dir->set_initial_sync_ended_for_type(it.Get(), true);
90 } 89 }
91 } 90 }
92 91
93 return SYNCER_OK; 92 return SYNCER_OK;
94 } 93 }
95 94
96 } // namespace syncer 95 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | sync/engine/syncer_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698