Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac63bd73 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 7381

* changes:
  Remove all our old high priority knowledge since WebCore will manage it.
parents f4704261 fe4fec7c
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -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;
    }


+1 −1
Original line number Diff line number Diff line
@@ -419,6 +419,6 @@ public class RequestHandle {
        mRequest = mRequestQueue.queueRequest(
                mUrl, mUri, mMethod, mHeaders, mRequest.mEventHandler,
                mBodyProvider,
                mBodyLength, mRequest.mHighPriority).mRequest;
                mBodyLength).mRequest;
    }
}
+28 −69
Original line number Diff line number Diff line
@@ -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);
            LinkedList<Request> reqList = mPending.get(host);
            if (!reqList.isEmpty()) {
                ret = reqList.removeFirst();
            if (reqList.isEmpty()) {
            } 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();
            Map.Entry<HttpHost, LinkedList<Request>> entry = iter.next();
            LinkedList<Request> reqList = entry.getValue();
            if (!reqList.isEmpty()) {
                ret = reqList.removeFirst();
            if (reqList.isEmpty()) {
            } else {
                requestQueue.remove(entry.getKey());
            }
        }
+3 −7
Original line number Diff line number Diff line
@@ -465,8 +465,6 @@ class BrowserFrame extends Handler {
     * @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 @@ class BrowserFrame extends Handler {
                                              HashMap headers,
                                              byte[] postData,
                                              int cacheMode,
                                              boolean isHighPriority,
                                              boolean synchronous) {
        PerfChecker checker = new PerfChecker();

@@ -542,8 +539,8 @@ class BrowserFrame extends Handler {

        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 @@ class BrowserFrame extends Handler {
            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.
+3 −6
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ class FrameLoader {

    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 @@ class FrameLoader {
    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 @@ class FrameLoader {
            // 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 @@ class FrameLoader {
        
        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) {
Loading