Bug 1298968 - Add comment explaining why TOPSITES is handled outside of switch r?sebastian
MozReview-Commit-ID: BFvz2qTm4vL
--- a/mobile/android/base/java/org/mozilla/gecko/db/BrowserProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/BrowserProvider.java
@@ -1206,16 +1206,20 @@ public class BrowserProvider extends Sha
return db.rawQuery(query, null);
}
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
final int match = URI_MATCHER.match(uri);
+ // Handle only queries requiring a writable DB connection here: most queries need only a readable
+ // connection, hence we can get a readable DB once, and then handle most queries within a switch.
+ // TopSites requires a writable connection (because of the temporary tables it uses), hence
+ // we handle that separately, i.e. before retrieving a readable connection.
if (match == TOPSITES) {
if (uri.getBooleanQueryParameter(BrowserContract.PARAM_TOPSITES_DISABLE_PINNED, false)) {
return getPlainTopSites(uri);
} else {
return getTopSites(uri);
}
}