Changes

Jump to: navigation, search

WebAPI/XHRBatch

2,345 bytes added, 04:38, 3 November 2013
Created page with "= XHRBatch API (DRAFT) = == Goal == The goal of this API is to let data uploading/downloading can be performed without the APP staying in the memory during the transmission. ..."
= XHRBatch API (DRAFT) =
== Goal ==
The goal of this API is to let data uploading/downloading can be performed without the APP staying in the memory during the transmission.

== Status ==

== Proposed API ==
interface nsIDOMNavigatorXHRBatch {
Promise<IXHRBatch[]> getBatches(); // return submitted batches of the same origin.
Promise<IXHRBatch[]> getAllBatches(); // return all submitted batches, not strict by the same origin if with the permission
}

[Constructor(DOMString name, DOMString description)]
interface XHRBatch : EventTarget {
readonly attribute DOMString origin;
readonly attribute DOMString name;
readonly attribute DOMString description;

// states
const unsigned short NOTSUBMITTED = 0; // This batch is still not submitted.
const unsigned short WAITING = 1; // This batch is submitted, but not in a transmission.
const unsigned short SENDING = 2; // This batch is in a transmission.
const unsigned short COMPLETED = 3; // All requests in this batch is completed or failed.
const unsigned short DROPPED = 4; // This batch is already removed from the user agent.
readonly attribute unsigned short state;

Promise<XMLHttpRequest> createXMLHttpRequest();
/*
* The batch is ready for a transmission and being known by the user agent.
* This request can be failed for running out resources of the user agent.
* As so, drop the old batches to release the resources. The state is transited
* from NOTSUBMITTED to WAITING.
*/
Promise<boolean> submit();
Promise<boolean> start(); // Start the transmission. The state is transited from WAITING to SENDING.
/*
* Stop the transmission.
* The state is transited from SENDING to WAITING once all requests are stopped.
* If |force| is true, all requests are stopped immediately, or it will wait
* until completed or failed for requests in sending.
*/
Promise<boolean> stop(boolean force);
Promise<boolean> drop(); // remove the batch from the user agent.
}

partial interface XMLHttpRequest {
readonly attribute XHRBatch batch; // The batch this request belonged to.
Promise<boolean> addToBatch(); // Add this request to the batch belonged to.
Promise<boolean> removeFromBatch(); // Remove this request from the batch belonged to.
}
Confirm
398
edits

Navigation menu