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

Unified Diff: chrome/browser/sync/engine/model_changing_syncer_command.h

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.h
diff --git a/chrome/browser/sync/engine/model_changing_syncer_command.h b/chrome/browser/sync/engine/model_changing_syncer_command.h
index 9a2311e96d907365d7f61a6cd519aa431f962cc3..16c7c4f9afe1c80955846a2dd6e9274222582bf2 100644
--- a/chrome/browser/sync/engine/model_changing_syncer_command.h
+++ b/chrome/browser/sync/engine/model_changing_syncer_command.h
@@ -6,7 +6,10 @@
#define CHROME_BROWSER_SYNC_ENGINE_MODEL_CHANGING_SYNCER_COMMAND_H_
#pragma once
+#include <set>
+
#include "base/compiler_specific.h"
+#include "chrome/browser/sync/engine/model_safe_worker.h"
#include "chrome/browser/sync/engine/syncer_command.h"
#include "chrome/browser/sync/util/unrecoverable_error_info.h"
@@ -41,6 +44,22 @@ class ModelChangingSyncerCommand : public SyncerCommand {
return UnrecoverableErrorInfo();
}
+ std::set<ModelSafeGroup> GetGroupsToChangeForTest(
+ const sessions::SyncSession& session) const {
+ return GetGroupsToChange(session);
+ }
+
+ protected:
+ // This should return the set of groups in |session| that need to be
+ // changed. The returned set should be a subset of
+ // GetActiveGroups(). Subclasses can guarantee this either by
+ // calling GetActiveGroups() or GetActiveGroupsWithConflicts() and
+ // filtering that, or using GetGroupForModelType() (which handles
+ // top-level/unspecified nodes) to project from model types to
+ // groups.
+ virtual std::set<ModelSafeGroup> GetGroupsToChange(
+ const sessions::SyncSession& session) const = 0;
+
// Sometimes, a command has work to do that needs to touch global state
// belonging to multiple ModelSafeGroups, but in a way that is known to be
// safe. This will be called once, prior to ModelChangingExecuteImpl,
@@ -55,6 +74,16 @@ class ModelChangingSyncerCommand : public SyncerCommand {
// running on an unsafe thread are siloed away.
virtual void ModelChangingExecuteImpl(sessions::SyncSession* session) = 0;
+ // Returns the set of groups that have active (i.e., enabled) types.
tim (not reviewing) 2011/11/22 18:40:05 Can we avoid introducing a new adjective if we can
akalin 2011/11/23 03:25:18 Done.
+ // Useful for implementing GetGroupsToChange().
+ static std::set<ModelSafeGroup> GetActiveGroups(
+ const sessions::SyncSession& session);
+
+ // Returns the set of active groups that have conflicts. Useful for
+ // implementing GetGroupsToChange().
+ static std::set<ModelSafeGroup> GetActiveGroupsWithConflicts(
+ const sessions::SyncSession& session);
+
private:
// ExecuteImpl is expected to be run by SyncerCommand to set work_session.
// StartChangingModel is called to start this command running.

Powered by Google App Engine
This is Rietveld 408576698