diff options
| author | Steve Block <steveblock@google.com> | 2011-01-04 14:26:27 +0000 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2011-01-07 16:50:09 +0000 |
| commit | 808751fe7ac16bf7224cba284a318695d8093355 (patch) | |
| tree | f878bc0cd2fbab85cdfef45c50b9d0e336d16795 /core/java/android/webkit/WebViewDatabase.java | |
| parent | b3b98d9b700ac0ae038a63b734287b4d3aad950d (diff) | |
Avoid superfluous calls to CacheManager with the Chromium HTTP stack
When using the Chromium HTTP stack, most of the calls to CacheManager
methods are not required, as we're not using its cache. These methods
are now marked with asserts to make this clear.
Also avoid creating the cache database in WebViewDatabase.
This will avoid creating the database databases/webviewCache.db and
the directory cache/webviewCache.
Bug: 3270236
Change-Id: I68f94dde16830ed817454d5e1af961f41b71d018
Diffstat (limited to 'core/java/android/webkit/WebViewDatabase.java')
| -rw-r--r-- | core/java/android/webkit/WebViewDatabase.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/core/java/android/webkit/WebViewDatabase.java b/core/java/android/webkit/WebViewDatabase.java index 8f896789e8b7..7b9def06db8f 100644 --- a/core/java/android/webkit/WebViewDatabase.java +++ b/core/java/android/webkit/WebViewDatabase.java @@ -33,6 +33,7 @@ import android.database.sqlite.SQLiteStatement; import android.util.Log; import android.webkit.CookieManager.Cookie; import android.webkit.CacheManager.CacheResult; +import android.webkit.JniUtil; public class WebViewDatabase { private static final String DATABASE_FILE = "webview.db"; @@ -202,6 +203,17 @@ public class WebViewDatabase { return; } + initDatabase(context); + if (!JniUtil.useChromiumHttpStack()) { + initCacheDatabase(context); + } + + // Thread done, notify. + mInitialized = true; + notify(); + } + + private void initDatabase(Context context) { try { mDatabase = context.openOrCreateDatabase(DATABASE_FILE, 0, null); } catch (SQLiteException e) { @@ -234,6 +246,10 @@ public class WebViewDatabase { // improves performance as database's ReentrantLock is // expansive mDatabase.setLockingEnabled(false); + } + + private void initCacheDatabase(Context context) { + assert !JniUtil.useChromiumHttpStack(); try { mCacheDatabase = context.openOrCreateDatabase( @@ -306,10 +322,6 @@ public class WebViewDatabase { .getColumnIndex(CACHE_CONTENTDISPOSITION_COL); mCacheCrossDomainColIndex = mCacheInserter .getColumnIndex(CACHE_CROSSDOMAIN_COL); - - // Thread done, notify. - mInitialized = true; - notify(); } private static void upgradeDatabase() { @@ -668,6 +680,8 @@ public class WebViewDatabase { * @return CacheResult The CacheManager.CacheResult */ CacheResult getCache(String url) { + assert !JniUtil.useChromiumHttpStack(); + if (url == null || !checkInitialized()) { return null; } @@ -708,6 +722,8 @@ public class WebViewDatabase { * @param url The url */ void removeCache(String url) { + assert !JniUtil.useChromiumHttpStack(); + if (url == null || !checkInitialized()) { return; } @@ -722,6 +738,8 @@ public class WebViewDatabase { * @param c The CacheManager.CacheResult */ void addCache(String url, CacheResult c) { + assert !JniUtil.useChromiumHttpStack(); + if (url == null || !checkInitialized()) { return; } |
