Merge change 7381
* changes:
Remove all our old high priority knowledge since WebCore will manage it.
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 @@
/** 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 @@
* @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 @@
* 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 @@
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 @@
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 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 @@
* 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 @@
* 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 @@
// 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 @@
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 @@
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 @@
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 @@
}
/* 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());
}
}
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index e04ae72..5a7a233 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -465,8 +465,6 @@
* @param postData If the method is "POST" postData is sent as the request
* body. Is null when empty.
* @param cacheMode The cache mode to use when loading this resource.
- * @param isHighPriority True if this resource needs to be put at the front
- * of the network queue.
* @param synchronous True if the load is synchronous.
* @return A newly created LoadListener object.
*/
@@ -476,7 +474,6 @@
HashMap headers,
byte[] postData,
int cacheMode,
- boolean isHighPriority,
boolean synchronous) {
PerfChecker checker = new PerfChecker();
@@ -542,8 +539,8 @@
if (DebugFlags.BROWSER_FRAME) {
Log.v(LOGTAG, "startLoadingResource: url=" + url + ", method="
- + method + ", postData=" + postData + ", isHighPriority="
- + isHighPriority + ", isMainFramePage=" + isMainFramePage);
+ + method + ", postData=" + postData + ", isMainFramePage="
+ + isMainFramePage);
}
// Create a LoadListener
@@ -568,8 +565,7 @@
CacheManager.endCacheTransaction();
}
- FrameLoader loader = new FrameLoader(loadListener, mSettings,
- method, isHighPriority);
+ FrameLoader loader = new FrameLoader(loadListener, mSettings, method);
loader.setHeaders(headers);
loader.setPostData(postData);
// Set the load mode to the mode used for the current page.
diff --git a/core/java/android/webkit/FrameLoader.java b/core/java/android/webkit/FrameLoader.java
index f98c5d3..8298729 100644
--- a/core/java/android/webkit/FrameLoader.java
+++ b/core/java/android/webkit/FrameLoader.java
@@ -28,7 +28,6 @@
private final LoadListener mListener;
private final String mMethod;
- private final boolean mIsHighPriority;
private final WebSettings mSettings;
private Map<String, String> mHeaders;
private byte[] mPostData;
@@ -52,11 +51,10 @@
private static final String LOGTAG = "webkit";
FrameLoader(LoadListener listener, WebSettings settings,
- String method, boolean highPriority) {
+ String method) {
mListener = listener;
mHeaders = null;
mMethod = method;
- mIsHighPriority = highPriority;
mCacheMode = WebSettings.LOAD_NORMAL;
mSettings = settings;
}
@@ -175,8 +173,7 @@
// as response from the cache could be a redirect
// and we may need to initiate a network request if the cache
// can't satisfy redirect URL
- mListener.setRequestData(mMethod, mHeaders, mPostData,
- mIsHighPriority);
+ mListener.setRequestData(mMethod, mHeaders, mPostData);
return true;
}
@@ -190,7 +187,7 @@
try {
ret = mNetwork.requestURL(mMethod, mHeaders,
- mPostData, mListener, mIsHighPriority);
+ mPostData, mListener);
} catch (android.net.ParseException ex) {
error = EventHandler.ERROR_BAD_URL;
} catch (java.lang.RuntimeException ex) {
diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java
index ea12f36..7cbbce2 100644
--- a/core/java/android/webkit/LoadListener.java
+++ b/core/java/android/webkit/LoadListener.java
@@ -104,7 +104,6 @@
private String mMethod;
private Map<String, String> mRequestHeaders;
private byte[] mPostData;
- private boolean mIsHighPriority;
// Flag to indicate that this load is synchronous.
private boolean mSynchronous;
private Vector<Message> mMessageQueue;
@@ -775,14 +774,12 @@
* @param method
* @param headers
* @param postData
- * @param isHighPriority
*/
void setRequestData(String method, Map<String, String> headers,
- byte[] postData, boolean isHighPriority) {
+ byte[] postData) {
mMethod = method;
mRequestHeaders = headers;
mPostData = postData;
- mIsHighPriority = isHighPriority;
}
/**
@@ -1178,7 +1175,7 @@
// Network.requestURL.
Network network = Network.getInstance(getContext());
if (!network.requestURL(mMethod, mRequestHeaders,
- mPostData, this, mIsHighPriority)) {
+ mPostData, this)) {
// Signal a bad url error if we could not load the
// redirection.
handleError(EventHandler.ERROR_BAD_URL,
diff --git a/core/java/android/webkit/Network.java b/core/java/android/webkit/Network.java
index 8c2b09b..fb60109 100644
--- a/core/java/android/webkit/Network.java
+++ b/core/java/android/webkit/Network.java
@@ -149,14 +149,12 @@
* @param headers The http headers.
* @param postData The body of the request.
* @param loader A LoadListener for receiving the results of the request.
- * @param isHighPriority True if this is high priority request.
* @return True if the request was successfully queued.
*/
public boolean requestURL(String method,
Map<String, String> headers,
byte [] postData,
- LoadListener loader,
- boolean isHighPriority) {
+ LoadListener loader) {
String url = loader.url();
@@ -188,7 +186,7 @@
RequestHandle handle = q.queueRequest(
url, loader.getWebAddress(), method, headers, loader,
- bodyProvider, bodyLength, isHighPriority);
+ bodyProvider, bodyLength);
loader.attachRequestHandle(handle);
if (loader.isSynchronous()) {
diff --git a/tests/CoreTests/android/core/RequestAPITest.java b/tests/CoreTests/android/core/RequestAPITest.java
index d89f5ae..94eb23e 100644
--- a/tests/CoreTests/android/core/RequestAPITest.java
+++ b/tests/CoreTests/android/core/RequestAPITest.java
@@ -72,7 +72,7 @@
RequestHandle handle =
mRequestQueue.queueRequest(
"http://localhost:8080/test1", "GET", headers, null,
- null, 0, false);
+ null, 0);
handle.waitUntilComplete();
fail("expected exception not thrown");
@@ -121,7 +121,7 @@
mTestWebServer.setKeepAlive(false);
RequestHandle handle = mRequestQueue.queueRequest(
"http://localhost:8080/test1", "GET", headers, null,
- null, 0, false);
+ null, 0);
handle.waitUntilComplete();
}
@@ -197,7 +197,7 @@
RequestHandle handle = mRequestQueue.queueRequest(
"http://localhost:8080/test1", "GET", null, testEventHandler,
- null, 0, false);
+ null, 0);
Log.d(LOGTAG, "testGet - sent request. Waiting");
handle.waitUntilComplete();
@@ -231,11 +231,11 @@
RequestHandle handle0 = mRequestQueue.queueRequest(
"http://localhost:8080/test1", "GET", null, testEventHandler,
- null, 0, false);
+ null, 0);
handle0.waitUntilComplete();
RequestHandle handle1 = mRequestQueue.queueRequest(
"http://localhost:8080/test1", "GET", null, testEventHandler2,
- null, 0, false);
+ null, 0);
handle1.waitUntilComplete();
/* It's not correct to use same listener for multiple
@@ -270,7 +270,7 @@
RequestHandle handle = mRequestQueue.queueRequest(
"http://localhost:8080/test1", "HEAD", null, testEventHandler,
- null, 0, false);
+ null, 0);
Log.d(LOGTAG, "testHead - sent request waiting");
handle.waitUntilComplete();
@@ -297,7 +297,7 @@
RequestHandle handle = mRequestQueue.queueRequest(
"http://localhost:8080/test1", "GET", null, testEventHandler,
- null, 0, false);
+ null, 0);
Log.d(LOGTAG, "testChunked - sent request waiting");
handle.waitUntilComplete();
@@ -330,7 +330,7 @@
Log.d(LOGTAG, testName + " start - rq = " + mRequestQueue);
RequestHandle requestHandle = mRequestQueue.queueRequest(
- "http://localhost:8080/test1", "GET", null, testEventHandler, null, 0, false);
+ "http://localhost:8080/test1", "GET", null, testEventHandler, null, 0);
Log.d(LOGTAG, testName + " - sent request waiting");
requestHandle.waitUntilComplete();
@@ -398,10 +398,10 @@
leh2.expectHeaders();
RequestHandle handle0 = mRequestQueue.queueRequest(
- "http://localhost:8080/test1", "GET", null, testEventHandler, null, 0, false);
+ "http://localhost:8080/test1", "GET", null, testEventHandler, null, 0);
handle0.waitUntilComplete();
RequestHandle handle1 = mRequestQueue.queueRequest(
- "http://localhost:8080/test1", "HEAD", null, testEventHandler, null, 0, false);
+ "http://localhost:8080/test1", "HEAD", null, testEventHandler, null, 0);
Log.d(LOGTAG, "testGetAndHead - sent request. Waiting");
handle1.waitUntilComplete();
@@ -432,7 +432,7 @@
Log.d(LOGTAG, "testPost start - rq = " + mRequestQueue);
RequestHandle handle = mRequestQueue.queueRequest(
- "http://localhost:8080/test1", "POST", null, testEventHandler, null, 0, false);
+ "http://localhost:8080/test1", "POST", null, testEventHandler, null, 0);
Log.d(LOGTAG, "testPost - sent request waiting");
handle.waitUntilComplete();
@@ -470,7 +470,7 @@
InputStream bodyProvider = new ByteArrayInputStream(mBody.getBytes());
RequestHandle handle = mRequestQueue.queueRequest(
- "http://localhost:8080/test1", "POST", null, testEventHandler, bodyProvider, bodyLength, false);
+ "http://localhost:8080/test1", "POST", null, testEventHandler, bodyProvider, bodyLength);
Log.d(LOGTAG, "testPostWithData - sent request waiting");
handle.waitUntilComplete();