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).
Total comments: 1
Total comments: 59
Total comments: 19
Total comments: 16
Total messages: 23