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

Unified Diff: sync/engine/sync_scheduler_impl.h

Issue 10701046: sync: Remove SyncManager::TestingMode in favour of InternalComponentsFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now with more scope Created 8 years, 5 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_impl.h
diff --git a/sync/engine/sync_scheduler.h b/sync/engine/sync_scheduler_impl.h
similarity index 75%
copy from sync/engine/sync_scheduler.h
copy to sync/engine/sync_scheduler_impl.h
index 0ca2f5db5a14be3d236213750e9489eda6a919f6..dfc3bff5a20c6143080565aca2466330a53f5932 100644
--- a/sync/engine/sync_scheduler.h
+++ b/sync/engine/sync_scheduler_impl.h
@@ -1,10 +1,9 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-//
-// A class to schedule syncer tasks intelligently.
-#ifndef SYNC_ENGINE_SYNC_SCHEDULER_H_
-#define SYNC_ENGINE_SYNC_SCHEDULER_H_
+
+#ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_
+#define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_
#include <string>
@@ -19,6 +18,7 @@
#include "base/timer.h"
#include "sync/engine/net/server_connection_manager.h"
#include "sync/engine/nudge_source.h"
+#include "sync/engine/sync_scheduler.h"
#include "sync/engine/syncer.h"
#include "sync/internal_api/public/base/model_type_payload_map.h"
#include "sync/internal_api/public/engine/polling_constants.h"
@@ -26,113 +26,37 @@
#include "sync/sessions/sync_session.h"
#include "sync/sessions/sync_session_context.h"
-class MessageLoop;
-
-namespace tracked_objects {
-class Location;
-} // namespace tracked_objects
-
namespace syncer {
-struct ServerConnectionEvent;
-
-struct ConfigurationParams {
- enum KeystoreKeyStatus {
- KEYSTORE_KEY_UNNECESSARY,
- KEYSTORE_KEY_NEEDED
- };
- ConfigurationParams();
- ConfigurationParams(
- const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& source,
- const syncer::ModelTypeSet& types_to_download,
- const syncer::ModelSafeRoutingInfo& routing_info,
- KeystoreKeyStatus keystore_key_status,
- const base::Closure& ready_task);
- ~ConfigurationParams();
-
- // Source for the configuration.
- sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source;
- // The types that should be downloaded.
- syncer::ModelTypeSet types_to_download;
- // The new routing info (superset of types to be downloaded).
- ModelSafeRoutingInfo routing_info;
- // Whether we need to perform a GetKey command.
- KeystoreKeyStatus keystore_key_status;
- // Callback to invoke on configuration completion.
- base::Closure ready_task;
-};
-
-class SyncScheduler : public sessions::SyncSession::Delegate {
+class SyncSchedulerImpl : public SyncScheduler {
public:
- enum Mode {
- // In this mode, the thread only performs configuration tasks. This is
- // designed to make the case where we want to download updates for a
- // specific type only, and not continue syncing until we are moved into
- // normal mode.
- CONFIGURATION_MODE,
- // Resumes polling and allows nudges, drops configuration tasks. Runs
- // through entire sync cycle.
- NORMAL_MODE,
- };
-
- // All methods of SyncScheduler must be called on the same thread
- // (except for RequestEarlyExit()).
-
// |name| is a display string to identify the syncer thread. Takes
// |ownership of |syncer|.
- SyncScheduler(const std::string& name,
- sessions::SyncSessionContext* context, Syncer* syncer);
+ SyncSchedulerImpl(const std::string& name,
+ sessions::SyncSessionContext* context, Syncer* syncer);
// Calls Stop().
- virtual ~SyncScheduler();
-
- // 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.
- virtual void Start(Mode mode);
-
- // Schedules the configuration task specified by |params|. Returns true if
- // the configuration task executed immediately, false if it had to be
- // scheduled for a later attempt. |params.ready_task| is invoked whenever the
- // configuration task executes.
- // Note: must already be in CONFIGURATION mode.
- virtual bool ScheduleConfiguration(const ConfigurationParams& 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,
- // and should in fact be called from a thread that isn't the sync loop to
- // allow preempting ongoing sync cycles.
- // Invokes |callback| from the sync loop once syncer is idle and all tasks
- // are cancelled.
- void RequestStop(const base::Closure& callback);
-
- // The meat and potatoes. Both of these methods will post a delayed task
- // to attempt the actual nudge (see ScheduleNudgeImpl).
- void ScheduleNudgeAsync(const base::TimeDelta& delay, NudgeSource source,
- syncer::ModelTypeSet types,
- const tracked_objects::Location& nudge_location);
- void ScheduleNudgeWithPayloadsAsync(
+ virtual ~SyncSchedulerImpl();
+
+ virtual void Start(Mode mode) OVERRIDE;
+ virtual bool ScheduleConfiguration(
+ const ConfigurationParams& params) OVERRIDE;
+ virtual void RequestStop(const base::Closure& callback) OVERRIDE;
+ virtual void ScheduleNudgeAsync(
+ const base::TimeDelta& delay,
+ NudgeSource source,
+ syncer::ModelTypeSet types,
+ const tracked_objects::Location& nudge_location) OVERRIDE;
+ virtual void ScheduleNudgeWithPayloadsAsync(
const base::TimeDelta& delay, NudgeSource source,
const syncer::ModelTypePayloadMap& types_with_payloads,
- const tracked_objects::Location& nudge_location);
-
- void CleanupDisabledTypes();
+ const tracked_objects::Location& nudge_location) OVERRIDE;
+ virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE;
- // Change status of notifications in the SyncSessionContext.
- void set_notifications_enabled(bool notifications_enabled);
+ virtual base::TimeDelta GetSessionsCommitDelay() const OVERRIDE;
- base::TimeDelta sessions_commit_delay() const;
-
- // 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);
-
- // Called when credentials are updated by the user.
- void OnCredentialsUpdated();
-
- // Called when the network layer detects a connection status change.
- void OnConnectionStatusChange();
+ virtual void OnCredentialsUpdated() OVERRIDE;
+ virtual void OnConnectionStatusChange() OVERRIDE;
// SyncSession::Delegate implementation.
virtual void OnSilencedUntil(
@@ -148,6 +72,11 @@ class SyncScheduler : public sessions::SyncSession::Delegate {
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);
+
private:
enum JobProcessDecision {
// Indicates we should continue with the current job.
@@ -254,7 +183,7 @@ class SyncScheduler : public sessions::SyncSession::Delegate {
// interval and mode == EXPONENTIAL_BACKOFF.
bool had_nudge;
base::TimeDelta length;
- base::OneShotTimer<SyncScheduler> timer;
+ base::OneShotTimer<SyncSchedulerImpl> timer;
// Configure jobs are saved only when backing off or throttling. So we
// expose the pointer here.
@@ -370,14 +299,14 @@ class SyncScheduler : public sessions::SyncSession::Delegate {
virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot);
- base::WeakPtrFactory<SyncScheduler> weak_ptr_factory_;
+ base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_;
// A second factory specially for weak_handle_this_, to allow the handle
// to be const and alleviate threading concerns.
- base::WeakPtrFactory<SyncScheduler> weak_ptr_factory_for_weak_handle_;
+ base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_;
// For certain methods that need to worry about X-thread posting.
- const WeakHandle<SyncScheduler> weak_handle_this_;
+ const WeakHandle<SyncSchedulerImpl> weak_handle_this_;
// Used for logging.
const std::string name_;
@@ -398,7 +327,7 @@ class SyncScheduler : public sessions::SyncSession::Delegate {
base::TimeDelta sessions_commit_delay_;
// Periodic timer for polling. See AdjustPolling.
- base::RepeatingTimer<SyncScheduler> poll_timer_;
+ base::RepeatingTimer<SyncSchedulerImpl> poll_timer_;
// The mode of operation.
Mode mode_;
@@ -423,9 +352,9 @@ class SyncScheduler : public sessions::SyncSession::Delegate {
sessions::SyncSessionContext *session_context_;
- DISALLOW_COPY_AND_ASSIGN(SyncScheduler);
+ DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl);
};
} // namespace syncer
-#endif // SYNC_ENGINE_SYNC_SCHEDULER_H_
+#endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698