Bug 904081 - Avoid exceeding query var limit in getFaviconsForUrls() (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Thu, 15 Aug 2013 17:39:16 +0100
changeset 143539 a7454660ca732db8744db69c6cf95943e3c38025
parent 143538 9dfb38fba3a8227e4f6be06c1f2d680f2d4a1f96
child 143540 9760c819e9934d5083d90ba83d1733590d1a4e37
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs904081
milestone26.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 904081 - Avoid exceeding query var limit in getFaviconsForUrls() (r=margaret)
mobile/android/base/db/LocalBrowserDB.java
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -17,16 +17,17 @@ import org.mozilla.gecko.db.BrowserContr
 import org.mozilla.gecko.gfx.BitmapUtils;
 
 import android.content.ContentProviderOperation;
 import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.database.ContentObserver;
 import android.database.Cursor;
 import android.database.CursorWrapper;
+import android.database.DatabaseUtils;
 import android.graphics.Bitmap;
 import android.graphics.drawable.BitmapDrawable;
 import android.net.Uri;
 import android.provider.Browser;
 import android.text.TextUtils;
 import android.util.Log;
 
 import java.io.ByteArrayOutputStream;
@@ -747,33 +748,33 @@ public class LocalBrowserDB implements B
         }
 
         return null;
     }
 
     @Override
     public Cursor getFaviconsForUrls(ContentResolver cr, List<String> urls) {
         StringBuilder selection = new StringBuilder();
-        String[] selectionArgs = new String[urls.size()];
+        selection.append(Favicons.URL + " IN (");
 
         for (int i = 0; i < urls.size(); i++) {
-          final String url = urls.get(i);
+            final String url = urls.get(i);
+
+            if (i > 0)
+                selection.append(", ");
 
-          if (i > 0)
-            selection.append(" OR ");
+            DatabaseUtils.appendEscapedSQLString(selection, url);
+        }
 
-          selection.append(Favicons.URL + " = ?");
-          selectionArgs[i] = url;
-        }
+        selection.append(")");
 
         return cr.query(mCombinedUriWithProfile,
                         new String[] { Combined.URL, Combined.FAVICON },
                         selection.toString(),
-                        selectionArgs,
-                        null);
+                        null, null);
     }
 
     @Override
     public void updateFaviconForUrl(ContentResolver cr, String pageUri,
             Bitmap favicon, String faviconUri) {
         ContentValues values = new ContentValues();
         values.put(Favicons.URL, faviconUri);
         values.put(Favicons.PAGE_URL, pageUri);