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

Commit 0b437472 authored by Steve Block's avatar Steve Block
Browse files

Fix loading from the cache for synchronous requests

This fixes crashes in several XHR layout tests.

Bug: 2218794
Change-Id: Iebe3a2d19f1fa43b8d9c9d7763e818f7195b8ceb
parent f3c755a0
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -262,10 +262,14 @@ class FrameLoader {
        CacheLoader cacheLoader =
                new CacheLoader(mListener, result);
        mListener.setCacheLoader(cacheLoader);
        if (mListener.isSynchronous()) {
            cacheLoader.load();
        } else {
            // Load the cached file in a separate thread
            WebViewWorker.getHandler().obtainMessage(
                    WebViewWorker.MSG_ADD_STREAMLOADER, cacheLoader).sendToTarget();
        }
    }

    /*
     * This function is used by the handleHTTPLoad to setup the cache headers
+16 −8
Original line number Diff line number Diff line
@@ -656,10 +656,14 @@ class LoadListener extends Handler implements EventHandler {
                // ask for it, so make sure we have a valid CacheLoader
                // before calling it.
                if (mCacheLoader != null) {
                    if (isSynchronous()) {
                        mCacheLoader.load();
                    } else {
                        // Load the cached file in a separate thread
                        WebViewWorker.getHandler().obtainMessage(
                                WebViewWorker.MSG_ADD_STREAMLOADER, mCacheLoader)
                                .sendToTarget();
                    }
                    mFromCache = true;
                    if (DebugFlags.LOAD_LISTENER) {
                        Log.v(LOGTAG, "LoadListener cache load url=" + url());
@@ -718,10 +722,14 @@ class LoadListener extends Handler implements EventHandler {
                    Log.v(LOGTAG, "FrameLoader: HTTP URL in cache " +
                            "and usable: " + url());
                }
                if (isSynchronous()) {
                    mCacheLoader.load();
                } else {
                    // Load the cached file in a separate thread
                    WebViewWorker.getHandler().obtainMessage(
                            WebViewWorker.MSG_ADD_STREAMLOADER, mCacheLoader)
                            .sendToTarget();
                }
                mFromCache = true;
                return true;
            }