mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 22:04:36 +00:00
bug 518075 - tweak original patch and item values
This commit is contained in:
parent
31cfd43156
commit
516a5f8953
@ -56,6 +56,11 @@ MULTI_DESKTOP_SYNC: 60 * 60 * 1000, // 1 hour
|
||||
MULTI_MOBILE_SYNC: 5 * 60 * 1000, // 5 minutes
|
||||
PARTIAL_DATA_SYNC: 60 * 1000, // 1 minute
|
||||
|
||||
// score thresholds for early syncs
|
||||
SINGLE_USER_THRESHOLD: 100,
|
||||
MULTI_DESKTOP_THRESHOLD: 500,
|
||||
MULTI_MOBILE_THRESHOLD: 1000,
|
||||
|
||||
// File IO Flags
|
||||
MODE_RDONLY: 0x01,
|
||||
MODE_WRONLY: 0x02,
|
||||
|
@ -969,7 +969,7 @@ BookmarksTracker.prototype = {
|
||||
|
||||
/* Every add/remove/change is worth 10 points */
|
||||
_upScore: function BMT__upScore() {
|
||||
this._score += 10;
|
||||
this.score += 10;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -281,7 +281,7 @@ CookieTracker.prototype = {
|
||||
|
||||
_init: function CT__init() {
|
||||
this._log = Log4Moz.Service.getLogger("Service." + this._logName);
|
||||
this._score = 0;
|
||||
this.score = 0;
|
||||
/* cookieService can't register observers, but what we CAN do is
|
||||
register a general observer with the global observerService
|
||||
to watch for the 'cookie-changed' message. */
|
||||
@ -299,9 +299,9 @@ CookieTracker.prototype = {
|
||||
var newCookie = aSubject.QueryInterface( Ci.nsICookie2 );
|
||||
if ( newCookie ) {
|
||||
if ( !newCookie.isSession ) {
|
||||
/* Any modification to a persistent cookie is worth
|
||||
10 points out of 100. Ignore session cookies. */
|
||||
this._score += 10;
|
||||
/* Any modification to a persistent cookie is worth
|
||||
10 points out of 100. Ignore session cookies. */
|
||||
this.score += 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ FormTracker.prototype = {
|
||||
|
||||
this._log.trace("Logging form element: " + name + " :: " + el.value);
|
||||
this.addChangedID(Utils.sha1(name + el.value));
|
||||
this._score += 10;
|
||||
this.score += 10;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -321,7 +321,7 @@ HistoryTracker.prototype = {
|
||||
* Clearing the whole history is worth 50 points (see below)
|
||||
*/
|
||||
_upScore: function BMT__upScore() {
|
||||
this._score += 1;
|
||||
this.score += 1;
|
||||
},
|
||||
|
||||
onVisit: function HT_onVisit(uri, vid, time, session, referrer, trans) {
|
||||
@ -337,6 +337,6 @@ HistoryTracker.prototype = {
|
||||
},
|
||||
onClearHistory: function HT_onClearHistory() {
|
||||
this._log.trace("onClearHistory");
|
||||
this._score += 50;
|
||||
this.score += 500;
|
||||
}
|
||||
};
|
||||
|
@ -238,13 +238,13 @@ PasswordTracker.prototype = {
|
||||
case 'addLogin':
|
||||
case 'removeLogin':
|
||||
aSubject.QueryInterface(Ci.nsILoginMetaInfo);
|
||||
this._score += 15;
|
||||
this.score += 15;
|
||||
this._log.trace(aData + ": " + aSubject.guid);
|
||||
this.addChangedID(aSubject.guid);
|
||||
break;
|
||||
case 'removeAllLogins':
|
||||
this._log.trace(aData);
|
||||
this._score += 50;
|
||||
this.score += 500;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ PrefTracker.prototype = {
|
||||
return;
|
||||
|
||||
if (this._syncPrefs.indexOf(aData) != -1) {
|
||||
this._score += 25;
|
||||
this.score += 1;
|
||||
this.addChangedID(WEAVE_PREFS_GUID);
|
||||
this._log.trace("Preference " + aData + " changed");
|
||||
}
|
||||
|
@ -426,12 +426,12 @@ TabTracker.prototype = {
|
||||
this._log.trace("Tab opened.");
|
||||
event.target.setAttribute(TAB_TIME_ATTR, event.timeStamp);
|
||||
//this._log.debug("Tab timestamp set to " + event.target.getAttribute(TAB_TIME_ATTR) + "\n");
|
||||
this._score += 50;
|
||||
this.score += 1;
|
||||
},
|
||||
|
||||
onTabClosed: function TabTracker_onTabSelected(event) {
|
||||
//this._log.trace("Tab closed.\n");
|
||||
this._score += 10;
|
||||
this.score += 1;
|
||||
},
|
||||
|
||||
onTabSelected: function TabTracker_onTabSelected(event) {
|
||||
@ -440,14 +440,14 @@ TabTracker.prototype = {
|
||||
//this._log.trace("Tab selected.\n");
|
||||
event.target.setAttribute(TAB_TIME_ATTR, event.timeStamp);
|
||||
//this._log.debug("Tab timestamp set to " + event.target.getAttribute(TAB_TIME_ATTR) + "\n");
|
||||
this._score += 10;
|
||||
this.score += 1;
|
||||
},
|
||||
// TODO: Also listen for tabs loading new content?
|
||||
|
||||
get changedIDs() {
|
||||
// Only mark the current client as changed if we tracked changes
|
||||
let obj = {};
|
||||
if (this._score > 0)
|
||||
if (this.score > 0)
|
||||
obj[Clients.clientID] = true;
|
||||
return obj;
|
||||
}
|
||||
|
@ -189,6 +189,12 @@ WeaveSvc.prototype = {
|
||||
},
|
||||
set syncInterval(value) Svc.Prefs.set("syncInterval", value),
|
||||
|
||||
get syncThreshold() Svc.Prefs.get("syncThreshold", SINGLE_USER_THRESHOLD),
|
||||
set syncThreshold(value) Svc.Prefs.set("nextSync", value),
|
||||
|
||||
get globalScore() Svc.Prefs.get("globalScore", 0),
|
||||
set globalScore(value) Svc.Prefs.set("globalScore", value),
|
||||
|
||||
get numClients() Svc.Prefs.get("numClients", 0),
|
||||
set numClients(value) Svc.Prefs.set("numClients", value),
|
||||
|
||||
@ -293,6 +299,7 @@ WeaveSvc.prototype = {
|
||||
Svc.Observer.addObserver(this, "weave:service:sync:finish", true);
|
||||
Svc.Observer.addObserver(this, "weave:service:sync:error", true);
|
||||
Svc.Observer.addObserver(this, "weave:service:backoff:interval", true);
|
||||
Svc.Observer.addObserver(this, "weave:engine:score:updated", true);
|
||||
|
||||
if (!this.enabled)
|
||||
this._log.info("Weave Sync disabled");
|
||||
@ -404,6 +411,9 @@ WeaveSvc.prototype = {
|
||||
Status.backoffInterval = interval;
|
||||
Status.minimumNextSync = Date.now() + data;
|
||||
break;
|
||||
case "weave:engine:score:updated":
|
||||
this._handleScoreUpdate();
|
||||
break;
|
||||
case "idle":
|
||||
this._log.trace("Idle time hit, trying to sync");
|
||||
Svc.Idle.removeIdleObserver(this, IDLE_TIME);
|
||||
@ -412,7 +422,35 @@ WeaveSvc.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_onQuitApplication: function WeaveSvc__onQuitApplication() {
|
||||
_doGS: function () {
|
||||
this._scoreTimer = null;
|
||||
this._calculateScore();
|
||||
},
|
||||
|
||||
_handleScoreUpdate: function WeaveSvc__handleScoreUpdate() {
|
||||
const SCORE_UPDATE_DELAY = 3000;
|
||||
if (this._scoreTimer) {
|
||||
this._scoreTimer.delay = SCORE_UPDATE_DELAY;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
Utils.delay(function() this._doGS(), SCORE_UPDATE_DELAY, this, "_scoreTimer");
|
||||
}
|
||||
},
|
||||
|
||||
_calculateScore: function WeaveSvc_calculateScoreAndDoStuff() {
|
||||
var engines = Engines.getEnabled();
|
||||
for (let i = 0;i < engines.length;i++) {
|
||||
this.globalScore += engines[i].score;
|
||||
this._log.debug(engines[i].name + ": score: " + engines[i].score);
|
||||
}
|
||||
|
||||
if (this.globalScore > this.syncThreshold) {
|
||||
this._log.debug("Global Score threshold hit, triggering sync.");
|
||||
this.syncOnIdle();
|
||||
}
|
||||
else if (!this._syncTimer) // start the clock if it isn't already
|
||||
this._scheduleNextSync();
|
||||
},
|
||||
|
||||
// These are global (for all engines)
|
||||
@ -1045,6 +1083,7 @@ WeaveSvc.prototype = {
|
||||
|
||||
// Clear out any potentially pending syncs now that we're syncing
|
||||
this._clearSyncTriggers();
|
||||
this.globalScore = 0;
|
||||
this.nextSync = 0;
|
||||
|
||||
if (!(this._remoteSetup()))
|
||||
@ -1127,6 +1166,7 @@ WeaveSvc.prototype = {
|
||||
let tabEngine = Engines.get("tabs");
|
||||
if (numClients == 1) {
|
||||
this.syncInterval = SINGLE_USER_SYNC;
|
||||
this.syncThreshold = SINGLE_USER_THRESHOLD;
|
||||
|
||||
// Disable tabs sync for single client, but store the original value
|
||||
Svc.Prefs.set("engine.tabs.backup", tabEngine.enabled);
|
||||
@ -1134,6 +1174,7 @@ WeaveSvc.prototype = {
|
||||
}
|
||||
else {
|
||||
this.syncInterval = hasMobile ? MULTI_MOBILE_SYNC : MULTI_DESKTOP_SYNC;
|
||||
this.syncThreshold = hasMobile ? MULTI_MOBILE_THRESHOLD : MULTI_DESKTOP_THRESHOLD;
|
||||
|
||||
// Restore the original tab enabled value
|
||||
tabEngine.enabled = Svc.Prefs.get("engine.tabs.backup", true);
|
||||
|
@ -45,6 +45,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://weave/log4moz.js");
|
||||
Cu.import("resource://weave/constants.js");
|
||||
Cu.import("resource://weave/util.js");
|
||||
Cu.import("resource://weave/ext/Observers.js");
|
||||
|
||||
/*
|
||||
* Trackers are associated with a single engine and deal with
|
||||
@ -86,10 +87,12 @@ Tracker.prototype = {
|
||||
* Setting it to other values should (but doesn't currently) throw an exception
|
||||
*/
|
||||
get score() {
|
||||
if (this._score >= 100)
|
||||
return 100;
|
||||
else
|
||||
return this._score;
|
||||
return this._score;
|
||||
},
|
||||
|
||||
set score(value) {
|
||||
this._score = value;
|
||||
Observers.notify("weave:engine:score:updated", this.name);
|
||||
},
|
||||
|
||||
// Should be called by service everytime a sync has been done for an engine
|
||||
|
Loading…
x
Reference in New Issue
Block a user