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

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

Issue 9950137: [not for review] sync: Don't use group_restriction from ApplyUpdatesCommand. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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/model_safe_worker.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/syncable.h" 10 #include "sync/syncable/syncable.h"
11 11
12 namespace browser_sync { 12 namespace browser_sync {
13 13
14 using sessions::SyncSession; 14 using sessions::SyncSession;
15 15
16 ApplyUpdatesCommand::ApplyUpdatesCommand() {} 16 ApplyUpdatesCommand::ApplyUpdatesCommand() {}
17 ApplyUpdatesCommand::~ApplyUpdatesCommand() {} 17 ApplyUpdatesCommand::~ApplyUpdatesCommand() {}
18 18
19 std::set<ModelSafeGroup> ApplyUpdatesCommand::GetGroupsToChange( 19 std::set<ModelSafeGroup> ApplyUpdatesCommand::GetGroupsToChange(
20 const sessions::SyncSession& session) const { 20 const sessions::SyncSession& session) const {
21 std::set<ModelSafeGroup> groups_with_unapplied_updates; 21 return session.status_controller().GetModelSafeGroupsWithUnappliedUpdates();
22
23 syncable::FullModelTypeSet server_types_with_unapplied_updates;
24 {
25 syncable::Directory* dir = session.context()->directory();
26 syncable::ReadTransaction trans(FROM_HERE, dir);
27 server_types_with_unapplied_updates =
28 dir->GetServerTypesWithUnappliedUpdates(&trans);
29 }
30
31 for (syncable::FullModelTypeSet::Iterator it =
32 server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) {
33 groups_with_unapplied_updates.insert(
34 GetGroupForModelType(it.Get(), session.routing_info()));
35 }
36
37 return groups_with_unapplied_updates;
38 } 22 }
39 23
40 SyncerError ApplyUpdatesCommand::ModelChangingExecuteImpl( 24 SyncerError ApplyUpdatesCommand::ModelChangingExecuteImpl(
41 SyncSession* session) { 25 SyncSession* session) {
42 syncable::Directory* dir = session->context()->directory(); 26 syncable::Directory* dir = session->context()->directory();
43 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); 27 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir);
44 28 sessions::StatusController* status =
45 // Compute server types with unapplied updates that fall under our 29 session->mutable_status_controller();
46 // group restriction.
47 const syncable::FullModelTypeSet server_types_with_unapplied_updates =
48 dir->GetServerTypesWithUnappliedUpdates(&trans);
49 syncable::FullModelTypeSet server_type_restriction;
50 for (syncable::FullModelTypeSet::Iterator it =
51 server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) {
52 if (GetGroupForModelType(it.Get(), session->routing_info()) ==
53 session->status_controller().group_restriction()) {
54 server_type_restriction.Put(it.Get());
55 }
56 }
57
58 std::vector<int64> handles;
59 dir->GetUnappliedUpdateMetaHandles(
60 &trans, server_type_restriction, &handles);
61 30
62 UpdateApplicator applicator( 31 UpdateApplicator applicator(
63 session->context()->resolver(), 32 session->context()->resolver(),
64 dir->GetCryptographer(&trans), 33 dir->GetCryptographer(&trans),
65 handles.begin(), handles.end(), session->routing_info(), 34 status->mutable_update_progress()->unapplied_updates()->begin(),
66 session->status_controller().group_restriction()); 35 status->mutable_update_progress()->unapplied_updates()->end(),
36 session->routing_info(),
37 status->group_restriction());
67 while (applicator.AttemptOneApplication(&trans)) {} 38 while (applicator.AttemptOneApplication(&trans)) {}
68 applicator.SaveProgressIntoSessionState( 39 applicator.SaveProgressIntoSessionState(
69 session->mutable_status_controller()->mutable_conflict_progress(), 40 status->mutable_conflict_progress(),
70 session->mutable_status_controller()->mutable_update_progress()); 41 status->mutable_update_progress());
71 42
72 // This might be the first time we've fully completed a sync cycle, for 43 // This might be the first time we've fully completed a sync cycle, for
73 // some subset of the currently synced datatypes. 44 // some subset of the currently synced datatypes.
74 const sessions::StatusController& status(session->status_controller()); 45 if (status->ServerSaysNothingMoreToDownload()) {
75 if (status.ServerSaysNothingMoreToDownload()) {
76 for (syncable::ModelTypeSet::Iterator it = 46 for (syncable::ModelTypeSet::Iterator it =
77 status.updates_request_types().First(); it.Good(); it.Inc()) { 47 status->updates_request_types().First(); it.Good(); it.Inc()) {
78 // This gets persisted to the directory's backing store. 48 // This gets persisted to the directory's backing store.
79 dir->set_initial_sync_ended_for_type(it.Get(), true); 49 dir->set_initial_sync_ended_for_type(it.Get(), true);
80 } 50 }
81 } 51 }
82 52
83 return SYNCER_OK; 53 return SYNCER_OK;
84 } 54 }
85 55
86 } // namespace browser_sync 56 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | sync/engine/model_safe_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698