Bug 1312795 - Remove shouldUseTransactions method and related code. r?sebastian draft
authorTushar Saini (:shatur) <tushar.saini1285@gmail.com>
Tue, 25 Oct 2016 22:54:59 +0530
changeset 429311 1257515f94664b3d7087df6e43b538ac8757de7b
parent 427338 99a239e1866a57f987b08dad796528e4ea30e622
child 534942 8e7651c4ddc79d3f72f42f92b5f5e8094d0b2adf
push id33534
push userbmo:tushar.saini1285@gmail.com
push dateTue, 25 Oct 2016 17:37:00 +0000
reviewerssebastian
bugs1312795
milestone52.0a1
Bug 1312795 - Remove shouldUseTransactions method and related code. r?sebastian MozReview-Commit-ID: xRXPi9yvff
mobile/android/base/java/org/mozilla/gecko/db/AbstractTransactionalProvider.java
--- a/mobile/android/base/java/org/mozilla/gecko/db/AbstractTransactionalProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/AbstractTransactionalProvider.java
@@ -84,25 +84,16 @@ public abstract class AbstractTransactio
      * Note that beginWrite takes a DB argument, but we don't differentiate
      * between databases in this tracking flag. If your ContentProvider manages
      * multiple database transactions within the same thread, you'll need to
      * amend this scheme -- but then, you're already doing some serious wizardry,
      * so rock on.
      */
     final ThreadLocal<Boolean> isInBatchOperation = new ThreadLocal<Boolean>();
 
-    /**
-     * Return true if OS version and database parallelism support indicates
-     * that this provider should bundle writes into transactions.
-     */
-    @SuppressWarnings("static-method")
-    protected boolean shouldUseTransactions() {
-        return true;
-    }
-
     private boolean isInBatch() {
         final Boolean isInBatch = isInBatchOperation.get();
         if (isInBatch == null) {
             return false;
         }
 
         return isInBatch;
     }
@@ -111,33 +102,33 @@ public abstract class AbstractTransactio
      * If we're not currently in a transaction, and we should be, start one.
      */
     protected void beginWrite(final SQLiteDatabase db) {
         if (isInBatch()) {
             trace("Not bothering with an intermediate write transaction: inside batch operation.");
             return;
         }
 
-        if (shouldUseTransactions() && !db.inTransaction()) {
+        if (!db.inTransaction()) {
             trace("beginWrite: beginning transaction.");
             db.beginTransaction();
         }
     }
 
     /**
      * If we're not in a batch, but we are in a write transaction, mark it as
      * successful.
      */
     protected void markWriteSuccessful(final SQLiteDatabase db) {
         if (isInBatch()) {
             trace("Not marking write successful: inside batch operation.");
             return;
         }
 
-        if (shouldUseTransactions() && db.inTransaction()) {
+        if (db.inTransaction()) {
             trace("Marking write transaction successful.");
             db.setTransactionSuccessful();
         }
     }
 
     /**
      * If we're not in a batch, but we are in a write transaction,
      * end it.
@@ -145,17 +136,17 @@ public abstract class AbstractTransactio
      * @see PerProfileDatabaseProvider#markWriteSuccessful(SQLiteDatabase)
      */
     protected void endWrite(final SQLiteDatabase db) {
         if (isInBatch()) {
             trace("Not ending write: inside batch operation.");
             return;
         }
 
-        if (shouldUseTransactions() && db.inTransaction()) {
+        if (db.inTransaction()) {
             trace("endWrite: ending transaction.");
             db.endTransaction();
         }
     }
 
     protected void beginBatch(final SQLiteDatabase db) {
         trace("Beginning batch.");
         isInBatchOperation.set(Boolean.TRUE);