Bug 1291821 - Rename RepositorySession's delegate to storeDelegate, for clarity r=rnewman
authorGrisha Kruglov <gkruglov@mozilla.com>
Sat, 08 Oct 2016 17:03:38 -0700
changeset 373890 07c5a4e937382e86f6baf393626f9c3dd060010a
parent 373889 e41e4bbf72ab1283f7ab13d0d8e1b20b7dadcbe5
child 373891 3d8a46a90f237c445a7ea1e6797c909fac112604
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1291821
milestone54.0a1
Bug 1291821 - Rename RepositorySession's delegate to storeDelegate, for clarity r=rnewman Otherwise we often end up with delegate meaning both fetch delegate and store delegate in extending classes, which gets a little confusing. MozReview-Commit-ID: L4Sd79jLr88
mobile/android/services/src/main/java/org/mozilla/gecko/sync/middleware/Crypto5MiddlewareRepositorySession.java
mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/RepositorySession.java
mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/Server11RepositorySession.java
mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserHistoryRepositorySession.java
mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserRepositorySession.java
mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/FennecTabsRepository.java
mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/FormHistoryRepositorySession.java
mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/PasswordsRepositorySession.java
mobile/android/tests/background/junit3/src/org/mozilla/gecko/background/testhelpers/WBORepository.java
mobile/android/tests/background/junit4/src/org/mozilla/android/sync/test/SynchronizerHelpers.java
mobile/android/tests/background/junit4/src/org/mozilla/gecko/background/testhelpers/WBORepository.java
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/middleware/Crypto5MiddlewareRepositorySession.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/middleware/Crypto5MiddlewareRepositorySession.java
@@ -145,28 +145,28 @@ public class Crypto5MiddlewareRepository
   public void fetchAll(RepositorySessionFetchRecordsDelegate delegate) {
     inner.fetchAll(makeUnwrappingDelegate(delegate));
   }
 
   @Override
   public void setStoreDelegate(RepositorySessionStoreDelegate delegate) {
     // TODO: it remains to be seen how this will work.
     inner.setStoreDelegate(delegate);
-    this.delegate = delegate;             // So we can handle errors without involving inner.
+    this.storeDelegate = delegate;             // So we can handle errors without involving inner.
   }
 
   @Override
   public void store(Record record) throws NoStoreDelegateException {
-    if (delegate == null) {
+    if (storeDelegate == null) {
       throw new NoStoreDelegateException();
     }
     CryptoRecord rec = record.getEnvelope();
     rec.keyBundle = this.keyBundle;
     try {
       rec.encrypt();
     } catch (UnsupportedEncodingException | CryptoException e) {
-      delegate.onRecordStoreFailed(e, record.guid);
+      storeDelegate.onRecordStoreFailed(e, record.guid);
       return;
     }
     // Allow the inner session to do delegate handling.
     inner.store(rec);
   }
 }
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/RepositorySession.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/RepositorySession.java
@@ -50,17 +50,17 @@ public abstract class RepositorySession 
   private static final String LOG_TAG = "RepositorySession";
 
   protected static void trace(String message) {
     Logger.trace(LOG_TAG, message);
   }
 
   private SessionStatus status = SessionStatus.UNSTARTED;
   protected Repository repository;
-  protected RepositorySessionStoreDelegate delegate;
+  protected RepositorySessionStoreDelegate storeDelegate;
 
   /**
    * A queue of Runnables which call out into delegates.
    */
   protected ExecutorService delegateQueue  = Executors.newSingleThreadExecutor();
 
   /**
    * A queue of Runnables which effect storing.
@@ -122,17 +122,17 @@ public abstract class RepositorySession 
    * * The store delegate will be notified of error or completion.
    *
    * This arrangement of calls allows for batching at the session level.
    *
    * Store success calls are not guaranteed.
    */
   public void setStoreDelegate(RepositorySessionStoreDelegate delegate) {
     Logger.debug(LOG_TAG, "Setting store delegate to " + delegate);
-    this.delegate = delegate;
+    this.storeDelegate = delegate;
   }
   public abstract void store(Record record) throws NoStoreDelegateException;
 
   public void storeIncomplete() {}
 
   public void storeDone() {
     // Our default behavior will be to assume that the Runnable is
     // executed as soon as all the stores synchronously finish, so
@@ -140,17 +140,17 @@ public abstract class RepositorySession 
     storeDone(now());
   }
 
   public void storeDone(final long end) {
     Logger.debug(LOG_TAG, "Scheduling onStoreCompleted for after storing is done: " + end);
     Runnable command = new Runnable() {
       @Override
       public void run() {
-        delegate.onStoreCompleted(end);
+        storeDelegate.onStoreCompleted(end);
       }
     };
     storeWorkQueue.execute(command);
   }
 
   /**
    * Indicates that a number of records have been stored, more are still to come but after some time,
    * and now would be a good time to flush records and perform any other similar operations.
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/Server11RepositorySession.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/Server11RepositorySession.java
@@ -26,18 +26,18 @@ public class Server11RepositorySession e
     this.downloader = new BatchingDownloader(serverRepository, this);
   }
 
   public Server11Repository getServerRepository() {
     return serverRepository;
   }
 
   @Override
-  public void setStoreDelegate(RepositorySessionStoreDelegate delegate) {
-    this.delegate = delegate;
+  public void setStoreDelegate(RepositorySessionStoreDelegate storeDelegate) {
+    super.setStoreDelegate(storeDelegate);
 
     // Now that we have the delegate, we can initialize our uploader.
     this.uploader = new BatchingUploader(this, storeWorkQueue, delegate);
   }
 
   @Override
   public void guidsSince(long timestamp,
                          RepositorySessionGuidsSinceDelegate delegate) {
@@ -68,17 +68,17 @@ public class Server11RepositorySession e
       delegate.onWipeFailed(new InactiveSessionException(null));
       return;
     }
     // TODO: implement wipe.
   }
 
   @Override
   public void store(Record record) throws NoStoreDelegateException {
-    if (delegate == null) {
+    if (storeDelegate == null) {
       throw new NoStoreDelegateException();
     }
 
     // If delegate was set, this shouldn't happen.
     if (uploader == null) {
       throw new IllegalStateException("Uploader haven't been initialized");
     }
 
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
@@ -609,29 +609,29 @@ public class AndroidBrowserBookmarksRepo
   @Override
   public boolean insertFolder(BookmarkRecord record) {
     // A folder that is *not* deleted needs its androidID updated, so that
     // updateBookkeeping can re-parent, etc.
     Record toStore = prepareRecord(record);
     try {
       Uri recordURI = dbHelper.insert(toStore);
       if (recordURI == null) {
-        delegate.onRecordStoreFailed(new RuntimeException("Got null URI inserting folder with guid " + toStore.guid + "."), record.guid);
+        storeDelegate.onRecordStoreFailed(new RuntimeException("Got null URI inserting folder with guid " + toStore.guid + "."), record.guid);
         return false;
       }
       toStore.androidID = ContentUris.parseId(recordURI);
       Logger.debug(LOG_TAG, "Inserted folder with guid " + toStore.guid + " as androidID " + toStore.androidID);
 
       updateBookkeeping(toStore);
     } catch (Exception e) {
-      delegate.onRecordStoreFailed(e, record.guid);
+      storeDelegate.onRecordStoreFailed(e, record.guid);
       return false;
     }
     trackRecord(toStore);
-    delegate.onRecordStoreSucceeded(record.guid);
+    storeDelegate.onRecordStoreSucceeded(record.guid);
     return true;
   }
 
   /**
    * Implement method of BookmarksInsertionManager.BookmarkInserter.
    */
   @Override
   public void bulkInsertNonFolders(Collection<BookmarkRecord> records) {
@@ -644,36 +644,36 @@ public class AndroidBrowserBookmarksRepo
     }
 
     try {
       int stored = dataAccessor.bulkInsert(toStores);
       if (stored != toStores.size()) {
         // Something failed; most pessimistic action is to declare that all insertions failed.
         // TODO: perform the bulkInsert in a transaction and rollback unless all insertions succeed?
         for (Record failed : toStores) {
-          delegate.onRecordStoreFailed(new RuntimeException("Possibly failed to bulkInsert non-folder with guid " + failed.guid + "."), failed.guid);
+          storeDelegate.onRecordStoreFailed(new RuntimeException("Possibly failed to bulkInsert non-folder with guid " + failed.guid + "."), failed.guid);
         }
         return;
       }
     } catch (NullCursorException e) {
       for (Record failed : toStores) {
-        delegate.onRecordStoreFailed(e, failed.guid);
+        storeDelegate.onRecordStoreFailed(e, failed.guid);
       }
       return;
     }
 
     // Success For All!
     for (Record succeeded : toStores) {
       try {
         updateBookkeeping(succeeded);
       } catch (Exception e) {
         Logger.warn(LOG_TAG, "Got exception updating bookkeeping of non-folder with guid " + succeeded.guid + ".", e);
       }
       trackRecord(succeeded);
-      delegate.onRecordStoreSucceeded(succeeded.guid);
+      storeDelegate.onRecordStoreSucceeded(succeeded.guid);
     }
   }
 
   @Override
   public void finish(RepositorySessionFinishDelegate delegate) throws InactiveSessionException {
     // Allow these to be GCed.
     deletionManager = null;
     insertionManager = null;
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserHistoryRepositorySession.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserHistoryRepositorySession.java
@@ -163,34 +163,34 @@ public class AndroidBrowserHistoryReposi
     recordsBuffer = new ArrayList<HistoryRecord>();
     Logger.debug(LOG_TAG, "Flushing " + outgoing.size() + " records to database.");
     // TODO: move bulkInsert to AndroidBrowserDataAccessor?
     int inserted = ((AndroidBrowserHistoryDataAccessor) dbHelper).bulkInsert(outgoing);
     if (inserted != outgoing.size()) {
       // Something failed; most pessimistic action is to declare that all insertions failed.
       // TODO: perform the bulkInsert in a transaction and rollback unless all insertions succeed?
       for (HistoryRecord failed : outgoing) {
-        delegate.onRecordStoreFailed(new RuntimeException("Failed to insert history item with guid " + failed.guid + "."), failed.guid);
+        storeDelegate.onRecordStoreFailed(new RuntimeException("Failed to insert history item with guid " + failed.guid + "."), failed.guid);
       }
       return;
     }
 
     // All good, everybody succeeded.
     for (HistoryRecord succeeded : outgoing) {
       try {
         // Does not use androidID -- just GUID -> String map.
         updateBookkeeping(succeeded);
       } catch (NoGuidForIdException | ParentNotFoundException e) {
         // Should not happen.
         throw new NullCursorException(e);
       } catch (NullCursorException e) {
         throw e;
       }
       trackRecord(succeeded);
-      delegate.onRecordStoreSucceeded(succeeded.guid); // At this point, we are really inserted.
+      storeDelegate.onRecordStoreSucceeded(succeeded.guid); // At this point, we are really inserted.
     }
   }
 
   @Override
   public void storeDone() {
     storeWorkQueue.execute(new Runnable() {
       @Override
       public void run() {
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserRepositorySession.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/AndroidBrowserRepositorySession.java
@@ -378,17 +378,17 @@ public abstract class AndroidBrowserRepo
   public void fetchAll(RepositorySessionFetchRecordsDelegate delegate) {
     this.fetchSince(0, delegate);
   }
 
   protected int storeCount = 0;
 
   @Override
   public void store(final Record record) throws NoStoreDelegateException {
-    if (delegate == null) {
+    if (storeDelegate == null) {
       throw new NoStoreDelegateException();
     }
     if (record == null) {
       Logger.error(LOG_TAG, "Record sent to store was null");
       throw new IllegalArgumentException("Null record passed to AndroidBrowserRepositorySession.store().");
     }
 
     storeCount += 1;
@@ -397,17 +397,17 @@ public abstract class AndroidBrowserRepo
     // Store Runnables *must* complete synchronously. It's OK, they
     // run on a background thread.
     Runnable command = new Runnable() {
 
       @Override
       public void run() {
         if (!isActive()) {
           Logger.warn(LOG_TAG, "AndroidBrowserRepositorySession is inactive. Store failing.");
-          delegate.onRecordStoreFailed(new InactiveSessionException(null), record.guid);
+          storeDelegate.onRecordStoreFailed(new InactiveSessionException(), record.guid);
           return;
         }
 
         // Check that the record is a valid type.
         // Fennec only supports bookmarks and folders. All other types of records,
         // including livemarks and queries, are simply ignored.
         // See Bug 708149. This might be resolved by Fennec changing its database
         // schema, or by Sync storing non-applied records in its own private database.
@@ -512,30 +512,30 @@ public abstract class AndroidBrowserRepo
                        (toStore.deleted ? " with deleted record " : " with record ") +
                        toStore.guid);
           Record replaced = replace(toStore, existingRecord);
 
           // Note that we don't track records here; deciding that is the job
           // of reconcileRecords.
           Logger.debug(LOG_TAG, "Calling delegate callback with guid " + replaced.guid +
                                 "(" + replaced.androidID + ")");
-          delegate.onRecordStoreSucceeded(replaced.guid);
+          storeDelegate.onRecordStoreSucceeded(replaced.guid);
           return;
 
         } catch (MultipleRecordsForGuidException e) {
           Logger.error(LOG_TAG, "Multiple records returned for given guid: " + record.guid);
-          delegate.onRecordStoreFailed(e, record.guid);
+          storeDelegate.onRecordStoreFailed(e, record.guid);
           return;
         } catch (NoGuidForIdException e) {
           Logger.error(LOG_TAG, "Store failed for " + record.guid, e);
-          delegate.onRecordStoreFailed(e, record.guid);
+          storeDelegate.onRecordStoreFailed(e, record.guid);
           return;
         } catch (Exception e) {
           Logger.error(LOG_TAG, "Store failed for " + record.guid, e);
-          delegate.onRecordStoreFailed(e, record.guid);
+          storeDelegate.onRecordStoreFailed(e, record.guid);
           return;
         }
       }
     };
     storeWorkQueue.execute(command);
   }
 
   /**
@@ -544,30 +544,30 @@ public abstract class AndroidBrowserRepo
    *
    * @param record the incoming record. This will be mostly blank, given that it's a deletion.
    * @param existingRecord the existing record. Use this to decide how to process the deletion.
    */
   protected void storeRecordDeletion(final Record record, final Record existingRecord) {
     // TODO: we ought to mark the record as deleted rather than purging it,
     // in order to support syncing to multiple destinations. Bug 722607.
     dbHelper.purgeGuid(record.guid);
-    delegate.onRecordStoreSucceeded(record.guid);
+    storeDelegate.onRecordStoreSucceeded(record.guid);
   }
 
   protected void insert(Record record) throws NoGuidForIdException, NullCursorException, ParentNotFoundException {
     Record toStore = prepareRecord(record);
     Uri recordURI = dbHelper.insert(toStore);
     if (recordURI == null) {
       throw new NullCursorException(new RuntimeException("Got null URI inserting record with guid " + record.guid));
     }
     toStore.androidID = ContentUris.parseId(recordURI);
 
     updateBookkeeping(toStore);
     trackRecord(toStore);
-    delegate.onRecordStoreSucceeded(toStore.guid);
+    storeDelegate.onRecordStoreSucceeded(toStore.guid);
 
     Logger.debug(LOG_TAG, "Inserted record with guid " + toStore.guid + " as androidID " + toStore.androidID);
   }
 
   protected Record replace(Record newRecord, Record existingRecord) throws NoGuidForIdException, NullCursorException, ParentNotFoundException {
     Record toStore = prepareRecord(newRecord);
 
     // newRecord should already have suitable androidID and guid.
@@ -772,17 +772,17 @@ public abstract class AndroidBrowserRepo
 
     public WipeRunnable(RepositorySessionWipeDelegate delegate) {
       this.delegate = delegate;
     }
 
     @Override
     public void run() {
       if (!isActive()) {
-        delegate.onWipeFailed(new InactiveSessionException(null));
+        delegate.onWipeFailed(new InactiveSessionException());
         return;
       }
       dbHelper.wipe();
       delegate.onWipeSucceeded();
     }
   }
 
   // For testing purposes.
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/FennecTabsRepository.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/FennecTabsRepository.java
@@ -197,17 +197,17 @@ public class FennecTabsRepository extend
       fetchSince(0, delegate);
     }
 
     private static final String TABS_CLIENT_GUID_IS = BrowserContract.Tabs.CLIENT_GUID + " = ?";
     private static final String CLIENT_GUID_IS = BrowserContract.Clients.GUID + " = ?";
 
     @Override
     public void store(final Record record) throws NoStoreDelegateException {
-      if (delegate == null) {
+      if (storeDelegate == null) {
         Logger.warn(LOG_TAG, "No store delegate.");
         throw new NoStoreDelegateException();
       }
       if (record == null) {
         Logger.error(LOG_TAG, "Record sent to store was null");
         throw new IllegalArgumentException("Null record passed to FennecTabsRepositorySession.store().");
       }
       if (!(record instanceof TabsRecord)) {
@@ -216,36 +216,36 @@ public class FennecTabsRepository extend
       }
       final TabsRecord tabsRecord = (TabsRecord) record;
 
       Runnable command = new Runnable() {
         @Override
         public void run() {
           Logger.debug(LOG_TAG, "Storing tabs for client " + tabsRecord.guid);
           if (!isActive()) {
-            delegate.onRecordStoreFailed(new InactiveSessionException(null), record.guid);
+            storeDelegate.onRecordStoreFailed(new InactiveSessionException(), record.guid);
             return;
           }
           if (tabsRecord.guid == null) {
-            delegate.onRecordStoreFailed(new RuntimeException("Can't store record with null GUID."), record.guid);
+            storeDelegate.onRecordStoreFailed(new RuntimeException("Can't store record with null GUID."), record.guid);
             return;
           }
 
           try {
             // This is nice and easy: we *always* store.
             final String[] selectionArgs = new String[] { tabsRecord.guid };
             if (tabsRecord.deleted) {
               try {
                 Logger.debug(LOG_TAG, "Clearing entry for client " + tabsRecord.guid);
                 clientsProvider.delete(BrowserContractHelpers.CLIENTS_CONTENT_URI,
                                        CLIENT_GUID_IS,
                                        selectionArgs);
-                delegate.onRecordStoreSucceeded(record.guid);
+                storeDelegate.onRecordStoreSucceeded(record.guid);
               } catch (Exception e) {
-                delegate.onRecordStoreFailed(e, record.guid);
+                storeDelegate.onRecordStoreFailed(e, record.guid);
               }
               return;
             }
 
             // If it exists, update the client record; otherwise insert.
             final ContentValues clientsCV = tabsRecord.getClientsContentValues();
 
             final ClientRecord clientRecord = clientsDatabase.fetchClient(tabsRecord.guid);
@@ -266,20 +266,20 @@ public class FennecTabsRepository extend
             // Now insert tabs.
             final ContentValues[] tabsArray = tabsRecord.getTabsContentValues();
             Logger.debug(LOG_TAG, "Inserting " + tabsArray.length + " tabs for client " + tabsRecord.guid);
 
             tabsProvider.delete(BrowserContractHelpers.TABS_CONTENT_URI, TABS_CLIENT_GUID_IS, selectionArgs);
             final int inserted = tabsProvider.bulkInsert(BrowserContractHelpers.TABS_CONTENT_URI, tabsArray);
             Logger.trace(LOG_TAG, "Inserted: " + inserted);
 
-            delegate.onRecordStoreSucceeded(record.guid);
+            storeDelegate.onRecordStoreSucceeded(record.guid);
           } catch (Exception e) {
             Logger.warn(LOG_TAG, "Error storing tabs.", e);
-            delegate.onRecordStoreFailed(e, record.guid);
+            storeDelegate.onRecordStoreFailed(e, record.guid);
           }
         }
       };
 
       storeWorkQueue.execute(command);
     }
 
     @Override
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/FormHistoryRepositorySession.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/FormHistoryRepositorySession.java
@@ -442,17 +442,17 @@ public class FormHistoryRepositorySessio
 
   protected void enqueueRegularRecord(Record record) {
     synchronized (recordsBufferMonitor) {
       if (recordsBuffer.size() >= INSERT_ITEM_THRESHOLD) {
         // Insert the existing contents, then enqueue.
         try {
           flushInsertQueue();
         } catch (Exception e) {
-          delegate.onRecordStoreFailed(e, record.guid);
+          storeDelegate.onRecordStoreFailed(e, record.guid);
           return;
         }
       }
       // Store the ContentValues, rather than the record.
       recordsBuffer.add(contentValuesForRegularRecord(record));
     }
   }
 
@@ -484,17 +484,17 @@ public class FormHistoryRepositorySessio
         Logger.debug(LOG_TAG, "Checking for residual form history items to insert.");
         try {
           synchronized (recordsBufferMonitor) {
             flushInsertQueue();
           }
           storeDone(now());
         } catch (Exception e) {
           // XXX TODO
-          delegate.onRecordStoreFailed(e, null);
+          storeDelegate.onRecordStoreFailed(e, null);
         }
       }
     };
     storeWorkQueue.execute(command);
   }
 
   /**
    * Called when a regular record with locally unknown GUID has been fetched
@@ -536,17 +536,17 @@ public class FormHistoryRepositorySessio
     int updated = formsProvider.update(FORM_HISTORY_CONTENT_URI, cv, GUID_IS, new String[] { existingRecord.guid });
     if (updated != 1) {
       Logger.warn(LOG_TAG, "Expected to update 1 record with guid " + existingRecord.guid + " but updated " + updated + " records.");
     }
   }
 
   @Override
   public void store(Record rawRecord) throws NoStoreDelegateException {
-    if (delegate == null) {
+    if (storeDelegate == null) {
       Logger.warn(LOG_TAG, "No store delegate.");
       throw new NoStoreDelegateException();
     }
     if (rawRecord == null) {
       Logger.error(LOG_TAG, "Record sent to store was null");
       throw new IllegalArgumentException("Null record passed to FormHistoryRepositorySession.store().");
     }
     if (!(rawRecord instanceof FormHistoryRecord)) {
@@ -555,17 +555,17 @@ public class FormHistoryRepositorySessio
     }
     final FormHistoryRecord record = (FormHistoryRecord) rawRecord;
 
     Runnable command = new Runnable() {
       @Override
       public void run() {
         if (!isActive()) {
           Logger.warn(LOG_TAG, "FormHistoryRepositorySession is inactive. Store failing.");
-          delegate.onRecordStoreFailed(new InactiveSessionException(null), record.guid);
+          storeDelegate.onRecordStoreFailed(new InactiveSessionException(), record.guid);
           return;
         }
 
         // TODO: lift these into the session.
         // Temporary: this matches prior syncing semantics, in which only
         // the relationship between the local and remote record is considered.
         // In the future we'll track these two timestamps and use them to
         // determine which records have changed, and thus process incoming
@@ -598,26 +598,26 @@ public class FormHistoryRepositorySessio
               return;
             }
 
             boolean locallyModified = existingRecord.lastModified > lastLocalRetrieval;
             if (!locallyModified) {
               Logger.trace(LOG_TAG, "Remote modified, local not. Deleting.");
               deleteExistingRecord(existingRecord);
               trackRecord(record);
-              delegate.onRecordStoreSucceeded(record.guid);
+              storeDelegate.onRecordStoreSucceeded(record.guid);
               return;
             }
 
             Logger.trace(LOG_TAG, "Both local and remote records have been modified.");
             if (record.lastModified > existingRecord.lastModified) {
               Logger.trace(LOG_TAG, "Remote is newer, and deleted. Purging local.");
               deleteExistingRecord(existingRecord);
               trackRecord(record);
-              delegate.onRecordStoreSucceeded(record.guid);
+              storeDelegate.onRecordStoreSucceeded(record.guid);
               return;
             }
 
             Logger.trace(LOG_TAG, "Remote is older, local is not deleted. Ignoring.");
             return;
           }
           // End deletion logic.
 
@@ -627,55 +627,55 @@ public class FormHistoryRepositorySessio
             existingRecord = findExistingRecordByPayload(record);
           }
 
           if (existingRecord == null) {
             // The record is new.
             Logger.trace(LOG_TAG, "No match. Inserting.");
             insertNewRegularRecord(record);
             trackRecord(record);
-            delegate.onRecordStoreSucceeded(record.guid);
+            storeDelegate.onRecordStoreSucceeded(record.guid);
             return;
           }
 
           // We found a local duplicate.
           Logger.trace(LOG_TAG, "Incoming record " + record.guid + " dupes to local record " + existingRecord.guid);
 
           if (!RepoUtils.stringsEqual(record.guid, existingRecord.guid)) {
             // We found a local record that does NOT have the same GUID -- keep the server's version.
             Logger.trace(LOG_TAG, "Remote guid different from local guid. Storing to keep remote guid.");
             replaceExistingRecordWithRegularRecord(record, existingRecord);
             trackRecord(record);
-            delegate.onRecordStoreSucceeded(record.guid);
+            storeDelegate.onRecordStoreSucceeded(record.guid);
             return;
           }
 
           // We found a local record that does have the same GUID -- check modification times.
           boolean locallyModified = existingRecord.lastModified > lastLocalRetrieval;
           if (!locallyModified) {
             Logger.trace(LOG_TAG, "Remote modified, local not. Storing.");
             replaceExistingRecordWithRegularRecord(record, existingRecord);
             trackRecord(record);
-            delegate.onRecordStoreSucceeded(record.guid);
+            storeDelegate.onRecordStoreSucceeded(record.guid);
             return;
           }
 
           Logger.trace(LOG_TAG, "Both local and remote records have been modified.");
           if (record.lastModified > existingRecord.lastModified) {
             Logger.trace(LOG_TAG, "Remote is newer, and not deleted. Storing.");
             replaceExistingRecordWithRegularRecord(record, existingRecord);
             trackRecord(record);
-            delegate.onRecordStoreSucceeded(record.guid);
+            storeDelegate.onRecordStoreSucceeded(record.guid);
             return;
           }
 
           Logger.trace(LOG_TAG, "Remote is older, local is not deleted. Ignoring.");
         } catch (Exception e) {
           Logger.error(LOG_TAG, "Store failed for " + record.guid, e);
-          delegate.onRecordStoreFailed(e, record.guid);
+          storeDelegate.onRecordStoreFailed(e, record.guid);
           return;
         }
       }
     };
 
     storeWorkQueue.execute(command);
   }
 
@@ -689,17 +689,17 @@ public class FormHistoryRepositorySessio
   }
 
   @Override
   public void wipe(final RepositorySessionWipeDelegate delegate) {
     Runnable command = new Runnable() {
       @Override
       public void run() {
         if (!isActive()) {
-          delegate.onWipeFailed(new InactiveSessionException(null));
+          delegate.onWipeFailed(new InactiveSessionException());
           return;
         }
 
         try {
           Logger.debug(LOG_TAG, "Wiping form history and deleted form history...");
           purgeDatabases(formsProvider);
           Logger.debug(LOG_TAG, "Wiping form history and deleted form history... DONE");
         } catch (Exception e) {
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/PasswordsRepositorySession.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/PasswordsRepositorySession.java
@@ -232,17 +232,17 @@ public class PasswordsRepositorySession 
 
   @Override
   public void fetchAll(RepositorySessionFetchRecordsDelegate delegate) {
     fetchSince(0, delegate);
   }
 
   @Override
   public void store(final Record record) throws NoStoreDelegateException {
-    if (delegate == null) {
+    if (storeDelegate == null) {
       Logger.error(LOG_TAG, "No store delegate.");
       throw new NoStoreDelegateException();
     }
     if (record == null) {
       Logger.error(LOG_TAG, "Record sent to store was null.");
       throw new IllegalArgumentException("Null record passed to PasswordsRepositorySession.store().");
     }
     if (!(record instanceof PasswordRecord)) {
@@ -252,32 +252,32 @@ public class PasswordsRepositorySession 
 
     final PasswordRecord remoteRecord = (PasswordRecord) record;
 
     final Runnable storeRunnable = new Runnable() {
       @Override
       public void run() {
         if (!isActive()) {
           Logger.warn(LOG_TAG, "RepositorySession is inactive. Store failing.");
-          delegate.onRecordStoreFailed(new InactiveSessionException(null), record.guid);
+          storeDelegate.onRecordStoreFailed(new InactiveSessionException(), record.guid);
           return;
         }
 
         final String guid = remoteRecord.guid;
         if (guid == null) {
-          delegate.onRecordStoreFailed(new RuntimeException("Can't store record with null GUID."), record.guid);
+          storeDelegate.onRecordStoreFailed(new RuntimeException("Can't store record with null GUID."), record.guid);
           return;
         }
 
         PasswordRecord existingRecord;
         try {
           existingRecord = retrieveByGUID(guid);
         } catch (NullCursorException | RemoteException e) {
           // Indicates a serious problem.
-          delegate.onRecordStoreFailed(e, record.guid);
+          storeDelegate.onRecordStoreFailed(e, record.guid);
           return;
         }
 
         long lastLocalRetrieval  = 0;      // lastSyncTimestamp?
         long lastRemoteRetrieval = 0;      // TODO: adjust for clock skew.
         boolean remotelyModified = remoteRecord.lastModified > lastRemoteRetrieval;
 
         // Check deleted state first.
@@ -319,48 +319,48 @@ public class PasswordsRepositorySession 
 
           return;
         }
         // End deletion logic.
 
         // Validate the incoming record.
         if (!remoteRecord.isValid()) {
             Logger.warn(LOG_TAG, "Incoming record is invalid. Reporting store failed.");
-            delegate.onRecordStoreFailed(new RuntimeException("Can't store invalid password record."), record.guid);
+            storeDelegate.onRecordStoreFailed(new RuntimeException("Can't store invalid password record."), record.guid);
             return;
         }
 
         // Now we're processing a non-deleted incoming record.
         if (existingRecord == null) {
           trace("Looking up match for record " + remoteRecord.guid);
           try {
             existingRecord = findExistingRecord(remoteRecord);
           } catch (RemoteException e) {
             Logger.error(LOG_TAG, "Remote exception in findExistingRecord.");
-            delegate.onRecordStoreFailed(e, record.guid);
+            storeDelegate.onRecordStoreFailed(e, record.guid);
           } catch (NullCursorException e) {
             Logger.error(LOG_TAG, "Null cursor in findExistingRecord.");
-            delegate.onRecordStoreFailed(e, record.guid);
+            storeDelegate.onRecordStoreFailed(e, record.guid);
           }
         }
 
         if (existingRecord == null) {
           // The record is new.
           trace("No match. Inserting.");
           Logger.debug(LOG_TAG, "Didn't find matching record. Inserting.");
           Record inserted = null;
           try {
             inserted = insert(remoteRecord);
           } catch (RemoteException e) {
             Logger.debug(LOG_TAG, "Record insert caused a RemoteException.");
-            delegate.onRecordStoreFailed(e, record.guid);
+            storeDelegate.onRecordStoreFailed(e, record.guid);
             return;
           }
           trackRecord(inserted);
-          delegate.onRecordStoreSucceeded(inserted.guid);
+          storeDelegate.onRecordStoreSucceeded(inserted.guid);
           return;
         }
 
         // We found a local dupe.
         trace("Incoming record " + remoteRecord.guid + " dupes to local record " + existingRecord.guid);
         Logger.debug(LOG_TAG, "remote " + remoteRecord.guid + " dupes to " + existingRecord.guid);
 
         if (existingRecord.deleted && existingRecord.lastModified > remoteRecord.lastModified) {
@@ -376,25 +376,25 @@ public class PasswordsRepositorySession 
 
         // TODO: pass in timestamps?
         Logger.debug(LOG_TAG, "Replacing " + existingRecord.guid + " with record " + toStore.guid);
         Record replaced = null;
         try {
           replaced = replace(existingRecord, toStore);
         } catch (RemoteException e) {
           Logger.debug(LOG_TAG, "Record replace caused a RemoteException.");
-          delegate.onRecordStoreFailed(e, record.guid);
+          storeDelegate.onRecordStoreFailed(e, record.guid);
           return;
         }
 
         // Note that we don't track records here; deciding that is the job
         // of reconcileRecords.
         Logger.debug(LOG_TAG, "Calling delegate callback with guid " + replaced.guid +
                               "(" + replaced.androidID + ")");
-        delegate.onRecordStoreSucceeded(record.guid);
+        storeDelegate.onRecordStoreSucceeded(record.guid);
         return;
       }
     };
     storeWorkQueue.execute(storeRunnable);
   }
 
   @Override
   public void wipe(final RepositorySessionWipeDelegate delegate) {
@@ -639,20 +639,20 @@ public class PasswordsRepositorySession 
     return null;
   }
 
   private void storeRecordDeletion(Record record) {
     try {
       deleteGUID(record.guid);
     } catch (RemoteException e) {
       Logger.error(LOG_TAG, "RemoteException in password delete.");
-      delegate.onRecordStoreFailed(e, record.guid);
+      storeDelegate.onRecordStoreFailed(e, record.guid);
       return;
     }
-    delegate.onRecordStoreSucceeded(record.guid);
+    storeDelegate.onRecordStoreSucceeded(record.guid);
   }
 
   /**
    * Make a PasswordRecord from a Cursor.
    * @param cur
    *        Cursor from query.
    * @param deleted
    *        true if creating a deleted Record, false if otherwise.
--- a/mobile/android/tests/background/junit3/src/org/mozilla/gecko/background/testhelpers/WBORepository.java
+++ b/mobile/android/tests/background/junit3/src/org/mozilla/gecko/background/testhelpers/WBORepository.java
@@ -121,44 +121,44 @@ public class WBORepository extends Repos
       }
       long fetchCompleted  = now();
       stats.fetchCompleted = fetchCompleted;
       delegate.deferredFetchDelegate(delegateExecutor).onFetchCompleted(fetchCompleted);
     }
 
     @Override
     public void store(final Record record) throws NoStoreDelegateException {
-      if (delegate == null) {
+      if (storeDelegate == null) {
         throw new NoStoreDelegateException();
       }
       final long now = now();
       if (stats.storeBegan < 0) {
         stats.storeBegan = now;
       }
       Record existing = wbos.get(record.guid);
       Logger.debug(LOG_TAG, "Existing record is " + (existing == null ? "<null>" : (existing.guid + ", " + existing)));
       if (existing != null &&
           existing.lastModified > record.lastModified) {
         Logger.debug(LOG_TAG, "Local record is newer. Not storing.");
-        delegate.deferredStoreDelegate(delegateExecutor).onRecordStoreSucceeded(record.guid);
+        storeDelegate.deferredStoreDelegate(delegateExecutor).onRecordStoreSucceeded(record.guid);
         return;
       }
       if (existing != null) {
         Logger.debug(LOG_TAG, "Replacing local record.");
       }
 
       // Store a copy of the record with an updated modified time.
       Record toStore = record.copyWithIDs(record.guid, record.androidID);
       if (bumpTimestamps) {
         toStore.lastModified = now;
       }
       wbos.put(record.guid, toStore);
 
       trackRecord(toStore);
-      delegate.deferredStoreDelegate(delegateExecutor).onRecordStoreSucceeded(record.guid);
+      storeDelegate.deferredStoreDelegate(delegateExecutor).onRecordStoreSucceeded(record.guid);
     }
 
     @Override
     public void wipe(final RepositorySessionWipeDelegate delegate) {
       if (!isActive()) {
         delegate.onWipeFailed(new InactiveSessionException(null));
         return;
       }
@@ -189,17 +189,17 @@ public class WBORepository extends Repos
     @Override
     public void storeDone(long end) {
       // TODO: this is not guaranteed to be called after all of the record
       // store callbacks have completed!
       if (stats.storeBegan < 0) {
         stats.storeBegan = end;
       }
       stats.storeCompleted = end;
-      delegate.deferredStoreDelegate(delegateExecutor).onStoreCompleted(end);
+      storeDelegate.deferredStoreDelegate(delegateExecutor).onStoreCompleted(end);
     }
   }
 
   public ConcurrentHashMap<String, Record> wbos;
 
   public WBORepository(boolean bumpTimestamps) {
     super();
     this.bumpTimestamps = bumpTimestamps;
--- a/mobile/android/tests/background/junit4/src/org/mozilla/android/sync/test/SynchronizerHelpers.java
+++ b/mobile/android/tests/background/junit4/src/org/mozilla/android/sync/test/SynchronizerHelpers.java
@@ -69,21 +69,21 @@ public class SynchronizerHelpers {
    */
   public static class SerialFailStoreWBORepository extends WBORepository {
     @Override
     public void createSession(RepositorySessionCreationDelegate delegate,
                               Context context) {
       delegate.deferredCreationDelegate().onSessionCreated(new WBORepositorySession(this) {
         @Override
         public void store(final Record record) throws NoStoreDelegateException {
-          if (delegate == null) {
+          if (storeDelegate == null) {
             throw new NoStoreDelegateException();
           }
           if (record.guid.contains(FAIL_SENTINEL)) {
-            delegate.onRecordStoreFailed(new StoreFailedException(), record.guid);
+            storeDelegate.onRecordStoreFailed(new StoreFailedException(), record.guid);
           } else {
             super.store(record);
           }
         }
       });
     }
   }
 
@@ -103,17 +103,17 @@ public class SynchronizerHelpers {
       }
 
       public void superStore(final Record record) throws NoStoreDelegateException {
         super.store(record);
       }
 
       @Override
       public void store(final Record record) throws NoStoreDelegateException {
-        if (delegate == null) {
+        if (storeDelegate == null) {
           throw new NoStoreDelegateException();
         }
         synchronized (batch) {
           batch.add(record);
           if (record.guid.contains("Fail")) {
             batchShouldFail = true;
           }
 
@@ -129,22 +129,22 @@ public class SynchronizerHelpers {
         batchShouldFail = false;
         batch.clear();
         storeWorkQueue.execute(new Runnable() {
           @Override
           public void run() {
             Logger.trace("XXX", "Notifying about batch.  Failure? " + thisBatchShouldFail);
             for (Record batchRecord : thisBatch) {
               if (thisBatchShouldFail) {
-                delegate.onRecordStoreFailed(new StoreFailedException(), batchRecord.guid);
+                storeDelegate.onRecordStoreFailed(new StoreFailedException(), batchRecord.guid);
               } else {
                 try {
                   superStore(batchRecord);
                 } catch (NoStoreDelegateException e) {
-                  delegate.onRecordStoreFailed(e, batchRecord.guid);
+                  storeDelegate.onRecordStoreFailed(e, batchRecord.guid);
                 }
               }
             }
           }
         });
       }
 
       @Override
--- a/mobile/android/tests/background/junit4/src/org/mozilla/gecko/background/testhelpers/WBORepository.java
+++ b/mobile/android/tests/background/junit4/src/org/mozilla/gecko/background/testhelpers/WBORepository.java
@@ -120,44 +120,44 @@ public class WBORepository extends Repos
       }
       long fetchCompleted  = now();
       stats.fetchCompleted = fetchCompleted;
       delegate.deferredFetchDelegate(delegateExecutor).onFetchCompleted(fetchCompleted);
     }
 
     @Override
     public void store(final Record record) throws NoStoreDelegateException {
-      if (delegate == null) {
+      if (storeDelegate == null) {
         throw new NoStoreDelegateException();
       }
       final long now = now();
       if (stats.storeBegan < 0) {
         stats.storeBegan = now;
       }
       Record existing = wbos.get(record.guid);
       Logger.debug(LOG_TAG, "Existing record is " + (existing == null ? "<null>" : (existing.guid + ", " + existing)));
       if (existing != null &&
           existing.lastModified > record.lastModified) {
         Logger.debug(LOG_TAG, "Local record is newer. Not storing.");
-        delegate.deferredStoreDelegate(delegateExecutor).onRecordStoreSucceeded(record.guid);
+        storeDelegate.deferredStoreDelegate(delegateExecutor).onRecordStoreSucceeded(record.guid);
         return;
       }
       if (existing != null) {
         Logger.debug(LOG_TAG, "Replacing local record.");
       }
 
       // Store a copy of the record with an updated modified time.
       Record toStore = record.copyWithIDs(record.guid, record.androidID);
       if (bumpTimestamps) {
         toStore.lastModified = now;
       }
       wbos.put(record.guid, toStore);
 
       trackRecord(toStore);
-      delegate.deferredStoreDelegate(delegateExecutor).onRecordStoreSucceeded(record.guid);
+      storeDelegate.deferredStoreDelegate(delegateExecutor).onRecordStoreSucceeded(record.guid);
     }
 
     @Override
     public void wipe(final RepositorySessionWipeDelegate delegate) {
       if (!isActive()) {
         delegate.onWipeFailed(new InactiveSessionException(null));
         return;
       }
@@ -188,17 +188,17 @@ public class WBORepository extends Repos
     @Override
     public void storeDone(long end) {
       // TODO: this is not guaranteed to be called after all of the record
       // store callbacks have completed!
       if (stats.storeBegan < 0) {
         stats.storeBegan = end;
       }
       stats.storeCompleted = end;
-      delegate.deferredStoreDelegate(delegateExecutor).onStoreCompleted(end);
+      storeDelegate.deferredStoreDelegate(delegateExecutor).onStoreCompleted(end);
     }
   }
 
   public ConcurrentHashMap<String, Record> wbos;
 
   public WBORepository(boolean bumpTimestamps) {
     super();
     this.bumpTimestamps = bumpTimestamps;