diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-15 06:18:36 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-15 06:18:36 +0000 |
commit | f706df5706936983f97b4898997da87029787da2 (patch) | |
tree | a1315c180059844bf0bc6344452f18544da6c91f /sync/engine/sync_scheduler_impl.h | |
parent | 639ec914f10c955f3b0c0c7dc2b1cdfd6b9f9527 (diff) | |
download | chromium_src-f706df5706936983f97b4898997da87029787da2.zip chromium_src-f706df5706936983f97b4898997da87029787da2.tar.gz chromium_src-f706df5706936983f97b4898997da87029787da2.tar.bz2 |
sync: add InternalComponentsFactory::Switches to simplify passing switches to internal components.
Cleans up backoff retry override code to use InternalComponentsFactory::Switches rather than
global bool hack.
Also puts keystore encryption flag atop new mechanism.
(TBR sky for new chrome_switch).
TBR=sky@chromium.org
BUG=142029, 139839
Review URL: https://chromiumcodereview.appspot.com/10837231
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine/sync_scheduler_impl.h')
-rw-r--r-- | sync/engine/sync_scheduler_impl.h | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/sync/engine/sync_scheduler_impl.h b/sync/engine/sync_scheduler_impl.h index 586ccdc..e5f3acf 100644 --- a/sync/engine/sync_scheduler_impl.h +++ b/sync/engine/sync_scheduler_impl.h @@ -28,12 +28,16 @@ namespace syncer { +class BackoffDelayProvider; + class SyncSchedulerImpl : public SyncScheduler { public: // |name| is a display string to identify the syncer thread. Takes - // |ownership of |syncer|. + // |ownership of |syncer| and |delay_provider|. SyncSchedulerImpl(const std::string& name, - sessions::SyncSessionContext* context, Syncer* syncer); + BackoffDelayProvider* delay_provider, + sessions::SyncSessionContext* context, + Syncer* syncer); // Calls Stop(). virtual ~SyncSchedulerImpl(); @@ -72,16 +76,6 @@ class SyncSchedulerImpl : public SyncScheduler { virtual void OnSyncProtocolError( const sessions::SyncSessionSnapshot& snapshot) OVERRIDE; - // DDOS avoidance function. Calculates how long we should wait before trying - // again after a failed sync attempt, where the last delay was |base_delay|. - // TODO(tim): Look at URLRequestThrottlerEntryInterface. - static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay); - - // For integration tests only. Override initial backoff value. - // TODO(tim): Remove this, use command line flag and plumb through. Done - // this way to reduce diffs in hotfix. - static void ForceShortInitialBackoffRetry(); - private: enum JobProcessDecision { // Indicates we should continue with the current job. @@ -150,17 +144,6 @@ class SyncSchedulerImpl : public SyncScheduler { FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, TransientPollFailure); FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, GetInitialBackoffDelay); - // A component used to get time delays associated with exponential backoff. - // Encapsulated into a class to facilitate testing. - class DelayProvider { - public: - DelayProvider(); - virtual base::TimeDelta GetDelay(const base::TimeDelta& last_delay); - virtual ~DelayProvider(); - private: - DISALLOW_COPY_AND_ASSIGN(DelayProvider); - }; - struct WaitInterval { enum Mode { // Uninitialized state, should not be set in practice. @@ -234,11 +217,6 @@ class SyncSchedulerImpl : public SyncScheduler { // Helper to ScheduleNextSync in case of consecutive sync errors. void HandleContinuationError(const SyncSessionJob& old_job); - // Helper to calculate the initial value for exponential backoff. - // See possible values and comments in polling_constants.h. - base::TimeDelta GetInitialBackoffDelay( - const sessions::ModelNeutralState& state) const; - // Determines if it is legal to run |job| by checking current // operational mode, backoff or throttling, freshness // (so we don't make redundant syncs), and connection. @@ -348,7 +326,7 @@ class SyncSchedulerImpl : public SyncScheduler { // Current wait state. Null if we're not in backoff and not throttled. scoped_ptr<WaitInterval> wait_interval_; - scoped_ptr<DelayProvider> delay_provider_; + scoped_ptr<BackoffDelayProvider> delay_provider_; // Invoked to run through the sync cycle. scoped_ptr<Syncer> syncer_; |