Bug 739066 - Don't include delete bookmarks/history in Combined view (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 30 Mar 2012 17:31:31 +0100
changeset 94049 61964245b303642e64d2e301ce67f87a61ac2d91
parent 94048 130e702908ca5f21364fd080edaf156d10e71e06
child 94050 cfd6bf0fe1e9ed29f72957d98eda997bc77806a3
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs739066
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 739066 - Don't include delete bookmarks/history in Combined view (r=margaret)
mobile/android/base/db/BrowserProvider.java.in
--- a/mobile/android/base/db/BrowserProvider.java.in
+++ b/mobile/android/base/db/BrowserProvider.java.in
@@ -59,17 +59,17 @@ import android.text.TextUtils;
 import android.util.Log;
 
 public class BrowserProvider extends ContentProvider {
     private static final String LOGTAG = "GeckoBrowserProvider";
     private Context mContext;
 
     static final String DATABASE_NAME = "browser.db";
 
-    static final int DATABASE_VERSION = 5;
+    static final int DATABASE_VERSION = 6;
 
     // Maximum age of deleted records to be cleaned up (20 days in ms)
     static final long MAX_AGE_OF_DELETED_RECORDS = 86400000 * 20;
 
     // Number of records marked as deleted to be removed
     static final long DELETED_RECORDS_PURGE_LIMIT = 5;
 
     static final String TABLE_BOOKMARKS = "bookmarks";
@@ -388,32 +388,34 @@ public class BrowserProvider extends Con
                         " SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
                                      qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " AS " + Combined.URL + ", " +
                                      qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + " AS " + Combined.TITLE + ", " +
                                      "-1 AS " + Combined.HISTORY_ID + ", " +
                                      "-1 AS " + Combined.VISITS + ", " +
                                      "-1 AS " + Combined.DATE_LAST_VISITED +
                         " FROM " + TABLE_BOOKMARKS +
                         " WHERE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE)  + " = " + Bookmarks.TYPE_BOOKMARK + " AND " +
+                                    qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED)  + " = 0 AND " +
                                     qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) +
                                         " NOT IN (SELECT " + History.URL + " FROM " + TABLE_HISTORY + ")" +
                         " UNION ALL" +                
                         // History with and without bookmark.
                         " SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
                                      qualifyColumn(TABLE_HISTORY, History.URL) + " AS " + Combined.URL + ", " +
                                      // Prioritze bookmark titles over history titles, since the user may have
                                      // customized the title for a bookmark.
                                      "COALESCE(" + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + ", " +
                                                    qualifyColumn(TABLE_HISTORY, History.TITLE) +")" + " AS " + Combined.TITLE + ", " +
                                      qualifyColumn(TABLE_HISTORY, History._ID) + " AS " + Combined.HISTORY_ID + ", " +
                                      qualifyColumn(TABLE_HISTORY, History.VISITS) + " AS " + Combined.VISITS + ", " +
                                      qualifyColumn(TABLE_HISTORY, History.DATE_LAST_VISITED) + " AS " + Combined.DATE_LAST_VISITED +
                         " FROM " + TABLE_HISTORY + " LEFT OUTER JOIN " + TABLE_BOOKMARKS +
                             " ON " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " = " + qualifyColumn(TABLE_HISTORY, History.URL) +
-                        " WHERE " + qualifyColumn(TABLE_HISTORY, History.URL) + " IS NOT NULL AND (" +
+                        " WHERE " + qualifyColumn(TABLE_HISTORY, History.URL) + " IS NOT NULL AND " +
+                                    qualifyColumn(TABLE_HISTORY, History.IS_DELETED)  + " = 0 AND (" +
                                         qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " IS NULL OR " +
                                         qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE)  + " = " + Bookmarks.TYPE_BOOKMARK + ")" +
                     ") LEFT OUTER JOIN " + TABLE_IMAGES +
                         " ON " + Combined.URL + " = " + qualifyColumn(TABLE_IMAGES, Images.URL));
         }
 
         @Override
         public void onCreate(SQLiteDatabase db) {
@@ -714,16 +716,23 @@ public class BrowserProvider extends Con
         private void upgradeDatabaseFrom3to4(SQLiteDatabase db) {
             migrateBookmarksTable(db, new BookmarkMigrator3to4());
         }
 
         private void upgradeDatabaseFrom4to5(SQLiteDatabase db) {
             createCombinedWithImagesView(db);
         }
 
+        private void upgradeDatabaseFrom5to6(SQLiteDatabase db) {
+            debug("Dropping view: " + VIEW_COMBINED_WITH_IMAGES);
+            db.execSQL("DROP VIEW IF EXISTS " + VIEW_COMBINED_WITH_IMAGES);
+
+            createCombinedWithImagesView(db);
+        }
+
         @Override
         public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
             debug("Upgrading browser.db: " + db.getPath() + " from " +
                     oldVersion + " to " + newVersion);
 
             db.beginTransaction();
 
             // We have to do incremental upgrades until we reach the current
@@ -740,16 +749,20 @@ public class BrowserProvider extends Con
 
                     case 4:
                         upgradeDatabaseFrom3to4(db);
                         break;
 
                     case 5:
                         upgradeDatabaseFrom4to5(db);
                         break;
+
+                    case 6:
+                        upgradeDatabaseFrom5to6(db);
+                        break;
                  }
              }
 
              db.setTransactionSuccessful();
              db.endTransaction();
         }
 
         @Override