| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 5 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
| 6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
| 17 #include "base/memory/scoped_ptr.h" | |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
| 22 #include "sync/base/sync_export.h" | 22 #include "sync/base/sync_export.h" |
| 23 #include "sync/engine/net/server_connection_manager.h" | 23 #include "sync/engine/net/server_connection_manager.h" |
| 24 #include "sync/engine/nudge_source.h" | 24 #include "sync/engine/nudge_source.h" |
| 25 #include "sync/engine/sync_scheduler.h" | 25 #include "sync/engine/sync_scheduler.h" |
| 26 #include "sync/engine/syncer.h" | 26 #include "sync/engine/syncer.h" |
| 27 #include "sync/internal_api/public/engine/polling_constants.h" | 27 #include "sync/internal_api/public/engine/polling_constants.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 56 void ScheduleClearServerData(const ClearParams& params) override; | 56 void ScheduleClearServerData(const ClearParams& params) override; |
| 57 void Stop() override; | 57 void Stop() override; |
| 58 void ScheduleLocalNudge( | 58 void ScheduleLocalNudge( |
| 59 ModelTypeSet types, | 59 ModelTypeSet types, |
| 60 const tracked_objects::Location& nudge_location) override; | 60 const tracked_objects::Location& nudge_location) override; |
| 61 void ScheduleLocalRefreshRequest( | 61 void ScheduleLocalRefreshRequest( |
| 62 ModelTypeSet types, | 62 ModelTypeSet types, |
| 63 const tracked_objects::Location& nudge_location) override; | 63 const tracked_objects::Location& nudge_location) override; |
| 64 void ScheduleInvalidationNudge( | 64 void ScheduleInvalidationNudge( |
| 65 syncer::ModelType type, | 65 syncer::ModelType type, |
| 66 scoped_ptr<InvalidationInterface> invalidation, | 66 std::unique_ptr<InvalidationInterface> invalidation, |
| 67 const tracked_objects::Location& nudge_location) override; | 67 const tracked_objects::Location& nudge_location) override; |
| 68 void ScheduleInitialSyncNudge(syncer::ModelType model_type) override; | 68 void ScheduleInitialSyncNudge(syncer::ModelType model_type) override; |
| 69 void SetNotificationsEnabled(bool notifications_enabled) override; | 69 void SetNotificationsEnabled(bool notifications_enabled) override; |
| 70 | 70 |
| 71 void OnCredentialsUpdated() override; | 71 void OnCredentialsUpdated() override; |
| 72 void OnConnectionStatusChange() override; | 72 void OnConnectionStatusChange() override; |
| 73 | 73 |
| 74 // SyncSession::Delegate implementation. | 74 // SyncSession::Delegate implementation. |
| 75 void OnThrottled(const base::TimeDelta& throttle_duration) override; | 75 void OnThrottled(const base::TimeDelta& throttle_duration) override; |
| 76 void OnTypesThrottled(ModelTypeSet types, | 76 void OnTypesThrottled(ModelTypeSet types, |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 // Timer for polling. Restarted on each successful poll, and when entering | 255 // Timer for polling. Restarted on each successful poll, and when entering |
| 256 // normal sync mode or exiting an error state. Not active in configuration | 256 // normal sync mode or exiting an error state. Not active in configuration |
| 257 // mode. | 257 // mode. |
| 258 base::OneShotTimer poll_timer_; | 258 base::OneShotTimer poll_timer_; |
| 259 | 259 |
| 260 // The mode of operation. | 260 // The mode of operation. |
| 261 Mode mode_; | 261 Mode mode_; |
| 262 | 262 |
| 263 // Current wait state. Null if we're not in backoff and not throttled. | 263 // Current wait state. Null if we're not in backoff and not throttled. |
| 264 scoped_ptr<WaitInterval> wait_interval_; | 264 std::unique_ptr<WaitInterval> wait_interval_; |
| 265 | 265 |
| 266 scoped_ptr<BackoffDelayProvider> delay_provider_; | 266 std::unique_ptr<BackoffDelayProvider> delay_provider_; |
| 267 | 267 |
| 268 // The event that will wake us up. | 268 // The event that will wake us up. |
| 269 base::OneShotTimer pending_wakeup_timer_; | 269 base::OneShotTimer pending_wakeup_timer_; |
| 270 | 270 |
| 271 // An event that fires when data type throttling expires. | 271 // An event that fires when data type throttling expires. |
| 272 base::OneShotTimer type_unthrottle_timer_; | 272 base::OneShotTimer type_unthrottle_timer_; |
| 273 | 273 |
| 274 // Storage for variables related to an in-progress configure request. Note | 274 // Storage for variables related to an in-progress configure request. Note |
| 275 // that (mode_ != CONFIGURATION_MODE) \implies !pending_configure_params_. | 275 // that (mode_ != CONFIGURATION_MODE) \implies !pending_configure_params_. |
| 276 scoped_ptr<ConfigurationParams> pending_configure_params_; | 276 std::unique_ptr<ConfigurationParams> pending_configure_params_; |
| 277 | 277 |
| 278 scoped_ptr<ClearParams> pending_clear_params_; | 278 std::unique_ptr<ClearParams> pending_clear_params_; |
| 279 | 279 |
| 280 // If we have a nudge pending to run soon, it will be listed here. | 280 // If we have a nudge pending to run soon, it will be listed here. |
| 281 base::TimeTicks scheduled_nudge_time_; | 281 base::TimeTicks scheduled_nudge_time_; |
| 282 | 282 |
| 283 // Keeps track of work that the syncer needs to handle. | 283 // Keeps track of work that the syncer needs to handle. |
| 284 sessions::NudgeTracker nudge_tracker_; | 284 sessions::NudgeTracker nudge_tracker_; |
| 285 | 285 |
| 286 // Invoked to run through the sync cycle. | 286 // Invoked to run through the sync cycle. |
| 287 scoped_ptr<Syncer> syncer_; | 287 std::unique_ptr<Syncer> syncer_; |
| 288 | 288 |
| 289 sessions::SyncSessionContext* session_context_; | 289 sessions::SyncSessionContext* session_context_; |
| 290 | 290 |
| 291 // A map tracking LOCAL NudgeSource invocations of ScheduleNudge* APIs, | 291 // A map tracking LOCAL NudgeSource invocations of ScheduleNudge* APIs, |
| 292 // organized by datatype. Each datatype that was part of the types requested | 292 // organized by datatype. Each datatype that was part of the types requested |
| 293 // in the call will have its TimeTicks value updated. | 293 // in the call will have its TimeTicks value updated. |
| 294 typedef std::map<ModelType, base::TimeTicks> ModelTypeTimeMap; | 294 typedef std::map<ModelType, base::TimeTicks> ModelTypeTimeMap; |
| 295 ModelTypeTimeMap last_local_nudges_by_model_type_; | 295 ModelTypeTimeMap last_local_nudges_by_model_type_; |
| 296 | 296 |
| 297 // Used as an "anti-reentrancy defensive assertion". | 297 // Used as an "anti-reentrancy defensive assertion". |
| (...skipping 24 matching lines...) Expand all Loading... |
| 322 // A second factory specially for weak_handle_this_, to allow the handle | 322 // A second factory specially for weak_handle_this_, to allow the handle |
| 323 // to be const and alleviate threading concerns. | 323 // to be const and alleviate threading concerns. |
| 324 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 324 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
| 325 | 325 |
| 326 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 326 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
| 327 }; | 327 }; |
| 328 | 328 |
| 329 } // namespace syncer | 329 } // namespace syncer |
| 330 | 330 |
| 331 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 331 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
| OLD | NEW |