зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1291821 - Add onBatchComplete to a FetchRecordsDelegate r=rnewman
Intended to signal that a group of records have been fetched, and more are to come after a pause. MozReview-Commit-ID: 8ozZTc6aNdA --HG-- extra : rebase_source : e2fdf70d6db6e242e65b788dcb6a09f975b5124b
This commit is contained in:
Родитель
3a6788a0df
Коммит
eb469c632e
|
@ -114,6 +114,11 @@ public class Crypto5MiddlewareRepositorySession extends MiddlewareRepositorySess
|
|||
next.onFetchCompleted(fetchEnd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
next.onBatchCompleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositorySessionFetchRecordsDelegate deferredFetchDelegate(ExecutorService executor) {
|
||||
// Synchronously perform *our* work, passing through appropriately.
|
||||
|
|
|
@ -46,6 +46,16 @@ public class DeferredRepositorySessionFetchRecordsDelegate implements Repository
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
inner.onBatchCompleted();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositorySessionFetchRecordsDelegate deferredFetchDelegate(ExecutorService newExecutor) {
|
||||
if (newExecutor == executor) {
|
||||
|
|
|
@ -23,5 +23,11 @@ public interface RepositorySessionFetchRecordsDelegate {
|
|||
*/
|
||||
public void onFetchCompleted(final long fetchEnd);
|
||||
|
||||
public RepositorySessionFetchRecordsDelegate deferredFetchDelegate(ExecutorService executor);
|
||||
/**
|
||||
* Called when a number of records have been returned but more are still expected to come,
|
||||
* possibly after a certain pause.
|
||||
*/
|
||||
void onBatchCompleted();
|
||||
|
||||
RepositorySessionFetchRecordsDelegate deferredFetchDelegate(ExecutorService executor);
|
||||
}
|
||||
|
|
|
@ -216,6 +216,10 @@ public class RecordsChannel implements
|
|||
this.consumer.queueFilled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordStoreFailed(Exception ex, String recordGuid) {
|
||||
Logger.trace(LOG_TAG, "Failed to store record with guid " + recordGuid);
|
||||
|
|
|
@ -665,6 +665,11 @@ public class TestBookmarks extends AndroidSyncTestCase {
|
|||
public void onFetchCompleted(long end) {
|
||||
finishAndNotify(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
|
||||
}
|
||||
};
|
||||
session.fetchSince(0, fetchDelegate);
|
||||
}
|
||||
|
@ -695,6 +700,11 @@ public class TestBookmarks extends AndroidSyncTestCase {
|
|||
public void onFetchCompleted(long end) {
|
||||
finishAndNotify(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
|
||||
}
|
||||
};
|
||||
try {
|
||||
session.fetch(new String[] { guid }, fetchDelegate);
|
||||
|
|
|
@ -104,8 +104,18 @@ public class TestStoreTracking extends AndroidSyncTestCase {
|
|||
performNotify(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
|
||||
}
|
||||
});
|
||||
} catch (InactiveSessionException e) {
|
||||
performNotify(e);
|
||||
|
@ -156,6 +166,11 @@ public class TestStoreTracking extends AndroidSyncTestCase {
|
|||
performNotify(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -99,6 +99,11 @@ public class DefaultFetchDelegate extends DefaultDelegate implements RepositoryS
|
|||
Logger.debug(LOG_TAG, "onFetchCompleted. Doing nothing.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
Logger.debug(LOG_TAG, "onBatchCompleted. Doing nothing.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositorySessionFetchRecordsDelegate deferredFetchDelegate(final ExecutorService executor) {
|
||||
return new DeferredRepositorySessionFetchRecordsDelegate(this, executor);
|
||||
|
|
|
@ -54,6 +54,11 @@ public class SynchronizerHelpers {
|
|||
delegate.onFetchCompleted(fetchEnd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositorySessionFetchRecordsDelegate deferredFetchDelegate(ExecutorService executor) {
|
||||
return this;
|
||||
|
|
|
@ -37,6 +37,11 @@ public class ExpectSuccessRepositorySessionFetchRecordsDelegate extends
|
|||
performNotify();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
log("Batch completed.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositorySessionFetchRecordsDelegate deferredFetchDelegate(ExecutorService executor) {
|
||||
return this;
|
||||
|
|
|
@ -86,6 +86,11 @@ public class BatchingDownloaderDelegateTest {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositorySessionFetchRecordsDelegate deferredFetchDelegate(ExecutorService executor) {
|
||||
return null;
|
||||
|
|
|
@ -52,6 +52,7 @@ public class BatchingDownloaderTest {
|
|||
public boolean isFailure;
|
||||
public boolean isFetched;
|
||||
public boolean isSuccess;
|
||||
public int batchesCompleted;
|
||||
public Exception ex;
|
||||
public Record record;
|
||||
|
||||
|
@ -73,6 +74,11 @@ public class BatchingDownloaderTest {
|
|||
this.isSuccess = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchCompleted() {
|
||||
this.batchesCompleted += 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositorySessionFetchRecordsDelegate deferredFetchDelegate(ExecutorService executor) {
|
||||
return null;
|
||||
|
|
Загрузка…
Ссылка в новой задаче