Bug 504256 - sync should observe idle service and only sync when the user is idle

Detect if the user has been recently active, and if so, skip the sync. Arbitrarily picking 30 seconds for now.
This commit is contained in:
Edward Lee 2009-07-17 16:55:15 -07:00
parent 2f261f5115
commit c5690e2288
2 changed files with 8 additions and 0 deletions

View File

@ -794,6 +794,13 @@ WeaveSvc.prototype = {
*/
sync: function WeaveSvc_sync(fullSync)
this._catch(this._lock(this._notify("sync", "", function() {
// Skip this incremental sync if the user has been active recently
if (!fullSync && Svc.Idle.idleTime < 30000) {
this._log.debug("Skipped sync because the user was active.");
return;
}
fullSync = true; // not doing thresholds yet
// Use thresholds to determine what to sync only if it's not a full sync

View File

@ -719,6 +719,7 @@ Svc.Prefs = new Preferences(PREFS_BRANCH);
["Bookmark", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService"],
["Crypto", "@labs.mozilla.com/Weave/Crypto;1", "IWeaveCrypto"],
["Directory", "@mozilla.org/file/directory_service;1", "nsIProperties"],
["Idle", "@mozilla.org/widget/idleservice;1", "nsIIdleService"],
["IO", "@mozilla.org/network/io-service;1", "nsIIOService"],
["Login", "@mozilla.org/login-manager;1", "nsILoginManager"],
["Memory", "@mozilla.org/xpcom/memory-service;1", "nsIMemory"],