Bug 718238 - Part 5: allow access to the tracked GUIDs in RepositorySession. r=nalexander
authorRichard Newman <rnewman@mozilla.com>
Thu, 23 Feb 2012 08:14:05 -0800
changeset 87549 a67d81a9354808aab04bac12d45c1b41c0209f21
parent 87548 592043eae457788454fb5cdf09a45f8c99226e75
child 87550 0987e5b0d371fd67190c19bf1d332238c0302f87
push id22130
push userrnewman@mozilla.com
push dateFri, 24 Feb 2012 02:35:54 +0000
treeherdermozilla-central@d23600a1d4a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs718238
milestone13.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 718238 - Part 5: allow access to the tracked GUIDs in RepositorySession. r=nalexander
mobile/android/base/sync/repositories/HashSetStoreTracker.java
mobile/android/base/sync/repositories/RepositorySession.java
mobile/android/base/sync/repositories/StoreTracker.java
mobile/android/base/sync/repositories/StoreTrackingRepositorySession.java
--- a/mobile/android/base/sync/repositories/HashSetStoreTracker.java
+++ b/mobile/android/base/sync/repositories/HashSetStoreTracker.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.HashSet;
+import java.util.Iterator;
 
 import org.mozilla.gecko.sync.repositories.domain.Record;
 
 public class HashSetStoreTracker implements StoreTracker {
 
   // Guarded by `this`.
   // Used to store GUIDs that were not locally modified but
   // have been modified by a call to `store`, and thus
@@ -47,9 +48,14 @@ public class HashSetStoreTracker impleme
     }
     return new RecordFilter() {
       @Override
       public boolean excludeRecord(Record r) {
         return isTrackedForExclusion(r.guid);
       }
     };
   }
+
+  @Override
+  public Iterator<String> recordsTrackedForExclusion() {
+    return this.guids.iterator();
+  }
 }
--- a/mobile/android/base/sync/repositories/RepositorySession.java
+++ b/mobile/android/base/sync/repositories/RepositorySession.java
@@ -33,16 +33,18 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 package org.mozilla.gecko.sync.repositories;
 
+import java.util.ArrayList;
+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;
 import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionGuidsSinceDelegate;
@@ -350,9 +352,14 @@ public abstract class RepositorySession 
    *
    * @param record
    */
   protected synchronized void trackRecord(Record record) {
   }
 
   protected synchronized void untrackRecord(Record record) {
   }
+
+  // Ah, Java. You wretched creature.
+  public Iterator<String> getTrackedRecordIDs() {
+    return new ArrayList<String>().iterator();
+  }
 }
--- a/mobile/android/base/sync/repositories/StoreTracker.java
+++ b/mobile/android/base/sync/repositories/StoreTracker.java
@@ -1,14 +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.Iterator;
+
 /**
  * Our hacky version of transactional semantics. The goal is to prevent
  * the following situation:
  *
  * * AAA is not modified locally.
  * * A modified AAA is downloaded during the storing phase. Its local
  *   timestamp is advanced.
  * * The direction of syncing changes, and AAA is now uploaded to the server.
@@ -70,9 +72,11 @@ public interface StoreTracker {
   /**
   *
   * @param guid
   * @return true if the specified GUID was removed from the tracked set.
   */
   public boolean untrackStoredForExclusion(String guid);
 
   public RecordFilter getFilter();
+
+  public Iterator<String> recordsTrackedForExclusion();
 }
--- a/mobile/android/base/sync/repositories/StoreTrackingRepositorySession.java
+++ b/mobile/android/base/sync/repositories/StoreTrackingRepositorySession.java
@@ -1,14 +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.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 {
   private static final String LOG_TAG = "StoreTrackSession";
   protected StoreTracker storeTracker;
@@ -53,16 +55,24 @@ public abstract class StoreTrackingRepos
       throw new IllegalStateException("Store tracker not yet initialized!");
     }
 
     Logger.debug(LOG_TAG, "Un-tracking record " + record.guid + ".");
     this.storeTracker.untrackStoredForExclusion(record.guid);
   }
 
   @Override
+  public Iterator<String> getTrackedRecordIDs() {
+    if (this.storeTracker == null) {
+      throw new IllegalStateException("Store tracker not yet initialized!");
+    }
+    return this.storeTracker.recordsTrackedForExclusion();
+  }
+
+  @Override
   public void abort(RepositorySessionFinishDelegate delegate) {
     this.storeTracker = null;
     super.abort(delegate);
   }
 
   @Override
   public void finish(RepositorySessionFinishDelegate delegate) {
     super.finish(delegate);