Bug 707732 - Handle case of updating favicon on non-existing URL (r=blassey, a=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Tue, 13 Dec 2011 13:59:37 +0000
changeset 84123 870c9c6580664fda25250cb8459c5354e267ed5e
parent 84122 3d281759cc9ba330bb7b497af9f7480da2a2ca6d
child 84124 1817ebca70d22a521428295561330920923efc3b
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, mfinkle
bugs707732
milestone11.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 707732 - Handle case of updating favicon on non-existing URL (r=blassey, a=mfinkle)
mobile/android/base/db/AndroidBrowserDB.java
--- a/mobile/android/base/db/AndroidBrowserDB.java
+++ b/mobile/android/base/db/AndroidBrowserDB.java
@@ -264,20 +264,23 @@ public class AndroidBrowserDB implements
 
         ByteArrayOutputStream stream = new ByteArrayOutputStream();
         bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
 
         ContentValues values = new ContentValues();
         values.put(Browser.BookmarkColumns.FAVICON, stream.toByteArray());
         values.put(Browser.BookmarkColumns.URL, uri);
 
-        cr.update(Browser.BOOKMARKS_URI,
-                  values,
-                  Browser.BookmarkColumns.URL + " = ?",
-                  new String[] { uri });
+        int updated = cr.update(Browser.BOOKMARKS_URI,
+                                values,
+                                Browser.BookmarkColumns.URL + " = ?",
+                                new String[] { uri });
+
+        if (updated == 0)
+            cr.insert(Browser.BOOKMARKS_URI, values);
     }
 
     public void updateThumbnailForUrl(ContentResolver cr, String uri,
             BitmapDrawable thumbnail) {
         Bitmap bitmap = thumbnail.getBitmap();
 
         ContentValues values = new ContentValues();
         ByteArrayOutputStream bos = new ByteArrayOutputStream();