Bug 1357896 - Let BrowserProvider handle bookmark timestamps on insertion r=rnewman draft
authorGrigory Kruglov <gkruglov@mozilla.com>
Mon, 24 Apr 2017 19:12:51 -0400
changeset 567378 3e3a39499182e216e33d163ae04c562ec28add5f
parent 565261 a34919b3d942cfd4f0737d432742b0ffa9929389
child 625632 f0c045ea3daa31659590a5c1645594c806b45bd2
push id55556
push userbmo:gkruglov@mozilla.com
push dateMon, 24 Apr 2017 23:13:12 +0000
reviewersrnewman
bugs1357896
milestone55.0a1
Bug 1357896 - Let BrowserProvider handle bookmark timestamps on insertion r=rnewman Otherwise we end up with modified<created, since we're generating 'modified' just before BrowserProvider generates 'created'. BrowserProvider will handle these timestamps missing from the bookmark ContentValues during an insertion. MozReview-Commit-ID: DundFG1kaAb
mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
--- a/mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
@@ -1131,25 +1131,24 @@ public class LocalBrowserDB extends Brow
 
         String where  = param + " = ?";
         String[] args = new String[] { value };
         int updated  = cr.update(mParentsUriWithProfile, values, where, args);
         debug("Updated " + updated + " rows to new modified time.");
     }
 
     private void addBookmarkItem(ContentResolver cr, String title, String uri, long folderId) {
-        final long now = System.currentTimeMillis();
         ContentValues values = new ContentValues();
         if (title != null) {
             values.put(Bookmarks.TITLE, title);
         }
 
+        // Timestamps (modified and created) will be set by BrowserProvider.
         values.put(Bookmarks.URL, uri);
         values.put(Bookmarks.PARENT, folderId);
-        values.put(Bookmarks.DATE_MODIFIED, now);
 
         // Get the page's favicon ID from the history table
         final Cursor c = cr.query(mHistoryUriWithProfile,
                                   new String[] { History.FAVICON_ID },
                                   History.URL + " = ?",
                                   new String[] { uri },
                                   null);
         try {
@@ -1176,17 +1175,17 @@ public class LocalBrowserDB extends Brow
                   new String[] { uri });
 
         // Bump parent modified time using its ID.
         debug("Bumping parent modified time for addition to: " + folderId);
         final String where  = Bookmarks._ID + " = ?";
         final String[] args = new String[] { String.valueOf(folderId) };
 
         ContentValues bumped = new ContentValues();
-        bumped.put(Bookmarks.DATE_MODIFIED, now);
+        bumped.put(Bookmarks.DATE_MODIFIED, System.currentTimeMillis());
 
         final int updated = cr.update(mBookmarksUriWithProfile, bumped, where, args);
         debug("Updated " + updated + " rows to new modified time.");
     }
 
     @Override
     @RobocopTarget
     public boolean addBookmark(ContentResolver cr, String title, String uri) {