mobile/android/base/fxa/sync/SchedulePolicy.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/fxa/sync/SchedulePolicy.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +package org.mozilla.gecko.fxa.sync;
     1.9 +
    1.10 +import org.mozilla.gecko.fxa.login.State.Action;
    1.11 +import org.mozilla.gecko.sync.BackoffHandler;
    1.12 +
    1.13 +public interface SchedulePolicy {
    1.14 +  /**
    1.15 +   * Call this with the number of other clients syncing to the account.
    1.16 +   */
    1.17 +  public abstract void onSuccessfulSync(int otherClientsCount);
    1.18 +  public abstract void onHandleFinal(Action needed);
    1.19 +  public abstract void onUpgradeRequired();
    1.20 +  public abstract void onUnauthorized();
    1.21 +
    1.22 +  /**
    1.23 +   * Before a sync we typically wish to adjust our backoff policy. This cleans
    1.24 +   * the slate prior to encountering a new backoff, and also functions as a rate
    1.25 +   * limiter.
    1.26 +   *
    1.27 +   * The {@link SchedulePolicy} acts as a controller for the {@link BackoffHandler}.
    1.28 +   * As a result of calling these two methods, the {@link BackoffHandler} will be
    1.29 +   * mutated, and additional side-effects (such as scheduling periodic syncs) can
    1.30 +   * occur.
    1.31 +   *
    1.32 +   * @param rateHandler the backoff handler to configure for basic rate limiting.
    1.33 +   * @param backgroundHandler the backoff handler to configure for background operations.
    1.34 +   */
    1.35 +  public abstract void configureBackoffMillisBeforeSyncing(BackoffHandler rateHandler, BackoffHandler backgroundHandler);
    1.36 +
    1.37 +  /**
    1.38 +   * We received an explicit backoff instruction, typically from a server.
    1.39 +   *
    1.40 +   * @param onlyExtend
    1.41 +   *          if <code>true</code>, the backoff handler will be asked to update
    1.42 +   *          its backoff only if the provided value is greater than the current
    1.43 +   *          backoff.
    1.44 +   */
    1.45 +  public abstract void configureBackoffMillisOnBackoff(BackoffHandler backoffHandler, long backoffMillis, boolean onlyExtend);
    1.46 +}
    1.47 \ No newline at end of file

mercurial