Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: sync/sessions/sync_session.h

Issue 11314008: sync: Follow-up to conflict resolution refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/sessions/status_controller_unittest.cc ('k') | sync/sessions/sync_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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
11 // server updates, and access the SyncSessionContext for the current session 11 // server updates, and access the SyncSessionContext for the current session
12 // via SyncSession instances. 12 // via SyncSession instances.
13 13
14 #ifndef SYNC_SESSIONS_SYNC_SESSION_H_ 14 #ifndef SYNC_SESSIONS_SYNC_SESSION_H_
15 #define SYNC_SESSIONS_SYNC_SESSION_H_ 15 #define SYNC_SESSIONS_SYNC_SESSION_H_
16 16
17 #include <map> 17 #include <map>
18 #include <set> 18 #include <set>
19 #include <string> 19 #include <string>
20 #include <utility> 20 #include <utility>
21 #include <vector> 21 #include <vector>
22 22
23 #include "base/basictypes.h" 23 #include "base/basictypes.h"
24 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
25 #include "base/time.h" 25 #include "base/time.h"
26 #include "sync/internal_api/public/base/model_type.h" 26 #include "sync/internal_api/public/base/model_type.h"
27 #include "sync/internal_api/public/engine/model_safe_worker.h" 27 #include "sync/internal_api/public/engine/model_safe_worker.h"
28 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 28 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
29 #include "sync/sessions/ordered_commit_set.h" 29 #include "sync/sessions/ordered_commit_set.h"
30 #include "sync/sessions/session_state.h"
31 #include "sync/sessions/status_controller.h" 30 #include "sync/sessions/status_controller.h"
32 #include "sync/sessions/sync_session_context.h" 31 #include "sync/sessions/sync_session_context.h"
33 #include "sync/util/extensions_activity_monitor.h" 32 #include "sync/util/extensions_activity_monitor.h"
34 33
35 namespace syncer { 34 namespace syncer {
36 class ModelSafeWorker; 35 class ModelSafeWorker;
37 36
38 namespace syncable { 37 namespace syncable {
39 class WriteTransaction; 38 class WriteTransaction;
40 } 39 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 const ModelSafeRoutingInfo& routing_info, 100 const ModelSafeRoutingInfo& routing_info,
102 const std::vector<ModelSafeWorker*>& workers); 101 const std::vector<ModelSafeWorker*>& workers);
103 ~SyncSession(); 102 ~SyncSession();
104 103
105 // Builds a thread-safe and read-only copy of the current session state. 104 // Builds a thread-safe and read-only copy of the current session state.
106 SyncSessionSnapshot TakeSnapshot() const; 105 SyncSessionSnapshot TakeSnapshot() const;
107 106
108 // Builds and sends a snapshot to the session context's listeners. 107 // Builds and sends a snapshot to the session context's listeners.
109 void SendEventNotification(SyncEngineEvent::EventCause cause); 108 void SendEventNotification(SyncEngineEvent::EventCause cause);
110 109
111 // Returns true if this session contains data that should go through the sync
112 // engine again.
113 bool HasMoreToSync() const;
114
115 // Returns true if we reached the server. Note that "reaching the server" 110 // Returns true if we reached the server. Note that "reaching the server"
116 // here means that from an HTTP perspective, we succeeded (HTTP 200). The 111 // here means that from an HTTP perspective, we succeeded (HTTP 200). The
117 // server **MAY** have returned a sync protocol error. 112 // server **MAY** have returned a sync protocol error.
118 // See SERVER_RETURN_* in the SyncerError enum for values. 113 // See SERVER_RETURN_* in the SyncerError enum for values.
119 bool DidReachServer() const; 114 bool DidReachServer() const;
120 115
121 // Collects all state pertaining to how and why |s| originated and unions it 116 // Collects all state pertaining to how and why |s| originated and unions it
122 // with corresponding state in |this|, leaving |s| unchanged. Allows |this| 117 // with corresponding state in |this|, leaving |s| unchanged. Allows |this|
123 // to take on the responsibilities |s| had (e.g. certain data types) in the 118 // to take on the responsibilities |s| had (e.g. certain data types) in the
124 // next SyncShare operation using |this|, rather than needed two separate 119 // next SyncShare operation using |this|, rather than needed two separate
125 // sessions. 120 // sessions.
126 void Coalesce(const SyncSession& session); 121 void Coalesce(const SyncSession& session);
127 122
128 // Compares the routing_info_, workers and payload map with those passed in. 123 // Compares the routing_info_, workers and payload map with those passed in.
129 // Purges types from the above 3 which are not present in latest. Useful 124 // Purges types from the above 3 which are not present in latest. Useful
130 // to update the sync session when the user has disabled some types from 125 // to update the sync session when the user has disabled some types from
131 // syncing. 126 // syncing.
132 void RebaseRoutingInfoWithLatest( 127 void RebaseRoutingInfoWithLatest(
133 const ModelSafeRoutingInfo& routing_info, 128 const ModelSafeRoutingInfo& routing_info,
134 const std::vector<ModelSafeWorker*>& workers); 129 const std::vector<ModelSafeWorker*>& workers);
135 130
136 // Should be called any time |this| is being re-used in a new call to
137 // SyncShare (e.g., HasMoreToSync returned true).
138 void PrepareForAnotherSyncCycle();
139
140 // TODO(akalin): Split this into context() and mutable_context(). 131 // TODO(akalin): Split this into context() and mutable_context().
141 SyncSessionContext* context() const { return context_; } 132 SyncSessionContext* context() const { return context_; }
142 Delegate* delegate() const { return delegate_; } 133 Delegate* delegate() const { return delegate_; }
143 syncable::WriteTransaction* write_transaction() { return write_transaction_; } 134 syncable::WriteTransaction* write_transaction() { return write_transaction_; }
144 const StatusController& status_controller() const { 135 const StatusController& status_controller() const {
145 return *status_controller_.get(); 136 return *status_controller_.get();
146 } 137 }
147 StatusController* mutable_status_controller() { 138 StatusController* mutable_status_controller() {
148 return status_controller_.get(); 139 return status_controller_.get();
149 } 140 }
150 141
151 const ExtensionsActivityMonitor::Records& extensions_activity() const { 142 const ExtensionsActivityMonitor::Records& extensions_activity() const {
152 return extensions_activity_; 143 return extensions_activity_;
153 } 144 }
154 ExtensionsActivityMonitor::Records* mutable_extensions_activity() { 145 ExtensionsActivityMonitor::Records* mutable_extensions_activity() {
155 return &extensions_activity_; 146 return &extensions_activity_;
156 } 147 }
157 148
158 const std::vector<ModelSafeWorker*>& workers() const { return workers_; } 149 const std::vector<ModelSafeWorker*>& workers() const { return workers_; }
159 const ModelSafeRoutingInfo& routing_info() const { return routing_info_; } 150 const ModelSafeRoutingInfo& routing_info() const { return routing_info_; }
160 const SyncSourceInfo& source() const { return source_; } 151 const SyncSourceInfo& source() const { return source_; }
161 152
162 // Returns the set of groups which have enabled types. 153 // Returns the set of groups which have enabled types.
163 const std::set<ModelSafeGroup>& GetEnabledGroups() const; 154 const std::set<ModelSafeGroup>& GetEnabledGroups() const;
164 155
165 // Returns the set of enabled groups that have conflicts.
166 std::set<ModelSafeGroup> GetEnabledGroupsWithConflicts() const;
167
168 private: 156 private:
169 // Extend the encapsulation boundary to utilities for internal member 157 // Extend the encapsulation boundary to utilities for internal member
170 // assignments. This way, the scope of these actions is explicit, they can't 158 // assignments. This way, the scope of these actions is explicit, they can't
171 // be overridden, and assigning is always accompanied by unassigning. 159 // be overridden, and assigning is always accompanied by unassigning.
172 friend class ScopedSetSessionWriteTransaction; 160 friend class ScopedSetSessionWriteTransaction;
173 161
174 // The context for this session, guaranteed to outlive |this|. 162 // The context for this session, guaranteed to outlive |this|.
175 SyncSessionContext* const context_; 163 SyncSessionContext* const context_;
176 164
177 // The source for initiating this sync session. 165 // The source for initiating this sync session.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 208
221 private: 209 private:
222 SyncSession* session_; 210 SyncSession* session_;
223 DISALLOW_COPY_AND_ASSIGN(ScopedSetSessionWriteTransaction); 211 DISALLOW_COPY_AND_ASSIGN(ScopedSetSessionWriteTransaction);
224 }; 212 };
225 213
226 } // namespace sessions 214 } // namespace sessions
227 } // namespace syncer 215 } // namespace syncer
228 216
229 #endif // SYNC_SESSIONS_SYNC_SESSION_H_ 217 #endif // SYNC_SESSIONS_SYNC_SESSION_H_
OLDNEW
« no previous file with comments | « sync/sessions/status_controller_unittest.cc ('k') | sync/sessions/sync_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698