michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko.fxa.sync; michael@0: michael@0: import org.mozilla.gecko.fxa.login.State.Action; michael@0: import org.mozilla.gecko.sync.BackoffHandler; michael@0: michael@0: public interface SchedulePolicy { michael@0: /** michael@0: * Call this with the number of other clients syncing to the account. michael@0: */ michael@0: public abstract void onSuccessfulSync(int otherClientsCount); michael@0: public abstract void onHandleFinal(Action needed); michael@0: public abstract void onUpgradeRequired(); michael@0: public abstract void onUnauthorized(); michael@0: michael@0: /** michael@0: * Before a sync we typically wish to adjust our backoff policy. This cleans michael@0: * the slate prior to encountering a new backoff, and also functions as a rate michael@0: * limiter. michael@0: * michael@0: * The {@link SchedulePolicy} acts as a controller for the {@link BackoffHandler}. michael@0: * As a result of calling these two methods, the {@link BackoffHandler} will be michael@0: * mutated, and additional side-effects (such as scheduling periodic syncs) can michael@0: * occur. michael@0: * michael@0: * @param rateHandler the backoff handler to configure for basic rate limiting. michael@0: * @param backgroundHandler the backoff handler to configure for background operations. michael@0: */ michael@0: public abstract void configureBackoffMillisBeforeSyncing(BackoffHandler rateHandler, BackoffHandler backgroundHandler); michael@0: michael@0: /** michael@0: * We received an explicit backoff instruction, typically from a server. michael@0: * michael@0: * @param onlyExtend michael@0: * if true, the backoff handler will be asked to update michael@0: * its backoff only if the provided value is greater than the current michael@0: * backoff. michael@0: */ michael@0: public abstract void configureBackoffMillisOnBackoff(BackoffHandler backoffHandler, long backoffMillis, boolean onlyExtend); michael@0: }