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

Unified Diff: chrome/browser/sync/engine/model_changing_syncer_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: Refactor some test code 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/model_changing_syncer_command.cc
diff --git a/chrome/browser/sync/engine/model_changing_syncer_command.cc b/chrome/browser/sync/engine/model_changing_syncer_command.cc
index 213cf2325569974a416c6358b81489be0ee172eb..0a54bca232b16a1e082fdba69f3c4ee4cb7cb854 100644
--- a/chrome/browser/sync/engine/model_changing_syncer_command.cc
+++ b/chrome/browser/sync/engine/model_changing_syncer_command.cc
@@ -6,7 +6,6 @@
#include "base/basictypes.h"
#include "base/callback_old.h"
-#include "chrome/browser/sync/engine/model_safe_worker.h"
#include "chrome/browser/sync/sessions/status_controller.h"
#include "chrome/browser/sync/sessions/sync_session.h"
#include "chrome/browser/sync/util/unrecoverable_error_info.h"
@@ -19,27 +18,13 @@ void ModelChangingSyncerCommand::ExecuteImpl(sessions::SyncSession* session) {
return;
}
- // Project the list of active types (i.e., types in the routing
- // info) to a list of groups.
- //
- // TODO(akalin): Make this overrideable by subclasses (who might be
- // working on a subset of |active_groups|). (See
- // http://crbug.com/97832.)
- std::set<ModelSafeGroup> active_groups;
- const ModelSafeRoutingInfo& routing_info = session->routing_info();
- for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin();
- it != routing_info.end(); ++it) {
- active_groups.insert(it->second);
- }
- // Always work on GROUP_PASSIVE, since that's the group that
- // top-level folders map to.
- active_groups.insert(GROUP_PASSIVE);
-
+ const std::set<ModelSafeGroup>& groups_to_change =
+ GetGroupsToChange(*work_session_);
for (size_t i = 0; i < session->workers().size(); ++i) {
- ModelSafeWorker* worker = session->workers()[i];
+ ModelSafeWorker* worker = work_session_->workers()[i];
ModelSafeGroup group = worker->GetModelSafeGroup();
// Skip workers whose group isn't active.
- if (active_groups.find(group) == active_groups.end()) {
+ if (groups_to_change.count(group) == 0u) {
VLOG(2) << "Skipping worker for group "
<< ModelSafeGroupToString(group);
continue;
@@ -60,6 +45,41 @@ void ModelChangingSyncerCommand::ExecuteImpl(sessions::SyncSession* session) {
}
}
+std::set<ModelSafeGroup> ModelChangingSyncerCommand::GetActiveGroups(
+ const sessions::SyncSession& session) {
+ // Project the list of active types (i.e., types in the routing
+ // info) to a list of active groups.
+ std::set<ModelSafeGroup> active_groups;
+ const ModelSafeRoutingInfo& routing_info = session.routing_info();
+ for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin();
+ it != routing_info.end(); ++it) {
+ active_groups.insert(it->second);
tim (not reviewing) 2011/11/22 18:40:05 First, GetActiveGroups belongs on the SyncSession
akalin 2011/11/23 03:25:18 Done.
+ }
+ // GROUP_PASSIVE is always active, since that's the group that
+ // top-level folders map to.
+ active_groups.insert(GROUP_PASSIVE);
+ return active_groups;
+}
+
+std::set<ModelSafeGroup>
+ ModelChangingSyncerCommand::GetActiveGroupsWithConflicts(
+ const sessions::SyncSession& session) {
+ const std::set<ModelSafeGroup>& active_groups =
+ ModelChangingSyncerCommand::GetActiveGroups(session);
+ std::set<ModelSafeGroup> active_groups_with_conflicts;
+ for (std::set<ModelSafeGroup>::const_iterator it =
+ active_groups.begin(); it != active_groups.end(); ++it) {
+ const sessions::ConflictProgress* conflict_progress =
+ session.status_controller().GetUnrestrictedConflictProgress(*it);
+ if (conflict_progress &&
+ (conflict_progress->ConflictingItemsBegin() !=
+ conflict_progress->ConflictingItemsEnd())) {
+ active_groups_with_conflicts.insert(*it);
+ }
+ }
+ return active_groups_with_conflicts;
+}
+
bool ModelChangingSyncerCommand::ModelNeutralExecuteImpl(
sessions::SyncSession* session) {
return true;

Powered by Google App Engine
This is Rietveld 408576698