Build 1.0_r1(from source)

android.net.http
Class RequestQueue

java.lang.Object
  extended by android.net.http.RequestQueue
All Implemented Interfaces:
RequestFeeder

public class RequestQueue
extends Object
implements RequestFeeder


Nested Class Summary
(package private)  class RequestQueue.ActivePool
          This class maintains active connection threads
(package private) static interface RequestQueue.ConnectionManager
          This interface is exposed to each connection
(package private)  class RequestQueue.NetworkStateTracker
           
 
Field Summary
static String HTTP_NETWORK_STATE_CHANGED_INTENT
          This intent broadcast when http is paused or unpaused due to net availability toggling
static String HTTP_NETWORK_STATE_UP
           
(package private)  boolean mNetworkConnected
          true if connected
 
Constructor Summary
RequestQueue(Context context)
          A RequestQueue class instance maintains a set of queued requests.
RequestQueue(Context context, int connectionCount)
          A RequestQueue class instance maintains a set of queued requests.
 
Method Summary
 void disablePlatformNotifications()
          If platform notifications have been enabled, call this method to disable before destroying RequestQueue
(package private)  void dump()
          debug tool: prints request queue to log
 void enablePlatformNotifications()
          Enables data state and proxy tracking
 HttpHost getProxyHost()
          used by webkit
 Request getRequest()
           
 Request getRequest(HttpHost host)
           
 boolean haveRequest(HttpHost host)
           
protected  void queueRequest(Request request, boolean head)
           
 RequestHandle queueRequest(String url, String method, Map<String,String> headers, EventHandler eventHandler, InputStream bodyProvider, int bodyLength, boolean highPriority)
          Queues an HTTP request
 RequestHandle queueRequest(String url, WebAddress uri, String method, Map<String,String> headers, EventHandler eventHandler, InputStream bodyProvider, int bodyLength, boolean highPriority)
          Queues an HTTP request
(package private)  boolean requestsPending()
           
 void requeueRequest(Request request)
          Put request back on head of queue
 void setNetworkState(boolean isNetworkConnected)
          Called by the NetworkStateTracker -- updates when network connectivity is lost/restored.
 void shutdown()
          This must be called to cleanly shutdown RequestQueue
 void startTiming()
           
 void stopTiming()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mNetworkConnected

boolean mNetworkConnected
true if connected


HTTP_NETWORK_STATE_CHANGED_INTENT

public static final String HTTP_NETWORK_STATE_CHANGED_INTENT
This intent broadcast when http is paused or unpaused due to net availability toggling

See Also:
Constant Field Values

HTTP_NETWORK_STATE_UP

public static final String HTTP_NETWORK_STATE_UP
See Also:
Constant Field Values
Constructor Detail

RequestQueue

public RequestQueue(Context context)
A RequestQueue class instance maintains a set of queued requests. It orders them, makes the requests against HTTP servers, and makes callbacks to supplied eventHandlers as data is read. It supports request prioritization, connection reuse and pipelining.

Parameters:
context - application context

RequestQueue

public RequestQueue(Context context,
                    int connectionCount)
A RequestQueue class instance maintains a set of queued requests. It orders them, makes the requests against HTTP servers, and makes callbacks to supplied eventHandlers as data is read. It supports request prioritization, connection reuse and pipelining.

Parameters:
context - application context
connectionCount - The number of simultaneous connections
Method Detail

enablePlatformNotifications

public void enablePlatformNotifications()
Enables data state and proxy tracking


disablePlatformNotifications

public void disablePlatformNotifications()
If platform notifications have been enabled, call this method to disable before destroying RequestQueue


getProxyHost

public HttpHost getProxyHost()
used by webkit

Returns:
proxy host if set, null otherwise

queueRequest

public RequestHandle queueRequest(String url,
                                  String method,
                                  Map<String,String> headers,
                                  EventHandler eventHandler,
                                  InputStream bodyProvider,
                                  int bodyLength,
                                  boolean highPriority)
Queues an HTTP request

Parameters:
url - The url to load.
method - "GET" or "POST."
headers - A hashmap of http headers.
eventHandler - The event handler for handling returned data. Callbacks will be made on the supplied instance.
bodyProvider - InputStream providing HTTP body, null if none
bodyLength - length of body, must be 0 if bodyProvider is null
highPriority - If true, queues before low priority requests if possible

queueRequest

public RequestHandle queueRequest(String url,
                                  WebAddress uri,
                                  String method,
                                  Map<String,String> headers,
                                  EventHandler eventHandler,
                                  InputStream bodyProvider,
                                  int bodyLength,
                                  boolean highPriority)
Queues an HTTP request

Parameters:
url - The url to load.
uri - The uri of the url to load.
method - "GET" or "POST."
headers - A hashmap of http headers.
eventHandler - The event handler for handling returned data. Callbacks will be made on the supplied instance.
bodyProvider - InputStream providing HTTP body, null if none
bodyLength - length of body, must be 0 if bodyProvider is null
highPriority - If true, queues before low priority requests if possible

setNetworkState

public void setNetworkState(boolean isNetworkConnected)
Called by the NetworkStateTracker -- updates when network connectivity is lost/restored. If isNetworkConnected is true, start processing requests


requestsPending

boolean requestsPending()
Returns:
true iff there are any non-active requests pending

dump

void dump()
debug tool: prints request queue to log


getRequest

public Request getRequest()
Specified by:
getRequest in interface RequestFeeder

getRequest

public Request getRequest(HttpHost host)
Specified by:
getRequest in interface RequestFeeder
Returns:
a request for given host if possible

haveRequest

public boolean haveRequest(HttpHost host)
Specified by:
haveRequest in interface RequestFeeder
Returns:
true if a request for this host is available

requeueRequest

public void requeueRequest(Request request)
Put request back on head of queue

Specified by:
requeueRequest in interface RequestFeeder

shutdown

public void shutdown()
This must be called to cleanly shutdown RequestQueue


queueRequest

protected void queueRequest(Request request,
                            boolean head)

startTiming

public void startTiming()

stopTiming

public void stopTiming()

Build 1.0_r1(from source)

Please submit a feedback, bug or feature