diff options
author | John Reck <jreck@google.com> | 2011-07-26 10:22:22 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-07-27 14:11:44 -0700 |
commit | 1cf4b79a0020bc18c83ca8bde0e318ecd5252bc2 (patch) | |
tree | ee1b1ce7a7c86f9a6226e62badf61e6e1bed3b4c /src/com/android/browser/provider | |
parent | ff6a748ae78165cc2298f5120a4374b4ed6f836b (diff) | |
download | packages_apps_Browser-1cf4b79a0020bc18c83ca8bde0e318ecd5252bc2.zip packages_apps_Browser-1cf4b79a0020bc18c83ca8bde0e318ecd5252bc2.tar.gz packages_apps_Browser-1cf4b79a0020bc18c83ca8bde0e318ecd5252bc2.tar.bz2 |
Restore overhaul
Bug: 5069192
Store thumbnails in a database restored async for each tab
Fix restoring a tab not restoring its current state
Change-Id: I2c14e352638aac0ef766fb3bf4036ff220c53ecd
Diffstat (limited to 'src/com/android/browser/provider')
-rw-r--r-- | src/com/android/browser/provider/BrowserProvider2.java | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index b974c0e..e40a882 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -74,6 +74,13 @@ public class BrowserProvider2 extends SQLiteContentProvider { static final Uri LEGACY_AUTHORITY_URI = new Uri.Builder() .authority(LEGACY_AUTHORITY).scheme("content").build(); + public static interface Thumbnails { + public static final Uri CONTENT_URI = Uri.withAppendedPath( + BrowserContract.AUTHORITY_URI, "thumbnails"); + public static final String _ID = "_id"; + public static final String THUMBNAIL = "thumbnail"; + } + static final String TABLE_BOOKMARKS = "bookmarks"; static final String TABLE_HISTORY = "history"; static final String TABLE_IMAGES = "images"; @@ -81,6 +88,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { static final String TABLE_SYNC_STATE = "syncstate"; static final String TABLE_SETTINGS = "settings"; static final String TABLE_SNAPSHOTS = "snapshots"; + static final String TABLE_THUMBNAILS = "thumbnails"; static final String TABLE_BOOKMARKS_JOIN_IMAGES = "bookmarks LEFT OUTER JOIN images " + "ON bookmarks.url = images." + Images.URL; @@ -111,6 +119,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { "WHERE url IS NOT NULL AND deleted == 0) AND url_key NOT IN " + "(SELECT url FROM history WHERE url IS NOT NULL)"; + static final int THUMBNAILS = 10; + static final int THUMBNAILS_ID = 11; + static final int BOOKMARKS = 1000; static final int BOOKMARKS_ID = 1001; static final int BOOKMARKS_FOLDER = 1002; @@ -187,6 +198,8 @@ public class BrowserProvider2 extends SQLiteContentProvider { matcher.addURI(authority, "combined", COMBINED); matcher.addURI(authority, "combined/#", COMBINED_ID); matcher.addURI(authority, "settings", SETTINGS); + matcher.addURI(authority, "thumbnails", THUMBNAILS); + matcher.addURI(authority, "thumbnails/#", THUMBNAILS_ID); // Legacy matcher.addURI(LEGACY_AUTHORITY, "searches", SEARCHES); @@ -333,7 +346,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { final class DatabaseHelper extends SQLiteOpenHelper { static final String DATABASE_NAME = "browser2.db"; - static final int DATABASE_VERSION = 30; + static final int DATABASE_VERSION = 31; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @@ -396,6 +409,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { ");"); createAccountsView(db); + createThumbnails(db); mSyncHelper.createDatabase(db); @@ -406,6 +420,13 @@ public class BrowserProvider2 extends SQLiteContentProvider { enableSync(db); } + void createThumbnails(SQLiteDatabase db) { + db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_THUMBNAILS + " (" + + Thumbnails._ID + " INTEGER PRIMARY KEY," + + Thumbnails.THUMBNAIL + " BLOB NOT NULL" + + ");"); + } + void enableSync(SQLiteDatabase db) { ContentValues values = new ContentValues(); values.put(Settings.KEY, Settings.KEY_SYNC_ENABLED); @@ -500,6 +521,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + if (oldVersion < 31) { + createThumbnails(db); + } if (oldVersion < 30) { db.execSQL("DROP VIEW IF EXISTS " + VIEW_SNAPSHOTS_COMBINED); db.execSQL("DROP TABLE IF EXISTS " + TABLE_SNAPSHOTS); @@ -974,6 +998,18 @@ public class BrowserProvider2 extends SQLiteContentProvider { break; } + case THUMBNAILS_ID: { + selection = DatabaseUtils.concatenateWhere( + selection, Thumbnails._ID + " = ?"); + selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs, + new String[] { Long.toString(ContentUris.parseId(uri)) }); + // fall through + } + case THUMBNAILS: { + qb.setTables(TABLE_THUMBNAILS); + break; + } + default: { throw new UnsupportedOperationException("Unknown URL " + uri.toString()); } @@ -1173,6 +1209,17 @@ public class BrowserProvider2 extends SQLiteContentProvider { } break; } + case THUMBNAILS_ID: { + selection = DatabaseUtils.concatenateWhere( + selection, Thumbnails._ID + " = ?"); + selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs, + new String[] { Long.toString(ContentUris.parseId(uri)) }); + // fall through + } + case THUMBNAILS: { + deleted = db.delete(TABLE_THUMBNAILS, selection, selectionArgs); + break; + } default: { throw new UnsupportedOperationException("Unknown delete URI " + uri); } @@ -1310,6 +1357,11 @@ public class BrowserProvider2 extends SQLiteContentProvider { break; } + case THUMBNAILS: { + id = db.replaceOrThrow(TABLE_THUMBNAILS, null, values); + break; + } + default: { throw new UnsupportedOperationException("Unknown insert URI " + uri); } @@ -1552,6 +1604,12 @@ public class BrowserProvider2 extends SQLiteContentProvider { break; } + case THUMBNAILS: { + modified = db.update(TABLE_THUMBNAILS, values, + selection, selectionArgs); + break; + } + default: { throw new UnsupportedOperationException("Unknown update URI " + uri); } |