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

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

Issue 8919021: [Sync] Rename ModelEnumSet to ModelTypeSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/engine/apply_updates_command.h" 5 #include "chrome/browser/sync/engine/apply_updates_command.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "chrome/browser/sync/engine/update_applicator.h" 8 #include "chrome/browser/sync/engine/update_applicator.h"
9 #include "chrome/browser/sync/sessions/sync_session.h" 9 #include "chrome/browser/sync/sessions/sync_session.h"
10 #include "chrome/browser/sync/syncable/directory_manager.h" 10 #include "chrome/browser/sync/syncable/directory_manager.h"
11 #include "chrome/browser/sync/syncable/syncable.h" 11 #include "chrome/browser/sync/syncable/syncable.h"
12 12
13 namespace browser_sync { 13 namespace browser_sync {
14 14
15 using sessions::SyncSession; 15 using sessions::SyncSession;
16 16
17 ApplyUpdatesCommand::ApplyUpdatesCommand() {} 17 ApplyUpdatesCommand::ApplyUpdatesCommand() {}
18 ApplyUpdatesCommand::~ApplyUpdatesCommand() {} 18 ApplyUpdatesCommand::~ApplyUpdatesCommand() {}
19 19
20 bool ApplyUpdatesCommand::HasCustomGroupsToChange() const { 20 bool ApplyUpdatesCommand::HasCustomGroupsToChange() const {
21 return true; 21 return true;
22 } 22 }
23 23
24 std::set<ModelSafeGroup> ApplyUpdatesCommand::GetGroupsToChange( 24 std::set<ModelSafeGroup> ApplyUpdatesCommand::GetGroupsToChange(
25 const sessions::SyncSession& session) const { 25 const sessions::SyncSession& session) const {
26 std::set<ModelSafeGroup> groups_with_unapplied_updates; 26 std::set<ModelSafeGroup> groups_with_unapplied_updates;
27 27
28 syncable::FullModelEnumSet server_types_with_unapplied_updates; 28 syncable::FullModelTypeSet server_types_with_unapplied_updates;
29 { 29 {
30 syncable::ScopedDirLookup dir(session.context()->directory_manager(), 30 syncable::ScopedDirLookup dir(session.context()->directory_manager(),
31 session.context()->account_name()); 31 session.context()->account_name());
32 if (!dir.good()) { 32 if (!dir.good()) {
33 LOG(ERROR) << "Scoped dir lookup failed!"; 33 LOG(ERROR) << "Scoped dir lookup failed!";
34 return groups_with_unapplied_updates; 34 return groups_with_unapplied_updates;
35 } 35 }
36 36
37 syncable::ReadTransaction trans(FROM_HERE, dir); 37 syncable::ReadTransaction trans(FROM_HERE, dir);
38 server_types_with_unapplied_updates = 38 server_types_with_unapplied_updates =
39 dir->GetServerTypesWithUnappliedUpdates(&trans); 39 dir->GetServerTypesWithUnappliedUpdates(&trans);
40 } 40 }
41 41
42 for (syncable::FullModelEnumSet::Iterator it = 42 for (syncable::FullModelTypeSet::Iterator it =
43 server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) { 43 server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) {
44 groups_with_unapplied_updates.insert( 44 groups_with_unapplied_updates.insert(
45 GetGroupForModelType(it.Get(), session.routing_info())); 45 GetGroupForModelType(it.Get(), session.routing_info()));
46 } 46 }
47 47
48 return groups_with_unapplied_updates; 48 return groups_with_unapplied_updates;
49 } 49 }
50 50
51 void ApplyUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) { 51 void ApplyUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) {
52 syncable::ScopedDirLookup dir(session->context()->directory_manager(), 52 syncable::ScopedDirLookup dir(session->context()->directory_manager(),
53 session->context()->account_name()); 53 session->context()->account_name());
54 if (!dir.good()) { 54 if (!dir.good()) {
55 LOG(ERROR) << "Scoped dir lookup failed!"; 55 LOG(ERROR) << "Scoped dir lookup failed!";
56 return; 56 return;
57 } 57 }
58 58
59 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); 59 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir);
60 60
61 // Compute server types with unapplied updates that fall under our 61 // Compute server types with unapplied updates that fall under our
62 // group restriction. 62 // group restriction.
63 const syncable::FullModelEnumSet server_types_with_unapplied_updates = 63 const syncable::FullModelTypeSet server_types_with_unapplied_updates =
64 dir->GetServerTypesWithUnappliedUpdates(&trans); 64 dir->GetServerTypesWithUnappliedUpdates(&trans);
65 syncable::FullModelEnumSet server_type_restriction; 65 syncable::FullModelTypeSet server_type_restriction;
66 for (syncable::FullModelEnumSet::Iterator it = 66 for (syncable::FullModelTypeSet::Iterator it =
67 server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) { 67 server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) {
68 if (GetGroupForModelType(it.Get(), session->routing_info()) == 68 if (GetGroupForModelType(it.Get(), session->routing_info()) ==
69 session->status_controller().group_restriction()) { 69 session->status_controller().group_restriction()) {
70 server_type_restriction.Put(it.Get()); 70 server_type_restriction.Put(it.Get());
71 } 71 }
72 } 72 }
73 73
74 syncable::Directory::UnappliedUpdateMetaHandles handles; 74 syncable::Directory::UnappliedUpdateMetaHandles handles;
75 dir->GetUnappliedUpdateMetaHandles( 75 dir->GetUnappliedUpdateMetaHandles(
76 &trans, server_type_restriction, &handles); 76 &trans, server_type_restriction, &handles);
77 77
78 UpdateApplicator applicator( 78 UpdateApplicator applicator(
79 session->context()->resolver(), 79 session->context()->resolver(),
80 session->context()->directory_manager()->GetCryptographer(&trans), 80 session->context()->directory_manager()->GetCryptographer(&trans),
81 handles.begin(), handles.end(), session->routing_info(), 81 handles.begin(), handles.end(), session->routing_info(),
82 session->status_controller().group_restriction()); 82 session->status_controller().group_restriction());
83 while (applicator.AttemptOneApplication(&trans)) {} 83 while (applicator.AttemptOneApplication(&trans)) {}
84 applicator.SaveProgressIntoSessionState( 84 applicator.SaveProgressIntoSessionState(
85 session->mutable_status_controller()->mutable_conflict_progress(), 85 session->mutable_status_controller()->mutable_conflict_progress(),
86 session->mutable_status_controller()->mutable_update_progress()); 86 session->mutable_status_controller()->mutable_update_progress());
87 87
88 // This might be the first time we've fully completed a sync cycle, for 88 // This might be the first time we've fully completed a sync cycle, for
89 // some subset of the currently synced datatypes. 89 // some subset of the currently synced datatypes.
90 const sessions::StatusController& status(session->status_controller()); 90 const sessions::StatusController& status(session->status_controller());
91 if (status.ServerSaysNothingMoreToDownload()) { 91 if (status.ServerSaysNothingMoreToDownload()) {
92 for (syncable::ModelEnumSet::Iterator it = 92 for (syncable::ModelTypeSet::Iterator it =
93 status.updates_request_types().First(); it.Good(); it.Inc()) { 93 status.updates_request_types().First(); it.Good(); it.Inc()) {
94 // This gets persisted to the directory's backing store. 94 // This gets persisted to the directory's backing store.
95 dir->set_initial_sync_ended_for_type(it.Get(), true); 95 dir->set_initial_sync_ended_for_type(it.Get(), true);
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 } // namespace browser_sync 100 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/all_status.cc ('k') | chrome/browser/sync/engine/apply_updates_command_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698