| 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 COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_SYNC_CYCLE_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_SYNC_CYCLE_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_SYNC_CYCLE_H_ | 6 #define COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_SYNC_CYCLE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // Called when server wants to schedule a retry GU. | 81 // Called when server wants to schedule a retry GU. |
| 82 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) = 0; | 82 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) = 0; |
| 83 | 83 |
| 84 // Called when server requests a migration. | 84 // Called when server requests a migration. |
| 85 virtual void OnReceivedMigrationRequest(ModelTypeSet types) = 0; | 85 virtual void OnReceivedMigrationRequest(ModelTypeSet types) = 0; |
| 86 | 86 |
| 87 protected: | 87 protected: |
| 88 virtual ~Delegate() {} | 88 virtual ~Delegate() {} |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // Build a cycle without a nudge tracker. Used for poll or configure type | 91 SyncCycle(SyncCycleContext* context, Delegate* delegate); |
| 92 // sync cycles. | |
| 93 static SyncCycle* Build(SyncCycleContext* context, Delegate* delegate); | |
| 94 ~SyncCycle(); | 92 ~SyncCycle(); |
| 95 | 93 |
| 96 // Builds a thread-safe and read-only copy of the current cycle state. | 94 // Builds a thread-safe and read-only copy of the current cycle state. |
| 97 SyncCycleSnapshot TakeSnapshot() const; | 95 SyncCycleSnapshot TakeSnapshot() const; |
| 98 SyncCycleSnapshot TakeSnapshotWithSource( | 96 SyncCycleSnapshot TakeSnapshotWithSource( |
| 99 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source) | 97 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source) |
| 100 const; | 98 const; |
| 101 | 99 |
| 102 // Builds and sends a snapshot to the cycle context's listeners. | 100 // Builds and sends a snapshot to the cycle context's listeners. |
| 103 void SendSyncCycleEndEventNotification( | 101 void SendSyncCycleEndEventNotification( |
| 104 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 102 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 105 void SendEventNotification(SyncCycleEvent::EventCause cause); | 103 void SendEventNotification(SyncCycleEvent::EventCause cause); |
| 106 | 104 |
| 107 void SendProtocolEvent(const ProtocolEvent& event); | 105 void SendProtocolEvent(const ProtocolEvent& event); |
| 108 | 106 |
| 109 // TODO(akalin): Split this into context() and mutable_context(). | 107 // TODO(akalin): Split this into context() and mutable_context(). |
| 110 SyncCycleContext* context() const { return context_; } | 108 SyncCycleContext* context() const { return context_; } |
| 111 Delegate* delegate() const { return delegate_; } | 109 Delegate* delegate() const { return delegate_; } |
| 112 const StatusController& status_controller() const { | 110 const StatusController& status_controller() const { |
| 113 return *status_controller_.get(); | 111 return *status_controller_.get(); |
| 114 } | 112 } |
| 115 StatusController* mutable_status_controller() { | 113 StatusController* mutable_status_controller() { |
| 116 return status_controller_.get(); | 114 return status_controller_.get(); |
| 117 } | 115 } |
| 118 | 116 |
| 119 private: | 117 private: |
| 120 SyncCycle(SyncCycleContext* context, Delegate* delegate); | |
| 121 | |
| 122 // The context for this cycle, guaranteed to outlive |this|. | 118 // The context for this cycle, guaranteed to outlive |this|. |
| 123 SyncCycleContext* const context_; | 119 SyncCycleContext* const context_; |
| 124 | 120 |
| 125 // The delegate for this cycle, must never be null. | 121 // The delegate for this cycle, must never be null. |
| 126 Delegate* const delegate_; | 122 Delegate* const delegate_; |
| 127 | 123 |
| 128 // Our controller for various status and error counters. | 124 // Our controller for various status and error counters. |
| 129 std::unique_ptr<StatusController> status_controller_; | 125 std::unique_ptr<StatusController> status_controller_; |
| 130 | 126 |
| 131 DISALLOW_COPY_AND_ASSIGN(SyncCycle); | 127 DISALLOW_COPY_AND_ASSIGN(SyncCycle); |
| 132 }; | 128 }; |
| 133 | 129 |
| 134 } // namespace syncer | 130 } // namespace syncer |
| 135 | 131 |
| 136 #endif // COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_SYNC_CYCLE_H_ | 132 #endif // COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_SYNC_CYCLE_H_ |
| OLD | NEW |