diff options
Diffstat (limited to 'sync/sessions/sync_session.h')
-rw-r--r-- | sync/sessions/sync_session.h | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/sync/sessions/sync_session.h b/sync/sessions/sync_session.h index 4026e88..93d7f41 100644 --- a/sync/sessions/sync_session.h +++ b/sync/sessions/sync_session.h @@ -112,11 +112,25 @@ class SyncSession { // engine again. bool HasMoreToSync() const; - // Returns true if we reached the server. Note that "reaching the server" - // here means that from an HTTP perspective, we succeeded (HTTP 200). The - // server **MAY** have returned a sync protocol error. - // See SERVER_RETURN_* in the SyncerError enum for values. - bool DidReachServer() const; + // Returns true if we completely ran the session without errors. + // + // There are many errors that could prevent a sync cycle from succeeding. + // These include invalid local state, inability to contact the server, + // inability to authenticate with the server, and server errors. What they + // have in common is that the we either need to take some action and then + // retry the sync cycle or, in the case of transient errors, retry after some + // backoff timer has expired. Most importantly, the SyncScheduler should not + // assume that the original action that triggered the sync cycle (ie. a nudge + // or a notification) has been properly serviced. + // + // This function also returns false if SyncShare has not been called on this + // session yet, or if ResetTransientState() has been called on this session + // since the last call to SyncShare. + bool Succeeded() const; + + // Returns true if we reached the server successfully and the server did not + // return any error codes. Returns false if no connection was attempted. + bool SuccessfullyReachedServer() const; // Collects all state pertaining to how and why |s| originated and unions it // with corresponding state in |this|, leaving |s| unchanged. Allows |this| @@ -125,13 +139,11 @@ class SyncSession { // sessions. void Coalesce(const SyncSession& session); - // Compares the routing_info_, workers and payload map with those passed in. - // Purges types from the above 3 which are not present in latest. Useful + // Compares the routing_info_, workers and payload map with the passed in + // session. Purges types from the above 3 which are not in session. Useful // to update the sync session when the user has disabled some types from // syncing. - void RebaseRoutingInfoWithLatest( - const ModelSafeRoutingInfo& routing_info, - const std::vector<ModelSafeWorker*>& workers); + void RebaseRoutingInfoWithLatest(const SyncSession& session); // Should be called any time |this| is being re-used in a new call to // SyncShare (e.g., HasMoreToSync returned true). @@ -165,6 +177,9 @@ class SyncSession { // Returns the set of enabled groups that have conflicts. std::set<ModelSafeGroup> GetEnabledGroupsWithConflicts() const; + // Mark the session has having finished all the sync steps it needed. + void SetFinished(); + private: // Extend the encapsulation boundary to utilities for internal member // assignments. This way, the scope of these actions is explicit, they can't @@ -202,6 +217,10 @@ class SyncSession { // |routing_info_|. std::set<ModelSafeGroup> enabled_groups_; + // Whether this session has reached its last step or not. Gets reset on each + // new cycle (via PrepareForAnotherSyncCycle). + bool finished_; + DISALLOW_COPY_AND_ASSIGN(SyncSession); }; |