Bug 726054 - Desktop parity: track last sync time from final upload, not final fetch. r=nalexander

This commit is contained in:
Richard Newman
2012-02-15 22:05:53 -08:00
parent ec77ce433e
commit ddcce24b1c
11 changed files with 86 additions and 40 deletions

View File

@@ -66,8 +66,15 @@ implements RecordsChannelDelegate,
private RepositorySession sessionB;
private RepositorySessionBundle bundleA;
private RepositorySessionBundle bundleB;
// Bug 726054: just like desktop, we track our last interaction with the server,
// not the last record timestamp that we fetched. This ensures that we don't re-
// download the records we just uploaded, at the cost of skipping any records
// that a concurrently syncing client has uploaded.
private long pendingATimestamp = -1;
private long pendingBTimestamp = -1;
private long storeEndATimestamp = -1;
private long storeEndBTimestamp = -1;
private boolean flowAToBCompleted = false;
private boolean flowBToACompleted = false;
@@ -133,9 +140,11 @@ implements RecordsChannelDelegate,
// TODO: failed record handling.
final RecordsChannel channelBToA = new RecordsChannel(this.sessionB, this.sessionA, this);
RecordsChannelDelegate channelDelegate = new RecordsChannelDelegate() {
public void onFlowCompleted(RecordsChannel recordsChannel, long end) {
info("First RecordsChannel flow completed. End is " + end + ". Starting next.");
pendingATimestamp = end;
public void onFlowCompleted(RecordsChannel recordsChannel, long fetchEnd, long storeEnd) {
info("First RecordsChannel flow completed. Fetch end is " + fetchEnd +
". Store end is " + storeEnd + ". Starting next.");
pendingATimestamp = fetchEnd;
storeEndBTimestamp = storeEnd;
flowAToBCompleted = true;
channelBToA.flow();
}
@@ -165,9 +174,12 @@ implements RecordsChannelDelegate,
}
@Override
public void onFlowCompleted(RecordsChannel channel, long end) {
info("Second RecordsChannel flow completed. End is " + end + ". Finishing.");
pendingBTimestamp = end;
public void onFlowCompleted(RecordsChannel channel, long fetchEnd, long storeEnd) {
info("Second RecordsChannel flow completed. Fetch end is " + fetchEnd +
". Store end is " + storeEnd + ". Finishing.");
pendingBTimestamp = fetchEnd;
storeEndATimestamp = storeEnd;
flowBToACompleted = true;
// Finish the two sessions.
@@ -278,8 +290,8 @@ implements RecordsChannelDelegate,
if (session == sessionA) {
if (flowAToBCompleted) {
info("onFinishSucceeded: bumping session A's timestamp to " + pendingATimestamp);
bundle.bumpTimestamp(pendingATimestamp);
info("onFinishSucceeded: bumping session A's timestamp to " + pendingATimestamp + " or " + storeEndATimestamp);
bundle.bumpTimestamp(Math.max(pendingATimestamp, storeEndATimestamp));
this.synchronizer.bundleA = bundle;
}
if (this.sessionB != null) {
@@ -289,8 +301,8 @@ implements RecordsChannelDelegate,
}
} else if (session == sessionB) {
if (flowBToACompleted) {
info("onFinishSucceeded: bumping session B's timestamp to " + pendingBTimestamp);
bundle.bumpTimestamp(pendingBTimestamp);
info("onFinishSucceeded: bumping session B's timestamp to " + pendingBTimestamp + " or " + storeEndBTimestamp);
bundle.bumpTimestamp(Math.max(pendingBTimestamp, storeEndBTimestamp));
this.synchronizer.bundleB = bundle;
info("Notifying delegate.onSynchronized.");
this.delegate.onSynchronized(this);