mobile/android/base/util/EventCallback.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/util/EventCallback.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +package org.mozilla.gecko.util;
     1.5 +
     1.6 +/**
     1.7 + * Callback interface for Gecko requests.
     1.8 + *
     1.9 + * For each instance of EventCallback, exactly one of sendResponse, sendError, or sendCancel
    1.10 + * must be called to prevent observer leaks. If more than one send* method is called, or if a
    1.11 + * single send method is called multiple times, an {@link IllegalStateException} will be thrown.
    1.12 + */
    1.13 +public interface EventCallback {
    1.14 +    /**
    1.15 +     * Sends a success response with the given data.
    1.16 +     *
    1.17 +     * @param response The response data to send to Gecko. Can be any of the types accepted by
    1.18 +     *                 JSONObject#put(String, Object).
    1.19 +     */
    1.20 +    public void sendSuccess(Object response);
    1.21 +
    1.22 +    /**
    1.23 +     * Sends an error response with the given data.
    1.24 +     *
    1.25 +     * @param response The response data to send to Gecko. Can be any of the types accepted by
    1.26 +     *                 JSONObject#put(String, Object).
    1.27 +     */
    1.28 +    public void sendError(Object response);
    1.29 +
    1.30 +    /**
    1.31 +     * Cancels the request, preventing any Gecko-side callbacks from being executed.
    1.32 +     */
    1.33 +    public void sendCancel();
    1.34 +}

mercurial