diff options
author | Patrick Scott <phanna@android.com> | 2009-07-14 15:54:30 -0400 |
---|---|---|
committer | Patrick Scott <phanna@android.com> | 2009-07-15 15:48:02 -0400 |
commit | fe4fec7c66b0d956f008ead0fd899b588cfacb5d (patch) | |
tree | 7004bcbad75be87c07cf7378043e70c747f97d07 /core/java/android/net | |
parent | 2debd56b5b24d7f4c385f64bfcaf23d00d4d986a (diff) | |
download | frameworks_base-fe4fec7c66b0d956f008ead0fd899b588cfacb5d.zip frameworks_base-fe4fec7c66b0d956f008ead0fd899b588cfacb5d.tar.gz frameworks_base-fe4fec7c66b0d956f008ead0fd899b588cfacb5d.tar.bz2 |
Remove all our old high priority knowledge since WebCore will manage it.
Also removed an unused variable in RequestQueue.java.
Diffstat (limited to 'core/java/android/net')
-rw-r--r-- | core/java/android/net/http/Request.java | 9 | ||||
-rw-r--r-- | core/java/android/net/http/RequestHandle.java | 2 | ||||
-rw-r--r-- | core/java/android/net/http/RequestQueue.java | 97 |
3 files changed, 31 insertions, 77 deletions
diff --git a/core/java/android/net/http/Request.java b/core/java/android/net/http/Request.java index 3fb3d3f..e160ab6 100644 --- a/core/java/android/net/http/Request.java +++ b/core/java/android/net/http/Request.java @@ -67,9 +67,6 @@ class Request { /** Set if I'm using a proxy server */ HttpHost mProxyHost; - /** True if request is .html, .js, .css */ - boolean mHighPriority; - /** True if request has been cancelled */ volatile boolean mCancelled = false; @@ -102,17 +99,15 @@ class Request { * @param eventHandler request will make progress callbacks on * this interface * @param headers reqeust headers - * @param highPriority true for .html, css, .cs */ Request(String method, HttpHost host, HttpHost proxyHost, String path, InputStream bodyProvider, int bodyLength, EventHandler eventHandler, - Map<String, String> headers, boolean highPriority) { + Map<String, String> headers) { mEventHandler = eventHandler; mHost = host; mProxyHost = proxyHost; mPath = path; - mHighPriority = highPriority; mBodyProvider = bodyProvider; mBodyLength = bodyLength; @@ -356,7 +351,7 @@ class Request { * for debugging */ public String toString() { - return (mHighPriority ? "P*" : "") + mPath; + return mPath; } diff --git a/core/java/android/net/http/RequestHandle.java b/core/java/android/net/http/RequestHandle.java index 6a97951..190ae7a 100644 --- a/core/java/android/net/http/RequestHandle.java +++ b/core/java/android/net/http/RequestHandle.java @@ -419,6 +419,6 @@ public class RequestHandle { mRequest = mRequestQueue.queueRequest( mUrl, mUri, mMethod, mHeaders, mRequest.mEventHandler, mBodyProvider, - mBodyLength, mRequest.mHighPriority).mRequest; + mBodyLength).mRequest; } } diff --git a/core/java/android/net/http/RequestQueue.java b/core/java/android/net/http/RequestQueue.java index 4d3e7c3..b6f295e 100644 --- a/core/java/android/net/http/RequestQueue.java +++ b/core/java/android/net/http/RequestQueue.java @@ -52,47 +52,10 @@ public class RequestQueue implements RequestFeeder { private Context mContext; - private static class RequestSet { - private final LinkedList<Request> mHighPriority; - private final LinkedList<Request> mLowPriority; - - RequestSet() { - mHighPriority = new LinkedList<Request>(); - mLowPriority = new LinkedList<Request>(); - } - - void add(Request req, boolean head) { - LinkedList l = mLowPriority; - if (req.mHighPriority) { - l = mHighPriority; - } - if (head) { - l.addFirst(req); - } else { - l.add(req); - } - } - - Request removeFirst() { - if (!mHighPriority.isEmpty()) { - return mHighPriority.removeFirst(); - } else if (!mLowPriority.isEmpty()) { - return mLowPriority.removeFirst(); - } - return null; - } - - boolean isEmpty() { - return mHighPriority.isEmpty() && mLowPriority.isEmpty(); - } - }; /** * Requests, indexed by HttpHost (scheme, host, port) */ - private LinkedHashMap<HttpHost, RequestSet> mPending; - - /* Support for notifying a client when queue is empty */ - private boolean mClientWaiting = false; + private LinkedHashMap<HttpHost, LinkedList<Request>> mPending; /** true if connected */ boolean mNetworkConnected = true; @@ -382,7 +345,7 @@ public class RequestQueue implements RequestFeeder { public RequestQueue(Context context, int connectionCount) { mContext = context; - mPending = new LinkedHashMap<HttpHost, RequestSet>(32); + mPending = new LinkedHashMap<HttpHost, LinkedList<Request>>(32); mActivePool = new ActivePool(connectionCount); mActivePool.startup(); @@ -472,16 +435,14 @@ public class RequestQueue implements RequestFeeder { * data. Callbacks will be made on the supplied instance. * @param bodyProvider InputStream providing HTTP body, null if none * @param bodyLength length of body, must be 0 if bodyProvider is null - * @param highPriority If true, queues before low priority - * requests if possible */ public RequestHandle queueRequest( String url, String method, Map<String, String> headers, EventHandler eventHandler, - InputStream bodyProvider, int bodyLength, boolean highPriority) { + InputStream bodyProvider, int bodyLength) { WebAddress uri = new WebAddress(url); return queueRequest(url, uri, method, headers, eventHandler, - bodyProvider, bodyLength, highPriority); + bodyProvider, bodyLength); } /** @@ -494,14 +455,11 @@ public class RequestQueue implements RequestFeeder { * data. Callbacks will be made on the supplied instance. * @param bodyProvider InputStream providing HTTP body, null if none * @param bodyLength length of body, must be 0 if bodyProvider is null - * @param highPriority If true, queues before low priority - * requests if possible */ public RequestHandle queueRequest( String url, WebAddress uri, String method, Map<String, String> headers, EventHandler eventHandler, - InputStream bodyProvider, int bodyLength, - boolean highPriority) { + InputStream bodyProvider, int bodyLength) { if (HttpLog.LOGV) HttpLog.v("RequestQueue.queueRequest " + uri); @@ -516,7 +474,7 @@ public class RequestQueue implements RequestFeeder { // set up request req = new Request(method, httpHost, mProxyHost, uri.mPath, bodyProvider, - bodyLength, eventHandler, headers, highPriority); + bodyLength, eventHandler, headers); queueRequest(req, false); @@ -558,24 +516,19 @@ public class RequestQueue implements RequestFeeder { HttpLog.v("dump()"); StringBuilder dump = new StringBuilder(); int count = 0; - Iterator<Map.Entry<HttpHost, RequestSet>> iter; + Iterator<Map.Entry<HttpHost, LinkedList<Request>>> iter; // mActivePool.log(dump); if (!mPending.isEmpty()) { iter = mPending.entrySet().iterator(); while (iter.hasNext()) { - Map.Entry<HttpHost, RequestSet> entry = iter.next(); + Map.Entry<HttpHost, LinkedList<Request>> entry = iter.next(); String hostName = entry.getKey().getHostName(); StringBuilder line = new StringBuilder("p" + count++ + " " + hostName + " "); - RequestSet reqList = entry.getValue(); - ListIterator reqIter = reqList.mHighPriority.listIterator(0); - while (iter.hasNext()) { - Request request = (Request)iter.next(); - line.append(request + " "); - } - reqIter = reqList.mLowPriority.listIterator(0); + LinkedList<Request> reqList = entry.getValue(); + ListIterator reqIter = reqList.listIterator(0); while (iter.hasNext()) { Request request = (Request)iter.next(); line.append(request + " "); @@ -607,9 +560,10 @@ public class RequestQueue implements RequestFeeder { Request ret = null; if (mNetworkConnected && mPending.containsKey(host)) { - RequestSet reqList = mPending.get(host); - ret = reqList.removeFirst(); - if (reqList.isEmpty()) { + LinkedList<Request> reqList = mPending.get(host); + if (!reqList.isEmpty()) { + ret = reqList.removeFirst(); + } else { mPending.remove(host); } } @@ -640,14 +594,18 @@ public class RequestQueue implements RequestFeeder { protected synchronized void queueRequest(Request request, boolean head) { HttpHost host = request.mProxyHost == null ? request.mHost : request.mProxyHost; - RequestSet reqList; + LinkedList<Request> reqList; if (mPending.containsKey(host)) { reqList = mPending.get(host); } else { - reqList = new RequestSet(); + reqList = new LinkedList<Request>(); mPending.put(host, reqList); } - reqList.add(request, head); + if (head) { + reqList.addFirst(request); + } else { + reqList.add(request); + } } @@ -660,14 +618,15 @@ public class RequestQueue implements RequestFeeder { } /* helper */ - private Request removeFirst(LinkedHashMap<HttpHost, RequestSet> requestQueue) { + private Request removeFirst(LinkedHashMap<HttpHost, LinkedList<Request>> requestQueue) { Request ret = null; - Iterator<Map.Entry<HttpHost, RequestSet>> iter = requestQueue.entrySet().iterator(); + Iterator<Map.Entry<HttpHost, LinkedList<Request>>> iter = requestQueue.entrySet().iterator(); if (iter.hasNext()) { - Map.Entry<HttpHost, RequestSet> entry = iter.next(); - RequestSet reqList = entry.getValue(); - ret = reqList.removeFirst(); - if (reqList.isEmpty()) { + Map.Entry<HttpHost, LinkedList<Request>> entry = iter.next(); + LinkedList<Request> reqList = entry.getValue(); + if (!reqList.isEmpty()) { + ret = reqList.removeFirst(); + } else { requestQueue.remove(entry.getKey()); } } |