Chromium Code Reviews| 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 // A class representing an attempt to synchronize the local syncable data | 5 // A class representing an attempt to synchronize the local syncable data |
| 6 // store with a sync server. A SyncSession instance is passed as a stateful | 6 // store with a sync server. A SyncSession instance is passed as a stateful |
| 7 // bundle to and from various SyncerCommands with the goal of converging the | 7 // bundle to and from various SyncerCommands with the goal of converging the |
| 8 // client view of data with that of the server. The commands twiddle with | 8 // client view of data with that of the server. The commands twiddle with |
| 9 // session status in response to events and hiccups along the way, set and | 9 // session status in response to events and hiccups along the way, set and |
| 10 // query session progress with regards to conflict resolution and applying | 10 // query session progress with regards to conflict resolution and applying |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 29 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 30 #include "sync/sessions/ordered_commit_set.h" | 30 #include "sync/sessions/ordered_commit_set.h" |
| 31 #include "sync/sessions/status_controller.h" | 31 #include "sync/sessions/status_controller.h" |
| 32 #include "sync/sessions/sync_session_context.h" | 32 #include "sync/sessions/sync_session_context.h" |
| 33 | 33 |
| 34 namespace syncer { | 34 namespace syncer { |
| 35 class ModelSafeWorker; | 35 class ModelSafeWorker; |
| 36 | 36 |
| 37 namespace sessions { | 37 namespace sessions { |
| 38 | 38 |
| 39 class NudgeTracker; | |
| 40 | |
| 39 class SYNC_EXPORT_PRIVATE SyncSession { | 41 class SYNC_EXPORT_PRIVATE SyncSession { |
| 40 public: | 42 public: |
| 41 // The Delegate services events that occur during the session requiring an | 43 // The Delegate services events that occur during the session requiring an |
| 42 // explicit (and session-global) action, as opposed to events that are simply | 44 // explicit (and session-global) action, as opposed to events that are simply |
| 43 // recorded in per-session state. | 45 // recorded in per-session state. |
| 44 class SYNC_EXPORT_PRIVATE Delegate { | 46 class SYNC_EXPORT_PRIVATE Delegate { |
| 45 public: | 47 public: |
| 46 // The client was throttled and should cease-and-desist syncing activity | 48 // The client was throttled and should cease-and-desist syncing activity |
| 47 // until the specified time. | 49 // until the specified time. |
| 48 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) = 0; | 50 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) = 0; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 79 // stops the current sync cycle and purges the client. In the new model | 81 // stops the current sync cycle and purges the client. In the new model |
| 80 // the former would be done by the |SyncProtocolError| and | 82 // the former would be done by the |SyncProtocolError| and |
| 81 // the latter(which is an action) would be done in ProfileSyncService | 83 // the latter(which is an action) would be done in ProfileSyncService |
| 82 // along with the rest of the actions. | 84 // along with the rest of the actions. |
| 83 virtual void OnShouldStopSyncingPermanently() = 0; | 85 virtual void OnShouldStopSyncingPermanently() = 0; |
| 84 | 86 |
| 85 // Called for the syncer to respond to the error sent by the server. | 87 // Called for the syncer to respond to the error sent by the server. |
| 86 virtual void OnSyncProtocolError( | 88 virtual void OnSyncProtocolError( |
| 87 const sessions::SyncSessionSnapshot& snapshot) = 0; | 89 const sessions::SyncSessionSnapshot& snapshot) = 0; |
| 88 | 90 |
| 91 // Called when the server wants to change the number of hints the client | |
| 92 // will buffer locally. | |
| 93 virtual void OnReceivedClientInvalidationHintBufferSize(int size) = 0; | |
|
tim (not reviewing)
2013/05/07 22:40:34
You use int here but size_t in NudgeTracker, was t
rlarocque
2013/05/07 22:56:49
The protobufs provide us with ints, so I've used i
tim (not reviewing)
2013/05/07 23:35:50
Sanity checking that the value was greater than ze
| |
| 94 | |
| 89 protected: | 95 protected: |
| 90 virtual ~Delegate() {} | 96 virtual ~Delegate() {} |
| 91 }; | 97 }; |
| 92 | 98 |
| 93 SyncSession(SyncSessionContext* context, | 99 // Build a session with a nudge tracker. Used for sync cycles with origin of |
| 94 Delegate* delegate, | 100 // GU_TRIGGER (ie. notification, local change, and/or refresh request) |
| 95 const SyncSourceInfo& source); | 101 static SyncSession* BuildForNudge(SyncSessionContext* context, |
| 102 Delegate* delegate, | |
| 103 const SyncSourceInfo& source, | |
| 104 const NudgeTracker* nudge_tracker); | |
| 105 | |
| 106 // Build a session without a nudge tracker. Used for poll or configure type | |
| 107 // sync cycles. | |
| 108 static SyncSession* Build(SyncSessionContext* context, | |
| 109 Delegate* delegate, | |
| 110 const SyncSourceInfo& source); | |
| 111 | |
| 96 ~SyncSession(); | 112 ~SyncSession(); |
| 97 | 113 |
| 98 // Builds a thread-safe and read-only copy of the current session state. | 114 // Builds a thread-safe and read-only copy of the current session state. |
| 99 SyncSessionSnapshot TakeSnapshot() const; | 115 SyncSessionSnapshot TakeSnapshot() const; |
| 100 | 116 |
| 101 // Builds and sends a snapshot to the session context's listeners. | 117 // Builds and sends a snapshot to the session context's listeners. |
| 102 void SendEventNotification(SyncEngineEvent::EventCause cause); | 118 void SendEventNotification(SyncEngineEvent::EventCause cause); |
| 103 | 119 |
| 104 // TODO(akalin): Split this into context() and mutable_context(). | 120 // TODO(akalin): Split this into context() and mutable_context(). |
| 105 SyncSessionContext* context() const { return context_; } | 121 SyncSessionContext* context() const { return context_; } |
| 106 Delegate* delegate() const { return delegate_; } | 122 Delegate* delegate() const { return delegate_; } |
| 107 const StatusController& status_controller() const { | 123 const StatusController& status_controller() const { |
| 108 return *status_controller_.get(); | 124 return *status_controller_.get(); |
| 109 } | 125 } |
| 110 StatusController* mutable_status_controller() { | 126 StatusController* mutable_status_controller() { |
| 111 return status_controller_.get(); | 127 return status_controller_.get(); |
| 112 } | 128 } |
| 113 | 129 |
| 114 const SyncSourceInfo& source() const { return source_; } | 130 const SyncSourceInfo& source() const { return source_; } |
| 115 | 131 |
| 132 const NudgeTracker* nudge_tracker() const { return nudge_tracker_; } | |
| 133 | |
| 116 private: | 134 private: |
| 135 SyncSession(SyncSessionContext* context, | |
| 136 Delegate* delegate, | |
| 137 const SyncSourceInfo& source, | |
| 138 const NudgeTracker* nudge_tracker); | |
| 139 | |
| 117 // The context for this session, guaranteed to outlive |this|. | 140 // The context for this session, guaranteed to outlive |this|. |
| 118 SyncSessionContext* const context_; | 141 SyncSessionContext* const context_; |
| 119 | 142 |
| 120 // The source for initiating this sync session. | 143 // The source for initiating this sync session. |
| 121 SyncSourceInfo source_; | 144 SyncSourceInfo source_; |
| 122 | 145 |
| 123 // The delegate for this session, must never be NULL. | 146 // The delegate for this session, must never be NULL. |
| 124 Delegate* const delegate_; | 147 Delegate* const delegate_; |
| 125 | 148 |
| 126 // Our controller for various status and error counters. | 149 // Our controller for various status and error counters. |
| 127 scoped_ptr<StatusController> status_controller_; | 150 scoped_ptr<StatusController> status_controller_; |
| 128 | 151 |
| 152 const NudgeTracker* nudge_tracker_; | |
| 153 | |
| 129 DISALLOW_COPY_AND_ASSIGN(SyncSession); | 154 DISALLOW_COPY_AND_ASSIGN(SyncSession); |
| 130 }; | 155 }; |
| 131 | 156 |
| 132 } // namespace sessions | 157 } // namespace sessions |
| 133 } // namespace syncer | 158 } // namespace syncer |
| 134 | 159 |
| 135 #endif // SYNC_SESSIONS_SYNC_SESSION_H_ | 160 #endif // SYNC_SESSIONS_SYNC_SESSION_H_ |
| OLD | NEW |