backout 3d0d92f2406b for not working properly
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Mon, 21 Apr 2014 15:00:08 -0700
changeset 179897 d6cf23c13dde5fe7c605035b16a97345a0e1ea97
parent 179865 c962bde5ac0b277dbcce06e071b7f0011e58a49b
child 179898 4aa53ede977df6409a9829b57d531772d4bde5b4
child 180023 8774539497c7a91e0ff0e66b0d629beb653a676d
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
milestone31.0a1
backs out3d0d92f2406b84c5f3b68cb7ceb76fa42c4d9057
backout 3d0d92f2406b for not working properly
mobile/android/modules/HomeProvider.jsm
--- a/mobile/android/modules/HomeProvider.jsm
+++ b/mobile/android/modules/HomeProvider.jsm
@@ -84,20 +84,16 @@ function getLastSyncPrefName(datasetId) 
 }
 
 // Whether or not we've registered an update timer.
 var gTimerRegistered = false;
 
 // Map of datasetId -> { interval: <integer>, callback: <function> }
 var gSyncCallbacks = {};
 
-// Whether or not writes to the provider are expected.
-// e.g. save() and deleteAll()
-var gWritesAreExpected = false;
-
 /**
  * nsITimerCallback implementation. Checks to see if it's time to sync any registered datasets.
  *
  * @param timer The timer which has expired.
  */
 function syncTimerCallback(timer) {
   for (let datasetId in gSyncCallbacks) {
     let lastSyncTime = 0;
@@ -153,20 +149,17 @@ this.HomeProvider = Object.freeze({
    */
   requestSync: function(datasetId, callback) {
     // Make sure it's a good time to sync.
     if ((Services.prefs.getIntPref(PREF_SYNC_UPDATE_MODE) === 1) && !isUsingWifi()) {
       Cu.reportError("HomeProvider: Failed to sync because device is not on a local network");
       return false;
     }
 
-    gWritesAreExpected = true;
     callback(datasetId);
-    gWritesAreExpected = false;
-
     return true;
   },
 
   /**
    * Specifies that a sync should be requested for the given dataset and update interval.
    *
    * @param datasetId Unique identifier for the dataset to sync.
    * @param interval Update interval in seconds. By default, this is throttled to 3600 seconds (1 hour).
@@ -294,20 +287,16 @@ HomeStorage.prototype = {
    *
    * @param data
    *        (array) JSON array of row items
    *
    * @return Promise
    * @resolves When the operation has completed.
    */
   save: function(data) {
-    if (!gWritesAreExpected) {
-      Cu.reportError("HomeStorage: save() called outside of sync window");
-    }
-
     return Task.spawn(function save_task() {
       let db = yield getDatabaseConnection();
       try {
         yield db.executeTransaction(function save_transaction() {
           // Insert data into DB.
           for (let item of data) {
             validateItem(this.datasetId, item);
 
@@ -337,20 +326,16 @@ HomeStorage.prototype = {
 
   /**
    * Deletes all rows associated with this storage.
    *
    * @return Promise
    * @resolves When the operation has completed.
    */
   deleteAll: function() {
-    if (!gWritesAreExpected) {
-      Cu.reportError("HomeStorage: deleteAll() called outside of sync window");
-    }
-
     return Task.spawn(function delete_all_task() {
       let db = yield getDatabaseConnection();
       try {
         let params = { dataset_id: this.datasetId };
         yield db.executeCached(SQL.deleteFromDataset, params);
       } finally {
         yield db.close();
       }