Bug 718238 - Part 5: allow access to the tracked GUIDs in RepositorySession. r=nalexander

This commit is contained in:
Richard Newman 2012-02-23 08:14:05 -08:00
parent 963d6c1b59
commit db8f11e6dc
4 changed files with 27 additions and 0 deletions

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.sync.repositories;
import java.util.HashSet;
import java.util.Iterator;
import org.mozilla.gecko.sync.repositories.domain.Record;
@ -52,4 +53,9 @@ public class HashSetStoreTracker implements StoreTracker {
}
};
}
@Override
public Iterator<String> recordsTrackedForExclusion() {
return this.guids.iterator();
}
}

View File

@ -38,6 +38,8 @@
package org.mozilla.gecko.sync.repositories;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -355,4 +357,9 @@ public abstract class RepositorySession {
protected synchronized void untrackRecord(Record record) {
}
// Ah, Java. You wretched creature.
public Iterator<String> getTrackedRecordIDs() {
return new ArrayList<String>().iterator();
}
}

View File

@ -4,6 +4,8 @@
package org.mozilla.gecko.sync.repositories;
import java.util.Iterator;
/**
* Our hacky version of transactional semantics. The goal is to prevent
* the following situation:
@ -75,4 +77,6 @@ public interface StoreTracker {
public boolean untrackStoredForExclusion(String guid);
public RecordFilter getFilter();
public Iterator<String> recordsTrackedForExclusion();
}

View File

@ -4,6 +4,8 @@
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;
@ -57,6 +59,14 @@ public abstract class StoreTrackingRepositorySession extends RepositorySession {
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;