mobile/android/base/sync/repositories/StoreTracker.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 package org.mozilla.gecko.sync.repositories;
michael@0 6
michael@0 7 import java.util.Iterator;
michael@0 8
michael@0 9 /**
michael@0 10 * Our hacky version of transactional semantics. The goal is to prevent
michael@0 11 * the following situation:
michael@0 12 *
michael@0 13 * * AAA is not modified locally.
michael@0 14 * * A modified AAA is downloaded during the storing phase. Its local
michael@0 15 * timestamp is advanced.
michael@0 16 * * The direction of syncing changes, and AAA is now uploaded to the server.
michael@0 17 *
michael@0 18 * The following situation should still be supported:
michael@0 19 *
michael@0 20 * * AAA is not modified locally.
michael@0 21 * * A modified AAA is downloaded and merged with the local AAA.
michael@0 22 * * The merged AAA is uploaded to the server.
michael@0 23 *
michael@0 24 * As should:
michael@0 25 *
michael@0 26 * * AAA is modified locally.
michael@0 27 * * A modified AAA is downloaded, and discarded or merged.
michael@0 28 * * The current version of AAA is uploaded to the server.
michael@0 29 *
michael@0 30 * We achieve this by tracking GUIDs during the storing phase. If we
michael@0 31 * apply a record such that the local copy is substantially the same
michael@0 32 * as the record we just downloaded, we add it to a list of records
michael@0 33 * to avoid uploading. The definition of "substantially the same"
michael@0 34 * depends on the particular repository. The only consideration is "do we
michael@0 35 * want to upload this record in this sync?".
michael@0 36 *
michael@0 37 * Note that items are removed from this list when a fetch that
michael@0 38 * considers them for upload completes successfully. The entire list
michael@0 39 * is discarded when the session is completed.
michael@0 40 *
michael@0 41 * This interface exposes methods to:
michael@0 42 *
michael@0 43 * * During a store, recording that a record has been stored, and should
michael@0 44 * thus not be returned in subsequent fetches;
michael@0 45 * * During a fetch, checking whether a record should be returned.
michael@0 46 *
michael@0 47 * In the future this might also grow self-persistence.
michael@0 48 *
michael@0 49 * See also RepositorySession.trackRecord.
michael@0 50 *
michael@0 51 * @author rnewman
michael@0 52 *
michael@0 53 */
michael@0 54 public interface StoreTracker {
michael@0 55
michael@0 56 /**
michael@0 57 * @param guid
michael@0 58 * The GUID of the item to track.
michael@0 59 * @return
michael@0 60 * Whether the GUID was a newly tracked value.
michael@0 61 */
michael@0 62 public boolean trackRecordForExclusion(String guid);
michael@0 63
michael@0 64 /**
michael@0 65 * @param guid
michael@0 66 * The GUID of the item to check.
michael@0 67 * @return
michael@0 68 * true if the item is already tracked.
michael@0 69 */
michael@0 70 public boolean isTrackedForExclusion(String guid);
michael@0 71
michael@0 72 /**
michael@0 73 *
michael@0 74 * @param guid
michael@0 75 * @return true if the specified GUID was removed from the tracked set.
michael@0 76 */
michael@0 77 public boolean untrackStoredForExclusion(String guid);
michael@0 78
michael@0 79 public RecordFilter getFilter();
michael@0 80
michael@0 81 public Iterator<String> recordsTrackedForExclusion();
michael@0 82 }

mercurial