OLD | NEW |
---|---|
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 std::set<ModelSafeGroup> ApplyUpdatesCommand::GetGroupsToChange( | |
21 const sessions::SyncSession& session) const { | |
22 std::set<ModelSafeGroup> groups_with_unapplied_updates; | |
23 syncable::ScopedDirLookup dir(session.context()->directory_manager(), | |
24 session.context()->account_name()); | |
25 if (!dir.good()) { | |
26 LOG(ERROR) << "Scoped dir lookup failed!"; | |
27 return groups_with_unapplied_updates; | |
28 } | |
29 | |
30 syncable::ReadTransaction trans(FROM_HERE, dir); | |
31 syncable::Directory::UnappliedUpdateMetaHandles handles; | |
32 dir->GetUnappliedUpdateMetaHandles(&trans, &handles); | |
33 for (syncable::Directory::UnappliedUpdateMetaHandles::const_iterator it = | |
tim (not reviewing)
2011/11/29 00:01:59
Might it make sense to keep an index on this in Di
akalin
2011/11/30 01:33:03
Done. Not quite trivial, but doable. I basically
| |
34 handles.begin(); it != handles.end(); ++it) { | |
35 const syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, *it); | |
36 groups_with_unapplied_updates.insert( | |
37 GetGroupForModelType(entry.GetServerModelType(), | |
38 session.routing_info())); | |
39 } | |
40 | |
41 return groups_with_unapplied_updates; | |
42 } | |
43 | |
20 void ApplyUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) { | 44 void ApplyUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) { |
21 syncable::ScopedDirLookup dir(session->context()->directory_manager(), | 45 syncable::ScopedDirLookup dir(session->context()->directory_manager(), |
22 session->context()->account_name()); | 46 session->context()->account_name()); |
23 if (!dir.good()) { | 47 if (!dir.good()) { |
24 LOG(ERROR) << "Scoped dir lookup failed!"; | 48 LOG(ERROR) << "Scoped dir lookup failed!"; |
25 return; | 49 return; |
26 } | 50 } |
27 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); | 51 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); |
28 syncable::Directory::UnappliedUpdateMetaHandles handles; | 52 syncable::Directory::UnappliedUpdateMetaHandles handles; |
29 dir->GetUnappliedUpdateMetaHandles(&trans, &handles); | 53 dir->GetUnappliedUpdateMetaHandles(&trans, &handles); |
(...skipping 24 matching lines...) Expand all Loading... | |
54 syncable::ModelType model_type = syncable::ModelTypeFromInt(i); | 78 syncable::ModelType model_type = syncable::ModelTypeFromInt(i); |
55 if (status.updates_request_types()[i]) { | 79 if (status.updates_request_types()[i]) { |
56 // This gets persisted to the directory's backing store. | 80 // This gets persisted to the directory's backing store. |
57 dir->set_initial_sync_ended_for_type(model_type, true); | 81 dir->set_initial_sync_ended_for_type(model_type, true); |
58 } | 82 } |
59 } | 83 } |
60 } | 84 } |
61 } | 85 } |
62 | 86 |
63 } // namespace browser_sync | 87 } // namespace browser_sync |
OLD | NEW |