Bug 754224 - Add keyword support to Profile Migration. r=margaret
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Sat, 12 May 2012 01:31:10 +0200
changeset 93812 1f9d4590d2f048fdb26bbea727b55781876a0b34
parent 93811 af802c58e1cff447e0478a7f6fc6b900cd8f44f8
child 93813 c115c58ef2b1800f8e50ce0c396a41603fb1faab
push id9337
push usergpascutto@mozilla.com
push dateFri, 11 May 2012 23:31:24 +0000
treeherdermozilla-inbound@1f9d4590d2f0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs754224
milestone15.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 754224 - Add keyword support to Profile Migration. r=margaret
mobile/android/base/ProfileMigrator.java
--- a/mobile/android/base/ProfileMigrator.java
+++ b/mobile/android/base/ProfileMigrator.java
@@ -146,56 +146,60 @@ public class ProfileMigrator {
         "SELECT places.url             AS p_url,"         +
         "       bookmark.guid          AS b_guid,"        +
         "       bookmark.id            AS b_id,"          +
         "       bookmark.title         AS b_title,"       +
         "       bookmark.type          AS b_type,"        +
         "       bookmark.parent        AS b_parent,"      +
         "       bookmark.dateAdded     AS b_added,"       +
         "       bookmark.lastModified  AS b_modified,"    +
-        "       bookmark.position      AS b_position,";
+        "       bookmark.position      AS b_position,"    +
+        "       keyword.keyword        AS k_keyword,";
 
     private static final String BOOKMARK_QUERY_TRAILER =
-        "FROM ((moz_bookmarks AS bookmark "               +
+        "FROM (((moz_bookmarks AS bookmark "              +
+        "        LEFT OUTER JOIN moz_keywords AS keyword "+
+        "        ON keyword.id = bookmark.keyword_id) "   +
         "       LEFT OUTER JOIN moz_places AS places "    +
         "       ON places.id = bookmark.fk) "             +
-        "       LEFT OUTER JOIN moz_favicons AS favicon " +
-        "       ON places.favicon_id = favicon.id) "      +
+        "      LEFT OUTER JOIN moz_favicons AS favicon "  +
+        "      ON places.favicon_id = favicon.id) "       +
         // Bookmark folders don't have a places entry.
         "WHERE (places.hidden IS NULL "                   +
         "       OR places.hidden <> 1) "                  +
         // This gives us a better chance of adding a folder before
         // adding its contents and hence avoiding extra iterations below.
         "ORDER BY bookmark.id";
 
     private static final String BOOKMARK_QUERY_GUID =
-        BOOKMARK_QUERY_SELECT                              +
+        BOOKMARK_QUERY_SELECT                             +
         "       favicon.data           AS f_data,"        +
         "       favicon.mime_type      AS f_mime_type,"   +
         "       favicon.url            AS f_url,"         +
         "       favicon.guid           AS f_guid "        +
         BOOKMARK_QUERY_TRAILER;
 
     private static final String BOOKMARK_QUERY_NO_GUID =
-        BOOKMARK_QUERY_SELECT                              +
+        BOOKMARK_QUERY_SELECT                             +
         "       favicon.data           AS f_data,"        +
         "       favicon.mime_type      AS f_mime_type,"   +
         "       favicon.url            AS f_url "         +
         BOOKMARK_QUERY_TRAILER;
 
     // Result column of relevant data
     private static final String BOOKMARK_URL      = "p_url";
     private static final String BOOKMARK_TITLE    = "b_title";
     private static final String BOOKMARK_GUID     = "b_guid";
     private static final String BOOKMARK_ID       = "b_id";
     private static final String BOOKMARK_TYPE     = "b_type";
     private static final String BOOKMARK_PARENT   = "b_parent";
     private static final String BOOKMARK_ADDED    = "b_added";
     private static final String BOOKMARK_MODIFIED = "b_modified";
     private static final String BOOKMARK_POSITION = "b_position";
+    private static final String KEYWORD_KEYWORD   = "k_keyword";
     private static final String FAVICON_DATA      = "f_data";
     private static final String FAVICON_MIME      = "f_mime_type";
     private static final String FAVICON_URL       = "f_url";
     private static final String FAVICON_GUID      = "f_guid";
 
     // Helper constants
     private static final int PLACES_TYPE_BOOKMARK  = 1;
     private static final int PLACES_TYPE_FOLDER    = 2;
@@ -1094,30 +1098,33 @@ public class ProfileMigrator {
 
                 doMigrateHistoryBatch(db, fetchEntries, currentEntries);
             }
         }
 
         protected void addBookmark(String url, String title, String guid,
                                    long parent, long added,
                                    long modified, long position,
-                                   int type) {
+                                   String keyword, int type) {
             ContentValues values = new ContentValues();
             if (title == null && url != null) {
                 title = url;
             }
             if (title != null) {
                 values.put(Bookmarks.TITLE, title);
             }
             if (url != null) {
                 values.put(Bookmarks.URL, url);
             }
             if (guid != null) {
                 values.put(SyncColumns.GUID, guid);
             }
+            if (keyword != null) {
+                values.put(Bookmarks.KEYWORD, keyword);
+            }
             values.put(SyncColumns.DATE_CREATED, added);
             values.put(SyncColumns.DATE_MODIFIED, modified);
             values.put(Bookmarks.POSITION, position);
             // Restore deleted record if possible
             values.put(Bookmarks.IS_DELETED, 0);
             if (mRerootMap.containsKey(parent)) {
                 parent = mRerootMap.get(parent);
             }
@@ -1190,16 +1197,17 @@ public class ProfileMigrator {
                 final int titleCol = cursor.getColumnIndex(BOOKMARK_TITLE);
                 final int guidCol = cursor.getColumnIndex(BOOKMARK_GUID);
                 final int idCol = cursor.getColumnIndex(BOOKMARK_ID);
                 final int typeCol = cursor.getColumnIndex(BOOKMARK_TYPE);
                 final int parentCol = cursor.getColumnIndex(BOOKMARK_PARENT);
                 final int addedCol = cursor.getColumnIndex(BOOKMARK_ADDED);
                 final int modifiedCol = cursor.getColumnIndex(BOOKMARK_MODIFIED);
                 final int positionCol = cursor.getColumnIndex(BOOKMARK_POSITION);
+                final int keywordCol = cursor.getColumnIndex(KEYWORD_KEYWORD);
                 final int faviconMimeCol = cursor.getColumnIndex(FAVICON_MIME);
                 final int faviconDataCol = cursor.getColumnIndex(FAVICON_DATA);
                 final int faviconUrlCol = cursor.getColumnIndex(FAVICON_URL);
                 final int faviconGuidCol = cursor.getColumnIndex(FAVICON_GUID);
 
                 // Keep statistics
                 int bookmarkCount = cursor.getCount();
                 Telemetry.HistogramAdd("BROWSERPROVIDER_XUL_IMPORT_BOOKMARKS",
@@ -1259,31 +1267,32 @@ public class ProfileMigrator {
                         String url = cursor.getString(urlCol);
                         String title = cursor.getString(titleCol);
                         String guid = cursor.getString(guidCol);
                         long dateadded =
                             cursor.getLong(addedCol) / (long)1000;
                         long datemodified =
                             cursor.getLong(modifiedCol) / (long)1000;
                         long position = cursor.getLong(positionCol);
+                        String keyword = cursor.getString(keywordCol);
                         byte[] faviconDataBuff = cursor.getBlob(faviconDataCol);
                         String faviconMime = cursor.getString(faviconMimeCol);
                         String faviconUrl = cursor.getString(faviconUrlCol);
                         String faviconGuid = null;
                         if (mHasFaviconGUID) {
                             faviconGuid = cursor.getString(faviconGuidCol);
                         }
 
                         // Is the parent for this bookmark already added?
                         // If so, we can add the bookmark itself.
                         if (knownFolders.contains(parent)) {
                             try {
                                 addBookmark(url, title, guid, parent,
                                             dateadded, datemodified,
-                                            position, type);
+                                            position, keyword, type);
                                 addFavicon(url, faviconUrl, faviconGuid,
                                            faviconMime, faviconDataBuff);
                                 if (type == PLACES_TYPE_FOLDER) {
                                     // We need to know the ID of the folder
                                     // we just inserted. It's possible to
                                     // make future database ops refer to the
                                     // result of this operation, but that makes
                                     // our algorithm to track dependencies too