diff options
author | John Reck <jreck@google.com> | 2012-04-18 17:42:06 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2012-04-19 10:32:36 -0700 |
commit | 2b71d6dad1cbdc84da3eed140429a102971a1106 (patch) | |
tree | b00a91c23f7af77164b3cecd9939f2277aca4b02 /src/com/android/browser/Tab.java | |
parent | b2ce8741bf389cca77aad12ff5971e51e6e6c3a5 (diff) | |
download | packages_apps_Browser-2b71d6dad1cbdc84da3eed140429a102971a1106.zip packages_apps_Browser-2b71d6dad1cbdc84da3eed140429a102971a1106.tar.gz packages_apps_Browser-2b71d6dad1cbdc84da3eed140429a102971a1106.tar.bz2 |
Change where saved pages are stored
Bug: 5416822
Move saved pages out of external storage (b/5605575)
Save them as files instead of in the database, as the database
has a row size limit
Change-Id: I03b5af2459724d8cab67a9acfcc2827c7129e80f
Diffstat (limited to 'src/com/android/browser/Tab.java')
-rw-r--r-- | src/com/android/browser/Tab.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 9b5a675..04bee08 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -64,8 +64,8 @@ import android.webkit.WebHistoryItem; import android.webkit.WebResourceResponse; import android.webkit.WebStorage; import android.webkit.WebView; -import android.webkit.WebViewClassic; import android.webkit.WebView.PictureListener; +import android.webkit.WebViewClassic; import android.webkit.WebViewClient; import android.widget.CheckBox; import android.widget.Toast; @@ -76,12 +76,15 @@ import com.android.browser.provider.SnapshotProvider.Snapshots; import com.android.common.speech.LoggingEvents; import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.OutputStream; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; +import java.util.UUID; import java.util.Vector; import java.util.regex.Pattern; import java.util.zip.GZIPOutputStream; @@ -2059,9 +2062,10 @@ class Tab implements PictureListener { public ContentValues createSnapshotValues() { if (mMainView == null) return null; - SnapshotByteArrayOutputStream bos = new SnapshotByteArrayOutputStream(); + String path = UUID.randomUUID().toString(); try { - GZIPOutputStream stream = new GZIPOutputStream(bos); + OutputStream outs = mContext.openFileOutput(path, Context.MODE_PRIVATE); + GZIPOutputStream stream = new GZIPOutputStream(outs); if (!getWebViewClassic().saveViewState(stream)) { return null; } @@ -2071,11 +2075,13 @@ class Tab implements PictureListener { Log.w(LOGTAG, "Failed to save view state", e); return null; } - byte[] data = bos.toByteArray(); + File savedFile = mContext.getFileStreamPath(path); + long size = savedFile.length(); ContentValues values = new ContentValues(); values.put(Snapshots.TITLE, mCurrentState.mTitle); values.put(Snapshots.URL, mCurrentState.mUrl); - values.put(Snapshots.VIEWSTATE, data); + values.put(Snapshots.VIEWSTATE_PATH, path); + values.put(Snapshots.VIEWSTATE_SIZE, size); values.put(Snapshots.BACKGROUND, getWebViewClassic().getPageBackgroundColor()); values.put(Snapshots.DATE_CREATED, System.currentTimeMillis()); values.put(Snapshots.FAVICON, compressBitmap(getFavicon())); |