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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 const sessions::SyncSessionSnapshot& snapshot) = 0; | 94 const sessions::SyncSessionSnapshot& snapshot) = 0; |
95 | 95 |
96 // Called when the server wants to change the number of hints the client | 96 // Called when the server wants to change the number of hints the client |
97 // will buffer locally. | 97 // will buffer locally. |
98 virtual void OnReceivedClientInvalidationHintBufferSize(int size) = 0; | 98 virtual void OnReceivedClientInvalidationHintBufferSize(int size) = 0; |
99 | 99 |
100 protected: | 100 protected: |
101 virtual ~Delegate() {} | 101 virtual ~Delegate() {} |
102 }; | 102 }; |
103 | 103 |
104 // Build a session with a nudge tracker. Used for sync cycles with origin of | |
105 // GU_TRIGGER (ie. notification, local change, and/or refresh request) | |
106 static SyncSession* BuildForNudge(SyncSessionContext* context, | |
107 Delegate* delegate, | |
108 const SyncSourceInfo& source, | |
109 const NudgeTracker* nudge_tracker); | |
110 | |
111 // Build a session without a nudge tracker. Used for poll or configure type | 104 // Build a session without a nudge tracker. Used for poll or configure type |
112 // sync cycles. | 105 // sync cycles. |
113 static SyncSession* Build(SyncSessionContext* context, | 106 static SyncSession* Build(SyncSessionContext* context, |
114 Delegate* delegate, | 107 Delegate* delegate, |
115 const SyncSourceInfo& source); | 108 const SyncSourceInfo& source); |
116 | |
117 ~SyncSession(); | 109 ~SyncSession(); |
118 | 110 |
119 // Builds a thread-safe and read-only copy of the current session state. | 111 // Builds a thread-safe and read-only copy of the current session state. |
120 SyncSessionSnapshot TakeSnapshot() const; | 112 SyncSessionSnapshot TakeSnapshot() const; |
121 | 113 |
122 // Builds and sends a snapshot to the session context's listeners. | 114 // Builds and sends a snapshot to the session context's listeners. |
123 void SendEventNotification(SyncEngineEvent::EventCause cause); | 115 void SendEventNotification(SyncEngineEvent::EventCause cause); |
124 | 116 |
125 // TODO(akalin): Split this into context() and mutable_context(). | 117 // TODO(akalin): Split this into context() and mutable_context(). |
126 SyncSessionContext* context() const { return context_; } | 118 SyncSessionContext* context() const { return context_; } |
127 Delegate* delegate() const { return delegate_; } | 119 Delegate* delegate() const { return delegate_; } |
128 const StatusController& status_controller() const { | 120 const StatusController& status_controller() const { |
129 return *status_controller_.get(); | 121 return *status_controller_.get(); |
130 } | 122 } |
131 StatusController* mutable_status_controller() { | 123 StatusController* mutable_status_controller() { |
132 return status_controller_.get(); | 124 return status_controller_.get(); |
133 } | 125 } |
134 | 126 |
135 const SyncSourceInfo& source() const { return source_; } | 127 const SyncSourceInfo& source() const { return source_; } |
136 | 128 |
137 const NudgeTracker* nudge_tracker() const { return nudge_tracker_; } | |
138 | |
139 private: | 129 private: |
140 SyncSession(SyncSessionContext* context, | 130 SyncSession(SyncSessionContext* context, |
141 Delegate* delegate, | 131 Delegate* delegate, |
142 const SyncSourceInfo& source, | 132 const SyncSourceInfo& source); |
143 const NudgeTracker* nudge_tracker); | |
144 | 133 |
145 // The context for this session, guaranteed to outlive |this|. | 134 // The context for this session, guaranteed to outlive |this|. |
146 SyncSessionContext* const context_; | 135 SyncSessionContext* const context_; |
147 | 136 |
148 // The source for initiating this sync session. | 137 // The source for initiating this sync session. |
149 SyncSourceInfo source_; | 138 SyncSourceInfo source_; |
150 | 139 |
151 // The delegate for this session, must never be NULL. | 140 // The delegate for this session, must never be NULL. |
152 Delegate* const delegate_; | 141 Delegate* const delegate_; |
153 | 142 |
154 // Our controller for various status and error counters. | 143 // Our controller for various status and error counters. |
155 scoped_ptr<StatusController> status_controller_; | 144 scoped_ptr<StatusController> status_controller_; |
156 | 145 |
157 const NudgeTracker* nudge_tracker_; | |
158 | |
159 DISALLOW_COPY_AND_ASSIGN(SyncSession); | 146 DISALLOW_COPY_AND_ASSIGN(SyncSession); |
160 }; | 147 }; |
161 | 148 |
162 } // namespace sessions | 149 } // namespace sessions |
163 } // namespace syncer | 150 } // namespace syncer |
164 | 151 |
165 #endif // SYNC_SESSIONS_SYNC_SESSION_H_ | 152 #endif // SYNC_SESSIONS_SYNC_SESSION_H_ |
OLD | NEW |