Loading core/java/android/webkit/BrowserFrame.java +4 −2 Original line number Diff line number Diff line Loading @@ -488,8 +488,10 @@ class BrowserFrame extends Handler { } } } if (!JniUtil.useChromiumHttpStack()) { WebViewWorker.getHandler().sendEmptyMessage( WebViewWorker.MSG_TRIM_CACHE); } break; } Loading core/java/android/webkit/CacheLoader.java +4 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.webkit; import android.net.http.Headers; import android.text.TextUtils; import android.webkit.JniUtil; /** * This class is a concrete implementation of StreamLoader that uses a Loading @@ -36,6 +37,9 @@ class CacheLoader extends StreamLoader { */ CacheLoader(LoadListener loadListener, CacheManager.CacheResult result) { super(loadListener); assert !JniUtil.useChromiumHttpStack(); mCacheResult = result; } Loading core/java/android/webkit/CacheManager.java +50 −1 Original line number Diff line number Diff line Loading @@ -190,6 +190,11 @@ public final class CacheManager { * @param context The application context. */ static void init(Context context) { if (JniUtil.useChromiumHttpStack()) { // TODO: Need to init mBaseDir. return; } mDataBase = WebViewDatabase.getInstance(context.getApplicationContext()); mBaseDir = new File(context.getCacheDir(), "webviewCache"); if (createCacheDirectory() && mClearCacheOnInit) { Loading @@ -204,6 +209,8 @@ public final class CacheManager { * @return true if the cache directory didn't exist and was created. */ static private boolean createCacheDirectory() { assert !JniUtil.useChromiumHttpStack(); if (!mBaseDir.exists()) { if(!mBaseDir.mkdirs()) { Log.w(LOGTAG, "Unable to create webviewCache directory"); Loading Loading @@ -245,6 +252,8 @@ public final class CacheManager { * @param disabled Whether the cache should be disabled */ static void setCacheDisabled(boolean disabled) { assert !JniUtil.useChromiumHttpStack(); if (disabled == mDisabled) { return; } Loading @@ -269,6 +278,8 @@ public final class CacheManager { // only called from WebViewWorkerThread // make sure to call enableTransaction/disableTransaction in pair static boolean enableTransaction() { assert !JniUtil.useChromiumHttpStack(); if (++mRefCount == 1) { mDataBase.startCacheTransaction(); return true; Loading @@ -279,6 +290,8 @@ public final class CacheManager { // only called from WebViewWorkerThread // make sure to call enableTransaction/disableTransaction in pair static boolean disableTransaction() { assert !JniUtil.useChromiumHttpStack(); if (--mRefCount == 0) { mDataBase.endCacheTransaction(); return true; Loading @@ -289,12 +302,16 @@ public final class CacheManager { // only called from WebViewWorkerThread // make sure to call startTransaction/endTransaction in pair static boolean startTransaction() { assert !JniUtil.useChromiumHttpStack(); return mDataBase.startCacheTransaction(); } // only called from WebViewWorkerThread // make sure to call startTransaction/endTransaction in pair static boolean endTransaction() { assert !JniUtil.useChromiumHttpStack(); boolean ret = mDataBase.endCacheTransaction(); if (++mTrimCacheCount >= TRIM_CACHE_INTERVAL) { mTrimCacheCount = 0; Loading Loading @@ -347,8 +364,12 @@ public final class CacheManager { return null; } String databaseKey = getDatabaseKey(url, postIdentifier); if (JniUtil.useChromiumHttpStack()) { // TODO: Implement this. return null; } String databaseKey = getDatabaseKey(url, postIdentifier); CacheResult result = mDataBase.getCache(databaseKey); if (result == null) { return null; Loading Loading @@ -415,6 +436,11 @@ public final class CacheManager { @Deprecated public static CacheResult createCacheFile(String url, int statusCode, Headers headers, String mimeType, boolean forceCache) { if (JniUtil.useChromiumHttpStack()) { // TODO: Implement this. return null; } return createCacheFile(url, statusCode, headers, mimeType, 0, forceCache); } Loading @@ -422,6 +448,8 @@ public final class CacheManager { static CacheResult createCacheFile(String url, int statusCode, Headers headers, String mimeType, long postIdentifier, boolean forceCache) { assert !JniUtil.useChromiumHttpStack(); if (!forceCache && mDisabled) { return null; } Loading Loading @@ -493,6 +521,11 @@ public final class CacheManager { return; } if (JniUtil.useChromiumHttpStack()) { // TODO: Implement this. return; } if (!cacheRet.outFile.exists()) { // the file in the cache directory can be removed by the system return; Loading Loading @@ -520,6 +553,8 @@ public final class CacheManager { } static boolean cleanupCacheFile(CacheResult cacheRet) { assert !JniUtil.useChromiumHttpStack(); try { cacheRet.outStream.close(); } catch (IOException e) { Loading @@ -534,6 +569,8 @@ public final class CacheManager { * @return Whether the removal succeeded. */ static boolean removeAllCacheFiles() { assert !JniUtil.useChromiumHttpStack(); // Note, this is called before init() when the database is // created or upgraded. if (mBaseDir == null) { Loading Loading @@ -570,6 +607,8 @@ public final class CacheManager { } static void trimCacheIfNeeded() { assert !JniUtil.useChromiumHttpStack(); if (mDataBase.getCacheTotalSize() > CACHE_THRESHOLD) { List<String> pathList = mDataBase.trimCache(CACHE_TRIM_AMOUNT); int size = pathList.size(); Loading Loading @@ -603,6 +642,8 @@ public final class CacheManager { } static void clearCache() { assert !JniUtil.useChromiumHttpStack(); // delete database mDataBase.clearCache(); } Loading @@ -617,12 +658,16 @@ public final class CacheManager { } private static String getDatabaseKey(String url, long postIdentifier) { assert !JniUtil.useChromiumHttpStack(); if (postIdentifier == 0) return url; return postIdentifier + url; } @SuppressWarnings("deprecation") private static void setupFiles(String url, CacheResult cacheRet) { assert !JniUtil.useChromiumHttpStack(); if (true) { // Note: SHA1 is much stronger hash. But the cost of setupFiles() is // 3.2% cpu time for a fresh load of nytimes.com. While a simple Loading Loading @@ -689,6 +734,8 @@ public final class CacheManager { } private static void appendAsHex(int i, StringBuffer ret) { assert !JniUtil.useChromiumHttpStack(); String hex = Integer.toHexString(i); switch (hex.length()) { case 1: Loading Loading @@ -718,6 +765,8 @@ public final class CacheManager { private static CacheResult parseHeaders(int statusCode, Headers headers, String mimeType) { assert !JniUtil.useChromiumHttpStack(); // if the contentLength is already larger than CACHE_MAX_SIZE, skip it if (headers.getContentLength() > CACHE_MAX_SIZE) return null; Loading core/java/android/webkit/FrameLoader.java +6 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.net.http.RequestHandle; import android.os.Build; import android.util.Log; import android.webkit.CacheManager.CacheResult; import android.webkit.JniUtil; import java.util.HashMap; import java.util.Map; Loading Loading @@ -56,6 +57,8 @@ class FrameLoader { FrameLoader(LoadListener listener, WebSettings settings, String method, WebResourceResponse interceptResponse) { assert !JniUtil.useChromiumHttpStack(); mListener = listener; mHeaders = null; mMethod = method; Loading Loading @@ -148,9 +151,10 @@ class FrameLoader { } /* package */ static boolean handleLocalFile(String url, LoadListener loadListener, private static boolean handleLocalFile(String url, LoadListener loadListener, WebSettings settings) { assert !JniUtil.useChromiumHttpStack(); // Attempt to decode the percent-encoded url before passing to the // local loaders. try { Loading core/java/android/webkit/LoadListener.java +4 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.os.Handler; import android.os.Message; import android.util.Log; import android.webkit.CacheManager.CacheResult; import android.webkit.JniUtil; import com.android.internal.R; Loading Loading @@ -156,6 +157,8 @@ class LoadListener extends Handler implements EventHandler { int nativeLoader, boolean synchronous, boolean isMainPageLoader, boolean isMainResource, boolean userGesture, long postIdentifier, String username, String password) { assert !JniUtil.useChromiumHttpStack(); if (DebugFlags.LOAD_LISTENER) { Log.v(LOGTAG, "LoadListener constructor url=" + url); } Loading Loading @@ -991,6 +994,7 @@ class LoadListener extends Handler implements EventHandler { * URL. */ static boolean willLoadFromCache(String url, long identifier) { assert !JniUtil.useChromiumHttpStack(); boolean inCache = CacheManager.getCacheFile(url, identifier, null) != null; if (DebugFlags.LOAD_LISTENER) { Loading Loading
core/java/android/webkit/BrowserFrame.java +4 −2 Original line number Diff line number Diff line Loading @@ -488,8 +488,10 @@ class BrowserFrame extends Handler { } } } if (!JniUtil.useChromiumHttpStack()) { WebViewWorker.getHandler().sendEmptyMessage( WebViewWorker.MSG_TRIM_CACHE); } break; } Loading
core/java/android/webkit/CacheLoader.java +4 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.webkit; import android.net.http.Headers; import android.text.TextUtils; import android.webkit.JniUtil; /** * This class is a concrete implementation of StreamLoader that uses a Loading @@ -36,6 +37,9 @@ class CacheLoader extends StreamLoader { */ CacheLoader(LoadListener loadListener, CacheManager.CacheResult result) { super(loadListener); assert !JniUtil.useChromiumHttpStack(); mCacheResult = result; } Loading
core/java/android/webkit/CacheManager.java +50 −1 Original line number Diff line number Diff line Loading @@ -190,6 +190,11 @@ public final class CacheManager { * @param context The application context. */ static void init(Context context) { if (JniUtil.useChromiumHttpStack()) { // TODO: Need to init mBaseDir. return; } mDataBase = WebViewDatabase.getInstance(context.getApplicationContext()); mBaseDir = new File(context.getCacheDir(), "webviewCache"); if (createCacheDirectory() && mClearCacheOnInit) { Loading @@ -204,6 +209,8 @@ public final class CacheManager { * @return true if the cache directory didn't exist and was created. */ static private boolean createCacheDirectory() { assert !JniUtil.useChromiumHttpStack(); if (!mBaseDir.exists()) { if(!mBaseDir.mkdirs()) { Log.w(LOGTAG, "Unable to create webviewCache directory"); Loading Loading @@ -245,6 +252,8 @@ public final class CacheManager { * @param disabled Whether the cache should be disabled */ static void setCacheDisabled(boolean disabled) { assert !JniUtil.useChromiumHttpStack(); if (disabled == mDisabled) { return; } Loading @@ -269,6 +278,8 @@ public final class CacheManager { // only called from WebViewWorkerThread // make sure to call enableTransaction/disableTransaction in pair static boolean enableTransaction() { assert !JniUtil.useChromiumHttpStack(); if (++mRefCount == 1) { mDataBase.startCacheTransaction(); return true; Loading @@ -279,6 +290,8 @@ public final class CacheManager { // only called from WebViewWorkerThread // make sure to call enableTransaction/disableTransaction in pair static boolean disableTransaction() { assert !JniUtil.useChromiumHttpStack(); if (--mRefCount == 0) { mDataBase.endCacheTransaction(); return true; Loading @@ -289,12 +302,16 @@ public final class CacheManager { // only called from WebViewWorkerThread // make sure to call startTransaction/endTransaction in pair static boolean startTransaction() { assert !JniUtil.useChromiumHttpStack(); return mDataBase.startCacheTransaction(); } // only called from WebViewWorkerThread // make sure to call startTransaction/endTransaction in pair static boolean endTransaction() { assert !JniUtil.useChromiumHttpStack(); boolean ret = mDataBase.endCacheTransaction(); if (++mTrimCacheCount >= TRIM_CACHE_INTERVAL) { mTrimCacheCount = 0; Loading Loading @@ -347,8 +364,12 @@ public final class CacheManager { return null; } String databaseKey = getDatabaseKey(url, postIdentifier); if (JniUtil.useChromiumHttpStack()) { // TODO: Implement this. return null; } String databaseKey = getDatabaseKey(url, postIdentifier); CacheResult result = mDataBase.getCache(databaseKey); if (result == null) { return null; Loading Loading @@ -415,6 +436,11 @@ public final class CacheManager { @Deprecated public static CacheResult createCacheFile(String url, int statusCode, Headers headers, String mimeType, boolean forceCache) { if (JniUtil.useChromiumHttpStack()) { // TODO: Implement this. return null; } return createCacheFile(url, statusCode, headers, mimeType, 0, forceCache); } Loading @@ -422,6 +448,8 @@ public final class CacheManager { static CacheResult createCacheFile(String url, int statusCode, Headers headers, String mimeType, long postIdentifier, boolean forceCache) { assert !JniUtil.useChromiumHttpStack(); if (!forceCache && mDisabled) { return null; } Loading Loading @@ -493,6 +521,11 @@ public final class CacheManager { return; } if (JniUtil.useChromiumHttpStack()) { // TODO: Implement this. return; } if (!cacheRet.outFile.exists()) { // the file in the cache directory can be removed by the system return; Loading Loading @@ -520,6 +553,8 @@ public final class CacheManager { } static boolean cleanupCacheFile(CacheResult cacheRet) { assert !JniUtil.useChromiumHttpStack(); try { cacheRet.outStream.close(); } catch (IOException e) { Loading @@ -534,6 +569,8 @@ public final class CacheManager { * @return Whether the removal succeeded. */ static boolean removeAllCacheFiles() { assert !JniUtil.useChromiumHttpStack(); // Note, this is called before init() when the database is // created or upgraded. if (mBaseDir == null) { Loading Loading @@ -570,6 +607,8 @@ public final class CacheManager { } static void trimCacheIfNeeded() { assert !JniUtil.useChromiumHttpStack(); if (mDataBase.getCacheTotalSize() > CACHE_THRESHOLD) { List<String> pathList = mDataBase.trimCache(CACHE_TRIM_AMOUNT); int size = pathList.size(); Loading Loading @@ -603,6 +642,8 @@ public final class CacheManager { } static void clearCache() { assert !JniUtil.useChromiumHttpStack(); // delete database mDataBase.clearCache(); } Loading @@ -617,12 +658,16 @@ public final class CacheManager { } private static String getDatabaseKey(String url, long postIdentifier) { assert !JniUtil.useChromiumHttpStack(); if (postIdentifier == 0) return url; return postIdentifier + url; } @SuppressWarnings("deprecation") private static void setupFiles(String url, CacheResult cacheRet) { assert !JniUtil.useChromiumHttpStack(); if (true) { // Note: SHA1 is much stronger hash. But the cost of setupFiles() is // 3.2% cpu time for a fresh load of nytimes.com. While a simple Loading Loading @@ -689,6 +734,8 @@ public final class CacheManager { } private static void appendAsHex(int i, StringBuffer ret) { assert !JniUtil.useChromiumHttpStack(); String hex = Integer.toHexString(i); switch (hex.length()) { case 1: Loading Loading @@ -718,6 +765,8 @@ public final class CacheManager { private static CacheResult parseHeaders(int statusCode, Headers headers, String mimeType) { assert !JniUtil.useChromiumHttpStack(); // if the contentLength is already larger than CACHE_MAX_SIZE, skip it if (headers.getContentLength() > CACHE_MAX_SIZE) return null; Loading
core/java/android/webkit/FrameLoader.java +6 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.net.http.RequestHandle; import android.os.Build; import android.util.Log; import android.webkit.CacheManager.CacheResult; import android.webkit.JniUtil; import java.util.HashMap; import java.util.Map; Loading Loading @@ -56,6 +57,8 @@ class FrameLoader { FrameLoader(LoadListener listener, WebSettings settings, String method, WebResourceResponse interceptResponse) { assert !JniUtil.useChromiumHttpStack(); mListener = listener; mHeaders = null; mMethod = method; Loading Loading @@ -148,9 +151,10 @@ class FrameLoader { } /* package */ static boolean handleLocalFile(String url, LoadListener loadListener, private static boolean handleLocalFile(String url, LoadListener loadListener, WebSettings settings) { assert !JniUtil.useChromiumHttpStack(); // Attempt to decode the percent-encoded url before passing to the // local loaders. try { Loading
core/java/android/webkit/LoadListener.java +4 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.os.Handler; import android.os.Message; import android.util.Log; import android.webkit.CacheManager.CacheResult; import android.webkit.JniUtil; import com.android.internal.R; Loading Loading @@ -156,6 +157,8 @@ class LoadListener extends Handler implements EventHandler { int nativeLoader, boolean synchronous, boolean isMainPageLoader, boolean isMainResource, boolean userGesture, long postIdentifier, String username, String password) { assert !JniUtil.useChromiumHttpStack(); if (DebugFlags.LOAD_LISTENER) { Log.v(LOGTAG, "LoadListener constructor url=" + url); } Loading Loading @@ -991,6 +994,7 @@ class LoadListener extends Handler implements EventHandler { * URL. */ static boolean willLoadFromCache(String url, long identifier) { assert !JniUtil.useChromiumHttpStack(); boolean inCache = CacheManager.getCacheFile(url, identifier, null) != null; if (DebugFlags.LOAD_LISTENER) { Loading