michael@0: package org.mozilla.gecko.util; michael@0: michael@0: /** michael@0: * Callback interface for Gecko requests. michael@0: * michael@0: * For each instance of EventCallback, exactly one of sendResponse, sendError, or sendCancel michael@0: * must be called to prevent observer leaks. If more than one send* method is called, or if a michael@0: * single send method is called multiple times, an {@link IllegalStateException} will be thrown. michael@0: */ michael@0: public interface EventCallback { michael@0: /** michael@0: * Sends a success response with the given data. michael@0: * michael@0: * @param response The response data to send to Gecko. Can be any of the types accepted by michael@0: * JSONObject#put(String, Object). michael@0: */ michael@0: public void sendSuccess(Object response); michael@0: michael@0: /** michael@0: * Sends an error response with the given data. michael@0: * michael@0: * @param response The response data to send to Gecko. Can be any of the types accepted by michael@0: * JSONObject#put(String, Object). michael@0: */ michael@0: public void sendError(Object response); michael@0: michael@0: /** michael@0: * Cancels the request, preventing any Gecko-side callbacks from being executed. michael@0: */ michael@0: public void sendCancel(); michael@0: }