• rlarocque@chromium.org's avatar
    sync: Refactor job ownership in SyncScheduler · 622618f6
    rlarocque@chromium.org authored
    This change separates the tracking of what work needs to be done from
    the decision of when to do it.  Prior to this change, SyncSessionJobs
    were owned either by Closures posted to the sync thread's message loop,
    or held temporarily in unscheduled_nudge_storage_, a member of the
    SyncScheduler.  Following this change, there can be only two jobs in
    existence, and they will be referenced only by the scoped_ptr members of
    SyncScheduler named pending_nudge_job_ and pending_configure_job_.
    
    This change, along with some previous changes to the way we schedule
    tasks, makes it possible to simplify the job "saving" logic.  Jobs with
    purpose == NUDGE are saved by assigning them to pending_nudge_job_ or
    coalescing them with the existing pending_nudge_job_.  Jobs with purpose
    == CONFIGURE are never coalesced, and can be saved in the
    pending_configure_job_ member.  These changes allow us to make
    SyncSessionJob::Clone() obsolete.
    
    The logic in ScheduleNudgeImpl() has been updated to take advantage of
    the fact that the pending job is much easier to find now.  It should now
    be much better at coalescing its sources.  In other words, there will be
    less scenarios where it can drop notification hints.  However, there are
    still some cases in DecideOnJob() that may induce it to drop hints
    unnecessarily.
    
    The scheduling logic has been modified, too.  We've removed support for
    the nudge while in an exponential backoff interval.  This makes it
    possible to track the next wakeup time using a single timer, since the
    wakeup event will be one of:
    - The end of a throttled interval
    - An end-of-backoff-interval retry
    - A scheduled nudge
    and these scenarios are now mutually exclusive.
    
    BUG=175024
    
    Review URL: https://chromiumcodereview.appspot.com/13422003
    
    git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192666 0039d316-1c4b-4281-b951-d872f2087c98
    622618f6
sync_scheduler_unittest.cc 46 KB