summaryrefslogtreecommitdiffstats
path: root/sync/sessions/sync_session.h
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-28 13:05:42 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-28 13:05:42 +0000
commit70abaf0adbf88fb80d78f7088a1195a506690399 (patch)
tree798874040d19bb23fa6ff7a99c7eb82cf3c86797 /sync/sessions/sync_session.h
parentbc390f12b3be83a0698fae361e7c47dbf4270661 (diff)
downloadchromium_src-70abaf0adbf88fb80d78f7088a1195a506690399.zip
chromium_src-70abaf0adbf88fb80d78f7088a1195a506690399.tar.gz
chromium_src-70abaf0adbf88fb80d78f7088a1195a506690399.tar.bz2
sync: make scheduling logic and job ownership more obvious.
- inlines (and removes) SaveJob, to perform only the relevant "saving" bits where needed. As it turns out, most of it was only necessary for ShouldRunJob (which I'd like to rename, as it's destructive), and it's a lot easier to read what's happening and why. Note also removed TODO at SaveJob callsites. - inlines (and removes) InitOrCoalescePendingJob to perform only the relevant bits at each callsite. - pulls SyncSessionJob into a class, to handle basic responsibilities that need the job Purpose + session (like "Succeeded()" and "Finish") that were previously strewn about and partially copy/pasted in the scheduler. - meticulously transfers ownership (removes linked_ptr usage!) of jobs instead of making many implicit struct copies, as it resulted in non-obvious behavior. To do this, ownership is given to the scheduling mechanism (the MessageLoop for ScheduleSyncSessionJob, WaitInterval::timer for canary jobs), instead of jobs sitting around without knowing whether they're scheduled or not. There are a few cases where we can't actually "schedule" a job -- which wasn't even obvious from the old code, and other interesting revelations, like fact that we were actually pre-empt nudge canary jobs and "unscheduling" them in certain cases. - removes DoPendingJobIfPossible, since it is no longer needed for DoCanaryJob/Unthrottle cases, and make the behavior more explicit in the other cases (mode-switch and SCM error change), see TakePendingJobForCurrentMode. - removes the ability to create jobs as canary, since this wasn't needed and was adding complexity (see DoCanaryJob / GrantCanaryPrivilege). - removes retry_scheduled as it wasn't used anywhere - adds lots of comments. Also discovered that THROTTLED intervals seem to never fire a canary job with today's code (broken), config jobs are immune to per-data-type throttling, and the had_nudge allowance was defeated by extra IsBackingOff check in ScheduleNudgeImpl (see comment on review). BUG= Review URL: https://chromiumcodereview.appspot.com/10917234 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164565 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/sessions/sync_session.h')
-rw-r--r--sync/sessions/sync_session.h39
1 files changed, 10 insertions, 29 deletions
diff --git a/sync/sessions/sync_session.h b/sync/sessions/sync_session.h
index 93d7f41..4026e88 100644
--- a/sync/sessions/sync_session.h
+++ b/sync/sessions/sync_session.h
@@ -112,25 +112,11 @@ class SyncSession {
// engine again.
bool HasMoreToSync() 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;
+ // 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;
// Collects all state pertaining to how and why |s| originated and unions it
// with corresponding state in |this|, leaving |s| unchanged. Allows |this|
@@ -139,11 +125,13 @@ class SyncSession {
// sessions.
void Coalesce(const SyncSession& session);
- // 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
+ // 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
// to update the sync session when the user has disabled some types from
// syncing.
- void RebaseRoutingInfoWithLatest(const SyncSession& session);
+ void RebaseRoutingInfoWithLatest(
+ const ModelSafeRoutingInfo& routing_info,
+ const std::vector<ModelSafeWorker*>& workers);
// Should be called any time |this| is being re-used in a new call to
// SyncShare (e.g., HasMoreToSync returned true).
@@ -177,9 +165,6 @@ 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
@@ -217,10 +202,6 @@ 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);
};