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

Unified Diff: sync/engine/sync_scheduler.h

Issue 10483015: [Sync] Refactor sync configuration logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 6 months 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: sync/engine/sync_scheduler.h
diff --git a/sync/engine/sync_scheduler.h b/sync/engine/sync_scheduler.h
index 20194a1b079f5d526f9fafa50b644f97571a702c..2e9afa3bd01e64de70503029a7d58987a559f4c6 100644
--- a/sync/engine/sync_scheduler.h
+++ b/sync/engine/sync_scheduler.h
@@ -37,6 +37,28 @@ namespace browser_sync {
struct ServerConnectionEvent;
+struct ConfigureParams {
+ ConfigureParams();
+ ConfigureParams(
+ const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& source,
+ const syncable::ModelTypeSet& types_to_config,
+ const browser_sync::ModelSafeRoutingInfo& routing_info,
+ bool need_encryption_key,
+ const base::Closure& ready_task);
+ ~ConfigureParams();
+
+ // Source for the configuration.
+ sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source;
+ // The types that should be downloaded.
+ syncable::ModelTypeSet types_to_config;
+ // The new routing info (superset of types to be downloaded).
+ ModelSafeRoutingInfo routing_info;
+ // Whether we need to perform a GetKey command.
+ bool need_encryption_key;
+ // Callback to invoke on configuration completion.
+ base::Closure ready_task;
+};
+
class SyncScheduler : public sessions::SyncSession::Delegate {
public:
enum Mode {
@@ -63,10 +85,15 @@ class SyncScheduler : public sessions::SyncSession::Delegate {
// Start the scheduler with the given mode. If the scheduler is
// already started, switch to the given mode, although some
- // scheduled tasks from the old mode may still run. If non-NULL,
- // |callback| will be invoked when the mode has been changed to
- // |mode|. Takes ownership of |callback|.
- void Start(Mode mode, const base::Closure& callback);
+ // scheduled tasks from the old mode may still run.
+ void Start(Mode mode);
+
+ // Performs the configuration tasks specified by |params|. Returns true if
+ // the configuration task completes, false if a retry had to be scheduled
+ // for later completion. |params.ready_task| is invoked whenever the
+ // configuration task completes.
+ // Note: must already be in CONFIGURATION mode.
+ bool Configure(const ConfigureParams& params);
// Request that any running syncer task stop as soon as possible and
// cancel all scheduled tasks. This function can be called from any thread,
@@ -85,12 +112,6 @@ class SyncScheduler : public sessions::SyncSession::Delegate {
const syncable::ModelTypePayloadMap& types_with_payloads,
const tracked_objects::Location& nudge_location);
- // Note: The source argument of this function must come from the subset of
- // GetUpdatesCallerInfo values related to configurations.
- void Configure(
- syncable::ModelTypeSet types,
- sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source);
-
void ClearUserData();
void CleanupDisabledTypes();
@@ -160,6 +181,7 @@ class SyncScheduler : public sessions::SyncSession::Delegate {
SyncSessionJob();
SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start,
linked_ptr<sessions::SyncSession> session, bool is_canary_job,
+ ConfigureParams config_params,
const tracked_objects::Location& nudge_location);
~SyncSessionJob();
static const char* GetPurposeString(SyncSessionJobPurpose purpose);
@@ -168,6 +190,7 @@ class SyncScheduler : public sessions::SyncSession::Delegate {
base::TimeTicks scheduled_start;
linked_ptr<sessions::SyncSession> session;
bool is_canary_job;
+ ConfigureParams config_params;
// This is the location the job came from. Used for debugging.
// In case of multiple nudges getting coalesced this stores the

Powered by Google App Engine
This is Rietveld 408576698