Bug 744282 - Switch untracking to use GUIDs only, with Record input as a convenience. r=nalexander
authorRichard Newman <rnewman@mozilla.com>
Tue, 10 Apr 2012 23:21:51 -0700
changeset 94716 ced9405748208b7dc216f7b8a6b33799cf634849
parent 94715 1a46ebf1b9d521489b0c685719df7ac19a30b080
child 94717 5633c5648fed42deb0ede34b7e6dd271a32518e7
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs744282
milestone14.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 744282 - Switch untracking to use GUIDs only, with Record input as a convenience. r=nalexander
mobile/android/base/sync/repositories/RepositorySession.java
mobile/android/base/sync/repositories/StoreTrackingRepositorySession.java
--- a/mobile/android/base/sync/repositories/RepositorySession.java
+++ b/mobile/android/base/sync/repositories/RepositorySession.java
@@ -1,15 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.sync.repositories;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 import org.mozilla.gecko.sync.Logger;
 import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionBeginDelegate;
 import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionFetchRecordsDelegate;
 import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionFinishDelegate;
@@ -354,32 +355,35 @@ public abstract class RepositorySession 
     // Preserve the local Android ID, and merge data where possible.
     // It sure would be nice if copyWithIDs didn't give a shit about androidID, mm?
     Record out = donor.copyWithIDs(remoteRecord.guid, localRecord.androidID);
 
     // We don't want to upload the record if the remote record was
     // applied without changes.
     // This logic will become more complicated as reconciling becomes smarter.
     if (!localIsMoreRecent) {
-      trackRecord(out);
+      trackGUID(out.guid);
     }
     return out;
   }
 
   /**
    * Depending on the RepositorySession implementation, track
    * that a record — most likely a brand-new record that has been
    * applied unmodified — should be tracked so as to not be uploaded
    * redundantly.
    *
-   * The default implementation does nothing.
+   * The default implementations do nothing.
    */
-  protected synchronized void trackRecord(Record record) {
+  protected void trackGUID(String guid) {
   }
 
-  protected synchronized void untrackRecord(Record record) {
+  protected synchronized void untrackGUIDs(Collection<String> guids) {
+  }
+
+  protected void untrackGUID(String guid) {
   }
 
   // Ah, Java. You wretched creature.
   public Iterator<String> getTrackedRecordIDs() {
     return new ArrayList<String>().iterator();
   }
 }
--- a/mobile/android/base/sync/repositories/StoreTrackingRepositorySession.java
+++ b/mobile/android/base/sync/repositories/StoreTrackingRepositorySession.java
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.sync.repositories;
 
+import java.util.Collection;
 import java.util.Iterator;
 
 import org.mozilla.gecko.sync.Logger;
 import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionBeginDelegate;
 import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionFinishDelegate;
 import org.mozilla.gecko.sync.repositories.domain.Record;
 
 public abstract class StoreTrackingRepositorySession extends RepositorySession {
@@ -33,35 +34,55 @@ public abstract class StoreTrackingRepos
       return;
     }
     // Or do this in your own subclass.
     storeTracker = createStoreTracker();
     deferredDelegate.onBeginSucceeded(this);
   }
 
   @Override
-  protected synchronized void trackRecord(Record record) {
+  protected synchronized void trackGUID(String guid) {
+    if (this.storeTracker == null) {
+      throw new IllegalStateException("Store tracker not yet initialized!");
+    }
+    this.storeTracker.trackRecordForExclusion(guid);
+  }
+
+  @Override
+  protected synchronized void untrackGUID(String guid) {
     if (this.storeTracker == null) {
       throw new IllegalStateException("Store tracker not yet initialized!");
     }
+    this.storeTracker.untrackStoredForExclusion(guid);
+  }
+
+  @Override
+  protected synchronized void untrackGUIDs(Collection<String> guids) {
+    if (this.storeTracker == null) {
+      throw new IllegalStateException("Store tracker not yet initialized!");
+    }
+    if (guids == null) {
+      return;
+    }
+    for (String guid : guids) {
+      this.storeTracker.untrackStoredForExclusion(guid);
+    }
+  }
+
+  protected void trackRecord(Record record) {
 
     Logger.debug(LOG_TAG, "Tracking record " + record.guid +
                            " (" + record.lastModified + ") to avoid re-upload.");
     // Future: we care about the timestamp…
-    this.storeTracker.trackRecordForExclusion(record.guid);
+    trackGUID(record.guid);
   }
 
-  @Override
-  protected synchronized void untrackRecord(Record record) {
-    if (this.storeTracker == null) {
-      throw new IllegalStateException("Store tracker not yet initialized!");
-    }
-
+  protected void untrackRecord(Record record) {
     Logger.debug(LOG_TAG, "Un-tracking record " + record.guid + ".");
-    this.storeTracker.untrackStoredForExclusion(record.guid);
+    untrackGUID(record.guid);
   }
 
   @Override
   public Iterator<String> getTrackedRecordIDs() {
     if (this.storeTracker == null) {
       throw new IllegalStateException("Store tracker not yet initialized!");
     }
     return this.storeTracker.recordsTrackedForExclusion();