Bug 518972 - Only upload history records that have more than one visit

Allow each engine to provide a custom Collection object and have History provide a collection that filters out certain data. This is inefficient because we have to first create then encrypt the record before we can filter it out.
This commit is contained in:
Edward Lee 2009-09-25 16:52:12 -07:00
parent 51a7e2fb0b
commit 4f389c5c8a
2 changed files with 22 additions and 1 deletions

View File

@ -331,6 +331,10 @@ SyncEngine.prototype = {
this._toFetch = o));
},
_makeUploadColl: function _makeUploadColl() {
return new Collection(this.engineURL);
},
// Create a new record by querying the store, and add the engine metadata
_createRecord: function SyncEngine__createRecord(id) {
return this._store.createRecord(id, this.cryptoMetaURL);
@ -580,7 +584,7 @@ SyncEngine.prototype = {
this._log.debug("Preparing " + outnum + " outgoing records");
// collection we'll upload
let up = new Collection(this.engineURL);
let up = this._makeUploadColl();
let count = 0;
// Upload what we've got so far in the collection

View File

@ -87,6 +87,19 @@ HistoryEngine.prototype = {
_findDupe: function _findDupe(item) {
return GUIDForUri(item.histUri);
},
_makeUploadColl: function _makeUploadColl() {
let coll = SyncEngine.prototype._makeUploadColl.call(this);
let origPush = coll.pushData;
// Only push the data for upload if it has more than 1 visit
coll.pushData = function(data) {
if (data._visitCount > 1)
origPush.call(coll, data);
};
return coll;
}
};
@ -255,6 +268,10 @@ HistoryStore.prototype = {
record.title = foo.title;
record.visits = this._getVisits(record.histUri);
record.encryption = cryptoMetaURL;
// XXX Add a value to the object so that pushData can read out, but we end
// up encrypting the data before calling pushData :(
record._visitCount = record.visits.length;
}
else
record.deleted = true;