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

Unified Diff: chrome/browser/sync/engine/apply_updates_command.cc

Issue 8637006: [Sync] Make syncer commands avoid posting tasks on threads with no work to do (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, add tests Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/engine/apply_updates_command.cc
diff --git a/chrome/browser/sync/engine/apply_updates_command.cc b/chrome/browser/sync/engine/apply_updates_command.cc
index 8b5a6b8db8d28e10eca8fe405b2cb0b2b03df8d0..b7716ff97c511f61adeb5c5680972e9b645c2d52 100644
--- a/chrome/browser/sync/engine/apply_updates_command.cc
+++ b/chrome/browser/sync/engine/apply_updates_command.cc
@@ -17,6 +17,30 @@ using sessions::SyncSession;
ApplyUpdatesCommand::ApplyUpdatesCommand() {}
ApplyUpdatesCommand::~ApplyUpdatesCommand() {}
+std::set<ModelSafeGroup> ApplyUpdatesCommand::GetGroupsToChange(
+ const sessions::SyncSession& session) const {
+ std::set<ModelSafeGroup> groups_with_unapplied_updates;
+ syncable::ScopedDirLookup dir(session.context()->directory_manager(),
+ session.context()->account_name());
+ if (!dir.good()) {
+ LOG(ERROR) << "Scoped dir lookup failed!";
+ return groups_with_unapplied_updates;
+ }
+
+ syncable::ReadTransaction trans(FROM_HERE, dir);
+ syncable::Directory::UnappliedUpdateMetaHandles handles;
+ dir->GetUnappliedUpdateMetaHandles(&trans, &handles);
+ 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
+ handles.begin(); it != handles.end(); ++it) {
+ const syncable::Entry entry(&trans, syncable::GET_BY_HANDLE, *it);
+ groups_with_unapplied_updates.insert(
+ GetGroupForModelType(entry.GetServerModelType(),
+ session.routing_info()));
+ }
+
+ return groups_with_unapplied_updates;
+}
+
void ApplyUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) {
syncable::ScopedDirLookup dir(session->context()->directory_manager(),
session->context()->account_name());

Powered by Google App Engine
This is Rietveld 408576698