OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 #include "base/timer.h" | 18 #include "base/timer.h" |
19 #include "sync/engine/net/server_connection_manager.h" | 19 #include "sync/engine/net/server_connection_manager.h" |
20 #include "sync/engine/nudge_source.h" | 20 #include "sync/engine/nudge_source.h" |
21 #include "sync/engine/sync_scheduler.h" | 21 #include "sync/engine/sync_scheduler.h" |
22 #include "sync/engine/syncer.h" | 22 #include "sync/engine/syncer.h" |
23 #include "sync/internal_api/public/base/model_type_payload_map.h" | 23 #include "sync/internal_api/public/base/model_type_state_map.h" |
24 #include "sync/internal_api/public/engine/polling_constants.h" | 24 #include "sync/internal_api/public/engine/polling_constants.h" |
25 #include "sync/internal_api/public/util/weak_handle.h" | 25 #include "sync/internal_api/public/util/weak_handle.h" |
26 #include "sync/sessions/sync_session.h" | 26 #include "sync/sessions/sync_session.h" |
27 #include "sync/sessions/sync_session_context.h" | 27 #include "sync/sessions/sync_session_context.h" |
28 | 28 |
29 namespace syncer { | 29 namespace syncer { |
30 | 30 |
31 class SyncSchedulerImpl : public SyncScheduler { | 31 class SyncSchedulerImpl : public SyncScheduler { |
32 public: | 32 public: |
33 // |name| is a display string to identify the syncer thread. Takes | 33 // |name| is a display string to identify the syncer thread. Takes |
34 // |ownership of |syncer|. | 34 // |ownership of |syncer|. |
35 SyncSchedulerImpl(const std::string& name, | 35 SyncSchedulerImpl(const std::string& name, |
36 sessions::SyncSessionContext* context, Syncer* syncer); | 36 sessions::SyncSessionContext* context, Syncer* syncer); |
37 | 37 |
38 // Calls Stop(). | 38 // Calls Stop(). |
39 virtual ~SyncSchedulerImpl(); | 39 virtual ~SyncSchedulerImpl(); |
40 | 40 |
41 virtual void Start(Mode mode) OVERRIDE; | 41 virtual void Start(Mode mode) OVERRIDE; |
42 virtual bool ScheduleConfiguration( | 42 virtual bool ScheduleConfiguration( |
43 const ConfigurationParams& params) OVERRIDE; | 43 const ConfigurationParams& params) OVERRIDE; |
44 virtual void RequestStop(const base::Closure& callback) OVERRIDE; | 44 virtual void RequestStop(const base::Closure& callback) OVERRIDE; |
45 virtual void ScheduleNudgeAsync( | 45 virtual void ScheduleNudgeAsync( |
46 const base::TimeDelta& delay, | 46 const base::TimeDelta& delay, |
47 NudgeSource source, | 47 NudgeSource source, |
48 ModelTypeSet types, | 48 ModelTypeSet types, |
49 const tracked_objects::Location& nudge_location) OVERRIDE; | 49 const tracked_objects::Location& nudge_location) OVERRIDE; |
50 virtual void ScheduleNudgeWithPayloadsAsync( | 50 virtual void ScheduleNudgeWithStatesAsync( |
51 const base::TimeDelta& delay, NudgeSource source, | 51 const base::TimeDelta& delay, NudgeSource source, |
52 const ModelTypePayloadMap& types_with_payloads, | 52 const ModelTypeStateMap& type_state_map, |
53 const tracked_objects::Location& nudge_location) OVERRIDE; | 53 const tracked_objects::Location& nudge_location) OVERRIDE; |
54 virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE; | 54 virtual void SetNotificationsEnabled(bool notifications_enabled) OVERRIDE; |
55 | 55 |
56 virtual base::TimeDelta GetSessionsCommitDelay() const OVERRIDE; | 56 virtual base::TimeDelta GetSessionsCommitDelay() const OVERRIDE; |
57 | 57 |
58 virtual void OnCredentialsUpdated() OVERRIDE; | 58 virtual void OnCredentialsUpdated() OVERRIDE; |
59 virtual void OnConnectionStatusChange() OVERRIDE; | 59 virtual void OnConnectionStatusChange() OVERRIDE; |
60 | 60 |
61 // SyncSession::Delegate implementation. | 61 // SyncSession::Delegate implementation. |
62 virtual void OnSilencedUntil( | 62 virtual void OnSilencedUntil( |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 // Coalesces the current job with the pending nudge. | 246 // Coalesces the current job with the pending nudge. |
247 void InitOrCoalescePendingJob(const SyncSessionJob& job); | 247 void InitOrCoalescePendingJob(const SyncSessionJob& job); |
248 | 248 |
249 // 'Impl' here refers to real implementation of public functions, running on | 249 // 'Impl' here refers to real implementation of public functions, running on |
250 // |thread_|. | 250 // |thread_|. |
251 void StopImpl(const base::Closure& callback); | 251 void StopImpl(const base::Closure& callback); |
252 void ScheduleNudgeImpl( | 252 void ScheduleNudgeImpl( |
253 const base::TimeDelta& delay, | 253 const base::TimeDelta& delay, |
254 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, | 254 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
255 const ModelTypePayloadMap& types_with_payloads, | 255 const ModelTypeStateMap& type_state_map, |
256 bool is_canary_job, const tracked_objects::Location& nudge_location); | 256 bool is_canary_job, const tracked_objects::Location& nudge_location); |
257 | 257 |
258 // Returns true if the client is currently in exponential backoff. | 258 // Returns true if the client is currently in exponential backoff. |
259 bool IsBackingOff() const; | 259 bool IsBackingOff() const; |
260 | 260 |
261 // Helper to signal all listeners registered with |session_context_|. | 261 // Helper to signal all listeners registered with |session_context_|. |
262 void Notify(SyncEngineEvent::EventCause cause); | 262 void Notify(SyncEngineEvent::EventCause cause); |
263 | 263 |
264 // Callback to change backoff state. | 264 // Callback to change backoff state. |
265 void DoCanaryJob(); | 265 void DoCanaryJob(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 scoped_ptr<Syncer> syncer_; | 343 scoped_ptr<Syncer> syncer_; |
344 | 344 |
345 sessions::SyncSessionContext *session_context_; | 345 sessions::SyncSessionContext *session_context_; |
346 | 346 |
347 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 347 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
348 }; | 348 }; |
349 | 349 |
350 } // namespace syncer | 350 } // namespace syncer |
351 | 351 |
352 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 352 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ |
OLD | NEW |