From 2b71d6dad1cbdc84da3eed140429a102971a1106 Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 18 Apr 2012 17:42:06 -0700 Subject: 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 --- src/com/android/browser/Tab.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/com/android/browser/Tab.java') diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 9b5a67579..04bee08dd 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())); -- cgit v1.2.3