зеркало из https://github.com/mozilla/pjs.git
Bug 419832 ? Change Livemark service update timings (for mak77@supereva.it, r=dietrich)
This commit is contained in:
Родитель
082a378ad3
Коммит
ba145caf90
|
@ -25,6 +25,7 @@
|
||||||
* Masayuki Nakano <masayuki@d-toybox.com>
|
* Masayuki Nakano <masayuki@d-toybox.com>
|
||||||
* Robert Sayre <sayrer@gmail.com> (JS port)
|
* Robert Sayre <sayrer@gmail.com> (JS port)
|
||||||
* Phil Ringnalda <philringnalda@gmail.com>
|
* Phil Ringnalda <philringnalda@gmail.com>
|
||||||
|
* Marco Bonardo <mak77@supereva.it>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the
|
* Alternatively, the contents of this file may be used under the
|
||||||
* terms of either the GNU General Public License Version 2 or later
|
* terms of either the GNU General Public License Version 2 or later
|
||||||
|
@ -58,7 +59,6 @@ const LS_CLASSID = Components.ID("{dca61eb5-c7cd-4df1-b0fb-d0722baba251}");
|
||||||
const LS_CLASSNAME = "Livemark Service";
|
const LS_CLASSNAME = "Livemark Service";
|
||||||
const LS_CONTRACTID = "@mozilla.org/browser/livemark-service;2";
|
const LS_CONTRACTID = "@mozilla.org/browser/livemark-service;2";
|
||||||
|
|
||||||
const LIVEMARK_TIMEOUT = 15000; // fire every 15 seconds
|
|
||||||
const PLACES_BUNDLE_URI = "chrome://places/locale/places.properties";
|
const PLACES_BUNDLE_URI = "chrome://places/locale/places.properties";
|
||||||
const DEFAULT_LOAD_MSG = "Live Bookmark loading...";
|
const DEFAULT_LOAD_MSG = "Live Bookmark loading...";
|
||||||
const DEFAULT_FAIL_MSG = "Live Bookmark feed failed to load.";
|
const DEFAULT_FAIL_MSG = "Live Bookmark feed failed to load.";
|
||||||
|
@ -82,15 +82,19 @@ const IS_CONTRACTID = "@mozilla.org/widget/idleservice;1";
|
||||||
const SEC_FLAGS = Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL;
|
const SEC_FLAGS = Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL;
|
||||||
const NS_BINDING_ABORTED = 0x804b0002;
|
const NS_BINDING_ABORTED = 0x804b0002;
|
||||||
|
|
||||||
// Check every hour by default
|
// Expire livemarks after 1 hour by default
|
||||||
var gExpiration = 3600000;
|
var gExpiration = 3600000;
|
||||||
|
|
||||||
// Check every 10 minutes on error
|
// Expire livemarks after 10 minutes on error
|
||||||
const ERROR_EXPIRATION = 600000;
|
const ERROR_EXPIRATION = 600000;
|
||||||
|
|
||||||
// Don't check when the user is idle for longer than half an hour:
|
// Don't check when the user is idle for longer than half an hour
|
||||||
const IDLE_TIMELIMIT = 1800000;
|
const IDLE_TIMELIMIT = 1800000;
|
||||||
|
|
||||||
|
// We should check for expiration _at least_ every hour
|
||||||
|
// This cap is used only if the user sets a very high expiration time (>4h)
|
||||||
|
const MAX_REFRESH_TIME = 3600000;
|
||||||
|
|
||||||
var gIoService = Cc[IO_CONTRACTID].getService(Ci.nsIIOService);
|
var gIoService = Cc[IO_CONTRACTID].getService(Ci.nsIIOService);
|
||||||
var gStringBundle;
|
var gStringBundle;
|
||||||
function GetString(name)
|
function GetString(name)
|
||||||
|
@ -183,18 +187,24 @@ LivemarkService.prototype = {
|
||||||
start: function LS_start() {
|
start: function LS_start() {
|
||||||
if (this._updateTimer)
|
if (this._updateTimer)
|
||||||
return;
|
return;
|
||||||
this._updateTimer = new G_Alarm(BindToObject(this._fireTimer, this),
|
// start is called in delayed startup, 5s after browser startup
|
||||||
LIVEMARK_TIMEOUT, true /* repeat */);
|
// we do a first check of the livemarks here, next checks will be on timer
|
||||||
|
// browser start => 5s => this.start() => check => refresh_time => check
|
||||||
|
this._checkAllLivemarks();
|
||||||
|
// the refresh time is calculated from the expiration time, but with a cap
|
||||||
|
var refresh_time = Math.min(Math.floor(gExpiration / 4), MAX_REFRESH_TIME);
|
||||||
|
this._updateTimer = new G_Alarm(BindToObject(this._checkAllLivemarks, this),
|
||||||
|
refresh_time, true /* repeat */);
|
||||||
},
|
},
|
||||||
|
|
||||||
// returns new length of _livemarks
|
_pushLivemark: function LS__pushLivemark(aFolderId, aFeedURI) {
|
||||||
_pushLivemark: function LS__pushLivemark(folderId, feedURI) {
|
// returns new length of _livemarks
|
||||||
return this._livemarks.push({folderId: folderId, feedURI: feedURI});
|
return this._livemarks.push({folderId: aFolderId, feedURI: aFeedURI});
|
||||||
},
|
},
|
||||||
|
|
||||||
_getLivemarkIndex: function LS__getLivemarkIndex(folderId) {
|
_getLivemarkIndex: function LS__getLivemarkIndex(aFolderId) {
|
||||||
for (var i=0; i < this._livemarks.length; ++i) {
|
for (var i = 0; i < this._livemarks.length; ++i) {
|
||||||
if (this._livemarks[i].folderId == folderId)
|
if (this._livemarks[i].folderId == aFolderId)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
throw Cr.NS_ERROR_INVALID_ARG;
|
throw Cr.NS_ERROR_INVALID_ARG;
|
||||||
|
@ -216,52 +226,54 @@ LivemarkService.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_fireTimer: function LS__fireTimer() {
|
_checkAllLivemarks: function LS__checkAllLivemarks() {
|
||||||
for (var i=0; i < this._livemarks.length; ++i) {
|
// check if livemarks are expired, update if needed
|
||||||
|
for (var i = 0; i < this._livemarks.length; ++i) {
|
||||||
this._updateLivemarkChildren(i, false);
|
this._updateLivemarkChildren(i, false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteLivemarkChildren: function LS_deleteLivemarkChildren(folderId) {
|
deleteLivemarkChildren: function LS_deleteLivemarkChildren(aFolderId) {
|
||||||
this._bms.removeFolderChildren(folderId);
|
this._bms.removeFolderChildren(aFolderId);
|
||||||
},
|
},
|
||||||
|
|
||||||
insertLivemarkLoadingItem: function LS_insertLivemarkLoading(bms, livemark) {
|
insertLivemarkLoadingItem: function LS_insertLivemarkLoading(aBms, aLivemark) {
|
||||||
var loadingURI = gIoService.newURI("about:livemark-loading", null, null);
|
var loadingURI = gIoService.newURI("about:livemark-loading", null, null);
|
||||||
if (!livemark.loadingId || livemark.loadingId == -1)
|
if (!aLivemark.loadingId || aLivemark.loadingId == -1)
|
||||||
livemark.loadingId = bms.insertBookmark(livemark.folderId, loadingURI,
|
aLivemark.loadingId = aBms.insertBookmark(aLivemark.folderId, loadingURI,
|
||||||
0, this._loading);
|
0, this._loading);
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateLivemarkChildren:
|
_updateLivemarkChildren:
|
||||||
function LS__updateLivemarkChildren(index, forceUpdate) {
|
function LS__updateLivemarkChildren(aIndex, aForceUpdate) {
|
||||||
if (this._livemarks[index].locked)
|
if (this._livemarks[aIndex].locked)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var livemark = this._livemarks[index];
|
var livemark = this._livemarks[aIndex];
|
||||||
livemark.locked = true;
|
livemark.locked = true;
|
||||||
try {
|
try {
|
||||||
// Check the TTL/expiration on this. If there isn't one,
|
// Check the TTL/expiration on this. If there isn't one,
|
||||||
// then we assume it's never been loaded. We perform this
|
// then we assume it's never been loaded. We perform this
|
||||||
// check even when the update is being forced, in case the
|
// check even when the update is being forced, in case the
|
||||||
// livemark has somehow never been loaded.
|
// livemark has somehow never been loaded.
|
||||||
var exprTime = this._ans.getPageAnnotation(livemark.feedURI,
|
var expireTime = this._ans.getItemAnnotation(livemark.folderId,
|
||||||
LMANNO_EXPIRATION);
|
LMANNO_EXPIRATION);
|
||||||
if (!forceUpdate && exprTime > Date.now()) {
|
if (!aForceUpdate && expireTime > Date.now()) {
|
||||||
// no need to refresh
|
// no need to refresh
|
||||||
livemark.locked = false;
|
livemark.locked = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the user idle time. If the user isn't using their computer, don't
|
// Check the user idle time.
|
||||||
// bother updating - save the internet some bandwidth. If we can't
|
// If the user is away from the computer, don't bother updating,
|
||||||
// get the idle time, assume the user isn't idle.
|
// so we save some bandwidth.
|
||||||
|
// If we can't get the idle time, assume the user is not idle.
|
||||||
var idleTime = 0;
|
var idleTime = 0;
|
||||||
try {
|
try {
|
||||||
idleTime = this._idleService.idleTime;
|
idleTime = this._idleService.idleTime;
|
||||||
} catch (ex) { /* We don't care */ }
|
}
|
||||||
if (idleTime > IDLE_TIMELIMIT)
|
catch (ex) { /* We don't care */ }
|
||||||
{
|
if (idleTime > IDLE_TIMELIMIT) {
|
||||||
livemark.locked = false;
|
livemark.locked = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -303,115 +315,122 @@ LivemarkService.prototype = {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
createLivemark: function LS_createLivemark(folder, name, siteURI,
|
createLivemark: function LS_createLivemark(aParentId, aName, aSiteURI,
|
||||||
feedURI, index) {
|
aFeedURI, aIndex) {
|
||||||
// Don't add livemarks to livemarks
|
// Don't add livemarks to livemarks
|
||||||
if (this.isLivemark(folder))
|
if (this.isLivemark(aParentId))
|
||||||
throw Cr.NS_ERROR_INVALID_ARG;
|
throw Cr.NS_ERROR_INVALID_ARG;
|
||||||
var livemarkID = this._createFolder(folder, name, siteURI, feedURI, index);
|
|
||||||
|
|
||||||
// kick off http fetch
|
var folderId = this._createFolder(aParentId, aName, aSiteURI,
|
||||||
this._updateLivemarkChildren(
|
aFeedURI, aIndex);
|
||||||
this._pushLivemark(livemarkID, feedURI) - 1,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
return livemarkID;
|
// do a first update of the livemark children
|
||||||
|
this._updateLivemarkChildren(this._pushLivemark(folderId, aFeedURI) - 1,
|
||||||
|
false);
|
||||||
|
|
||||||
|
return folderId;
|
||||||
},
|
},
|
||||||
|
|
||||||
createLivemarkFolderOnly:
|
createLivemarkFolderOnly:
|
||||||
function LS_createLivemarkFolderOnly(folder, name, siteURI, feedURI, index) {
|
function LS_createLivemarkFolderOnly(aParentId, aName, aSiteURI,
|
||||||
var livemarkID = this._createFolder(folder, name, siteURI, feedURI, index);
|
aFeedURI, aIndex) {
|
||||||
this._pushLivemark(livemarkID, feedURI);
|
// Don't add livemarks to livemarks
|
||||||
var livemarkIndex = this._getLivemarkIndex(livemarkID);
|
if (this.isLivemark(aParentId))
|
||||||
|
throw Cr.NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
|
var folderId = this._createFolder(aParentId, aName, aSiteURI,
|
||||||
|
aFeedURI, aIndex);
|
||||||
|
|
||||||
|
var livemarkIndex = this._pushLivemark(folderId, aFeedURI) - 1;
|
||||||
var livemark = this._livemarks[livemarkIndex];
|
var livemark = this._livemarks[livemarkIndex];
|
||||||
this.insertLivemarkLoadingItem(this._bms, livemark);
|
this.insertLivemarkLoadingItem(this._bms, livemark);
|
||||||
|
|
||||||
return livemarkID;
|
return folderId;
|
||||||
},
|
},
|
||||||
|
|
||||||
_createFolder:
|
_createFolder:
|
||||||
function LS__createFolder(folder, name, siteURI, feedURI, index) {
|
function LS__createFolder(aParentId, aName, aSiteURI, aFeedURI, aIndex) {
|
||||||
var livemarkID = this._bms.createFolder(folder, name, index);
|
var folderId = this._bms.createFolder(aParentId, aName, aIndex);
|
||||||
this._bms.setFolderReadonly(livemarkID, true);
|
this._bms.setFolderReadonly(folderId, true);
|
||||||
|
|
||||||
// Add an annotation to map the folder id to the livemark feed URI
|
// Add an annotation to map the folder id to the livemark feed URI
|
||||||
this._ans.setItemAnnotation(livemarkID, LMANNO_FEEDURI, feedURI.spec, 0,
|
this._ans.setItemAnnotation(folderId, LMANNO_FEEDURI, aFeedURI.spec, 0,
|
||||||
this._ans.EXPIRE_NEVER);
|
this._ans.EXPIRE_NEVER);
|
||||||
|
|
||||||
if (siteURI) {
|
if (aSiteURI) {
|
||||||
// Add an annotation to map the folder URI to the livemark site URI
|
// Add an annotation to map the folder URI to the livemark site URI
|
||||||
this._setSiteURISecure(livemarkID, feedURI, siteURI);
|
this._setSiteURISecure(folderId, aFeedURI, aSiteURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
return livemarkID;
|
return folderId;
|
||||||
},
|
},
|
||||||
|
|
||||||
isLivemark: function LS_isLivemark(folder) {
|
isLivemark: function LS_isLivemark(aFolderId) {
|
||||||
return this._ans.itemHasAnnotation(folder, LMANNO_FEEDURI);
|
return this._ans.itemHasAnnotation(aFolderId, LMANNO_FEEDURI);
|
||||||
},
|
},
|
||||||
|
|
||||||
_ensureLivemark: function LS__ensureLivemark(container) {
|
_ensureLivemark: function LS__ensureLivemark(aFolderId) {
|
||||||
if (!this.isLivemark(container))
|
if (!this.isLivemark(aFolderId))
|
||||||
throw Cr.NS_ERROR_INVALID_ARG;
|
throw Cr.NS_ERROR_INVALID_ARG;
|
||||||
},
|
},
|
||||||
|
|
||||||
getSiteURI: function LS_getSiteURI(container) {
|
getSiteURI: function LS_getSiteURI(aFolderId) {
|
||||||
this._ensureLivemark(container);
|
this._ensureLivemark(aFolderId);
|
||||||
|
|
||||||
if (this._ans.itemHasAnnotation(container, LMANNO_SITEURI)) {
|
if (this._ans.itemHasAnnotation(aFolderId, LMANNO_SITEURI)) {
|
||||||
var siteURIString =
|
var siteURIString =
|
||||||
this._ans.getItemAnnotation(container, LMANNO_SITEURI);
|
this._ans.getItemAnnotation(aFolderId, LMANNO_SITEURI);
|
||||||
|
|
||||||
return gIoService.newURI(siteURIString, null, null);
|
return gIoService.newURI(siteURIString, null, null);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
setSiteURI: function LS_setSiteURI(container, siteURI) {
|
setSiteURI: function LS_setSiteURI(aFolderId, aSiteURI) {
|
||||||
this._ensureLivemark(container);
|
this._ensureLivemark(aFolderId);
|
||||||
|
|
||||||
if (!siteURI) {
|
if (!aSiteURI) {
|
||||||
this._ans.removeItemAnnotation(container, LMANNO_SITEURI);
|
this._ans.removeItemAnnotation(aFolderId, LMANNO_SITEURI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var livemarkIndex = this._getLivemarkIndex(container);
|
var livemarkIndex = this._getLivemarkIndex(aFolderId);
|
||||||
var livemark = this._livemarks[livemarkIndex];
|
var livemark = this._livemarks[livemarkIndex];
|
||||||
this._setSiteURISecure(container, livemark.feedURI, siteURI);
|
this._setSiteURISecure(aFolderId, livemark.feedURI, aSiteURI);
|
||||||
},
|
},
|
||||||
|
|
||||||
_setSiteURISecure: function LS__setSiteURISecure(container, feedURI, siteURI) {
|
_setSiteURISecure:
|
||||||
|
function LS__setSiteURISecure(aFolderId, aFeedURI, aSiteURI) {
|
||||||
var secMan = Cc[SEC_CONTRACTID].getService(Ci.nsIScriptSecurityManager);
|
var secMan = Cc[SEC_CONTRACTID].getService(Ci.nsIScriptSecurityManager);
|
||||||
var feedPrincipal = secMan.getCodebasePrincipal(feedURI);
|
var feedPrincipal = secMan.getCodebasePrincipal(aFeedURI);
|
||||||
try {
|
try {
|
||||||
secMan.checkLoadURIWithPrincipal(feedPrincipal, siteURI, SEC_FLAGS);
|
secMan.checkLoadURIWithPrincipal(feedPrincipal, aSiteURI, SEC_FLAGS);
|
||||||
} catch (e) {
|
}
|
||||||
|
catch (e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._ans.setItemAnnotation(container, LMANNO_SITEURI, siteURI.spec,
|
this._ans.setItemAnnotation(aFolderId, LMANNO_SITEURI, aSiteURI.spec,
|
||||||
0, this._ans.EXPIRE_NEVER);
|
0, this._ans.EXPIRE_NEVER);
|
||||||
},
|
},
|
||||||
|
|
||||||
getFeedURI: function LS_getFeedURI(container) {
|
getFeedURI: function LS_getFeedURI(aFolderId) {
|
||||||
if (this._ans.itemHasAnnotation(container, LMANNO_FEEDURI))
|
if (this._ans.itemHasAnnotation(aFolderId, LMANNO_FEEDURI))
|
||||||
return gIoService.newURI(this._ans.getItemAnnotation(container,
|
return gIoService.newURI(this._ans.getItemAnnotation(aFolderId,
|
||||||
LMANNO_FEEDURI),
|
LMANNO_FEEDURI),
|
||||||
null, null);
|
null, null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
setFeedURI: function LS_setFeedURI(container, feedURI) {
|
setFeedURI: function LS_setFeedURI(aFolderId, aFeedURI) {
|
||||||
if (!feedURI)
|
if (!aFeedURI)
|
||||||
throw Cr.NS_ERROR_INVALID_ARG;
|
throw Cr.NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
this._ans.setItemAnnotation(container, LMANNO_FEEDURI, feedURI.spec, 0,
|
this._ans.setItemAnnotation(aFolderId, LMANNO_FEEDURI, aFeedURI.spec, 0,
|
||||||
this._ans.EXPIRE_NEVER);
|
this._ans.EXPIRE_NEVER);
|
||||||
|
|
||||||
// now update our internal table
|
// now update our internal table
|
||||||
var livemarkIndex = this._getLivemarkIndex(container);
|
var livemarkIndex = this._getLivemarkIndex(aFolderId);
|
||||||
this._livemarks[livemarkIndex].feedURI = feedURI;
|
this._livemarks[livemarkIndex].feedURI = aFeedURI;
|
||||||
},
|
},
|
||||||
|
|
||||||
reloadAllLivemarks: function LS_reloadAllLivemarks() {
|
reloadAllLivemarks: function LS_reloadAllLivemarks() {
|
||||||
|
@ -420,8 +439,8 @@ LivemarkService.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reloadLivemarkFolder: function LS_reloadLivemarkFolder(folderID) {
|
reloadLivemarkFolder: function LS_reloadLivemarkFolder(aFolderId) {
|
||||||
var livemarkIndex = this._getLivemarkIndex(folderID);
|
var livemarkIndex = this._getLivemarkIndex(aFolderId);
|
||||||
this._updateLivemarkChildren(livemarkIndex, true);
|
this._updateLivemarkChildren(livemarkIndex, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -433,7 +452,9 @@ LivemarkService.prototype = {
|
||||||
onItemVisited: function() { },
|
onItemVisited: function() { },
|
||||||
onItemMoved: function() { },
|
onItemMoved: function() { },
|
||||||
|
|
||||||
onItemRemoved: function(aItemId, aParentFolder, aIndex) {
|
onItemRemoved: function(aItemId, aParentId, aIndex) {
|
||||||
|
// we don't need to remove annotations since itemAnnotations
|
||||||
|
// are already removed with the bookmark
|
||||||
try {
|
try {
|
||||||
var livemarkIndex = this._getLivemarkIndex(aItemId);
|
var livemarkIndex = this._getLivemarkIndex(aItemId);
|
||||||
}
|
}
|
||||||
|
@ -446,38 +467,28 @@ LivemarkService.prototype = {
|
||||||
// remove the livemark from the update array
|
// remove the livemark from the update array
|
||||||
this._livemarks.splice(livemarkIndex, 1);
|
this._livemarks.splice(livemarkIndex, 1);
|
||||||
|
|
||||||
// check if we have more then one livemark for this address
|
|
||||||
// if exists we should not delete the annotation since it's still in use
|
|
||||||
var stillInUse = false;
|
|
||||||
stillInUse = this._livemarks.some(
|
|
||||||
function(mark) { return mark.feedURI.equals(livemark.feedURI) }
|
|
||||||
);
|
|
||||||
if (!stillInUse) {
|
|
||||||
this._ans.removePageAnnotation(livemark.feedURI, LMANNO_EXPIRATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (livemark.loadGroup)
|
if (livemark.loadGroup)
|
||||||
livemark.loadGroup.cancel(NS_BINDING_ABORTED);
|
livemark.loadGroup.cancel(NS_BINDING_ABORTED);
|
||||||
},
|
},
|
||||||
|
|
||||||
createInstance: function LS_createInstance(outer, iid) {
|
createInstance: function LS_createInstance(aOuter, aIID) {
|
||||||
if (outer != null)
|
if (aOuter != null)
|
||||||
throw Cr.NS_ERROR_NO_AGGREGATION;
|
throw Cr.NS_ERROR_NO_AGGREGATION;
|
||||||
return this.QueryInterface(iid);
|
return this.QueryInterface(aIID);
|
||||||
},
|
},
|
||||||
|
|
||||||
QueryInterface: function LS_QueryInterface(iid) {
|
QueryInterface: function LS_QueryInterface(aIID) {
|
||||||
if (iid.equals(Ci.nsILivemarkService) ||
|
if (aIID.equals(Ci.nsILivemarkService) ||
|
||||||
iid.equals(Ci.nsIFactory) ||
|
aIID.equals(Ci.nsIFactory) ||
|
||||||
iid.equals(Ci.nsINavBookmarkObserver) ||
|
aIID.equals(Ci.nsINavBookmarkObserver) ||
|
||||||
iid.equals(Ci.nsISupports))
|
aIID.equals(Ci.nsISupports))
|
||||||
return this;
|
return this;
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function LivemarkLoadListener(livemark) {
|
function LivemarkLoadListener(aLivemark) {
|
||||||
this._livemark = livemark;
|
this._livemark = aLivemark;
|
||||||
this._livemark.loadingId = -1;
|
this._livemark.loadingId = -1;
|
||||||
this._processor = null;
|
this._processor = null;
|
||||||
this._isAborted = false;
|
this._isAborted = false;
|
||||||
|
@ -562,7 +573,7 @@ LivemarkLoadListener.prototype = {
|
||||||
/**
|
/**
|
||||||
* See nsIFeedResultListener.idl
|
* See nsIFeedResultListener.idl
|
||||||
*/
|
*/
|
||||||
handleResult: function LLL_handleResult(result) {
|
handleResult: function LLL_handleResult(aResult) {
|
||||||
if (this._isAborted) {
|
if (this._isAborted) {
|
||||||
if (this._livemark.loadingId != -1) {
|
if (this._livemark.loadingId != -1) {
|
||||||
this._bms.removeItem(this._livemark.loadingId);
|
this._bms.removeItem(this._livemark.loadingId);
|
||||||
|
@ -574,7 +585,7 @@ LivemarkLoadListener.prototype = {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// The actual work is done in runBatched, see above.
|
// The actual work is done in runBatched, see above.
|
||||||
this._bms.runInBatchMode(this, result);
|
this._bms.runInBatchMode(this, aResult);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
this._processor.listener = null;
|
this._processor.listener = null;
|
||||||
|
@ -586,43 +597,42 @@ LivemarkLoadListener.prototype = {
|
||||||
deleteLivemarkChildren: LivemarkService.prototype.deleteLivemarkChildren,
|
deleteLivemarkChildren: LivemarkService.prototype.deleteLivemarkChildren,
|
||||||
|
|
||||||
insertLivemarkChild:
|
insertLivemarkChild:
|
||||||
function LS_insertLivemarkChild(folderId, uri, title) {
|
function LS_insertLivemarkChild(aFolderId, aUri, aTitle) {
|
||||||
var id = this._bms.insertBookmark(folderId, uri, this._bms.DEFAULT_INDEX,
|
this._bms.insertBookmark(aFolderId, aUri, this._bms.DEFAULT_INDEX, aTitle);
|
||||||
title);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See nsIStreamListener.idl
|
* See nsIStreamListener.idl
|
||||||
*/
|
*/
|
||||||
onDataAvailable: function LLL_onDataAvailable(request, context, inputStream,
|
onDataAvailable: function LLL_onDataAvailable(aRequest, aContext, aInputStream,
|
||||||
sourceOffset, count) {
|
aSourceOffset, aCount) {
|
||||||
this._processor.onDataAvailable(request, context, inputStream,
|
this._processor.onDataAvailable(aRequest, aContext, aInputStream,
|
||||||
sourceOffset, count);
|
aSourceOffset, aCount);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See nsIRequestObserver.idl
|
* See nsIRequestObserver.idl
|
||||||
*/
|
*/
|
||||||
onStartRequest: function LLL_onStartRequest(request, context) {
|
onStartRequest: function LLL_onStartRequest(aRequest, aContext) {
|
||||||
if (this._isAborted)
|
if (this._isAborted)
|
||||||
throw Cr.NS_ERROR_UNEXPECTED;
|
throw Cr.NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
var channel = request.QueryInterface(Ci.nsIChannel);
|
var channel = aRequest.QueryInterface(Ci.nsIChannel);
|
||||||
|
|
||||||
// Parse feed data as it comes in
|
// Parse feed data as it comes in
|
||||||
this._processor = Cc[FP_CONTRACTID].createInstance(Ci.nsIFeedProcessor);
|
this._processor = Cc[FP_CONTRACTID].createInstance(Ci.nsIFeedProcessor);
|
||||||
this._processor.listener = this;
|
this._processor.listener = this;
|
||||||
this._processor.parseAsync(null, channel.URI);
|
this._processor.parseAsync(null, channel.URI);
|
||||||
|
|
||||||
this._processor.onStartRequest(request, context);
|
this._processor.onStartRequest(aRequest, aContext);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See nsIRequestObserver.idl
|
* See nsIRequestObserver.idl
|
||||||
*/
|
*/
|
||||||
onStopRequest: function LLL_onStopRequest(request, context, status) {
|
onStopRequest: function LLL_onStopRequest(aRequest, aContext, aStatus) {
|
||||||
if (!Components.isSuccessCode(status)) {
|
if (!Components.isSuccessCode(aStatus)) {
|
||||||
// Something went wrong; try to load again in a bit
|
// Something went wrong, try to load again in a bit
|
||||||
this._setResourceTTL(ERROR_EXPIRATION);
|
this._setResourceTTL(ERROR_EXPIRATION);
|
||||||
this._isAborted = true;
|
this._isAborted = true;
|
||||||
if (this._livemark.loadingId != -1) {
|
if (this._livemark.loadingId != -1) {
|
||||||
|
@ -635,21 +645,21 @@ LivemarkLoadListener.prototype = {
|
||||||
}
|
}
|
||||||
// Set an expiration on the livemark, for reloading the data
|
// Set an expiration on the livemark, for reloading the data
|
||||||
try {
|
try {
|
||||||
this._processor.onStopRequest(request, context, status);
|
this._processor.onStopRequest(aRequest, aContext, aStatus);
|
||||||
|
|
||||||
// Calculate a new ttl
|
// Calculate a new ttl
|
||||||
var channel = request.QueryInterface(Ci.nsICachingChannel);
|
var channel = aRequest.QueryInterface(Ci.nsICachingChannel);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
var entryInfo = channel.cacheToken.QueryInterface(Ci.nsICacheEntryInfo);
|
var entryInfo = channel.cacheToken.QueryInterface(Ci.nsICacheEntryInfo);
|
||||||
if (entryInfo) {
|
if (entryInfo) {
|
||||||
// nsICacheEntryInfo returns value as seconds,
|
// nsICacheEntryInfo returns value as seconds,
|
||||||
// expiresTime stores as ms
|
// expireTime stores as milliseconds
|
||||||
var expiresTime = entryInfo.expirationTime * 1000;
|
var expireTime = entryInfo.expirationTime * 1000;
|
||||||
var nowTime = Date.now();
|
var nowTime = Date.now();
|
||||||
|
|
||||||
// note, expiresTime can be 0, see bug #383538
|
// note, expireTime can be 0, see bug 383538
|
||||||
if (expiresTime > nowTime) {
|
if (expireTime > nowTime) {
|
||||||
this._setResourceTTL(Math.max((expiresTime - nowTime),
|
this._setResourceTTL(Math.max((expireTime - nowTime),
|
||||||
gExpiration));
|
gExpiration));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -660,53 +670,53 @@ LivemarkLoadListener.prototype = {
|
||||||
this._setResourceTTL(this._ttl);
|
this._setResourceTTL(this._ttl);
|
||||||
},
|
},
|
||||||
|
|
||||||
_setResourceTTL: function LLL__setResourceTTL(milliseconds) {
|
_setResourceTTL: function LLL__setResourceTTL(aMilliseconds) {
|
||||||
var exptime = Date.now() + milliseconds;
|
var expireTime = Date.now() + aMilliseconds;
|
||||||
this._ans.setPageAnnotation(this._livemark.feedURI, LMANNO_EXPIRATION,
|
this._ans.setItemAnnotation(this._livemark.folderId, LMANNO_EXPIRATION,
|
||||||
exptime, 0,
|
expireTime, 0,
|
||||||
Ci.nsIAnnotationService.EXPIRE_NEVER);
|
Ci.nsIAnnotationService.EXPIRE_NEVER);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See nsIBadCertListener2
|
* See nsIBadCertListener2
|
||||||
*/
|
*/
|
||||||
notifyCertProblem: function LLL_certProblem(socketInfo, status, targetSite) {
|
notifyCertProblem: function LLL_certProblem(aSocketInfo, aStatus, aTargetSite) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See nsISSLErrorListener
|
* See nsISSLErrorListener
|
||||||
*/
|
*/
|
||||||
notifySSLError: function LLL_SSLError(socketInfo, error, targetSite) {
|
notifySSLError: function LLL_SSLError(aSocketInfo, aError, aTargetSite) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See nsIInterfaceRequestor
|
* See nsIInterfaceRequestor
|
||||||
*/
|
*/
|
||||||
getInterface: function LLL_getInterface(iid) {
|
getInterface: function LLL_getInterface(aIID) {
|
||||||
return this.QueryInterface(iid);
|
return this.QueryInterface(aIID);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See nsISupports.idl
|
* See nsISupports.idl
|
||||||
*/
|
*/
|
||||||
QueryInterface: function LLL_QueryInterface(iid) {
|
QueryInterface: function LLL_QueryInterface(aIID) {
|
||||||
if (iid.equals(Ci.nsIFeedResultListener) ||
|
if (aIID.equals(Ci.nsIFeedResultListener) ||
|
||||||
iid.equals(Ci.nsIStreamListener) ||
|
aIID.equals(Ci.nsIStreamListener) ||
|
||||||
iid.equals(Ci.nsIRequestObserver)||
|
aIID.equals(Ci.nsIRequestObserver)||
|
||||||
iid.equals(Ci.nsINavHistoryBatchCallback) ||
|
aIID.equals(Ci.nsINavHistoryBatchCallback) ||
|
||||||
iid.equals(Ci.nsIBadCertListener2) ||
|
aIID.equals(Ci.nsIBadCertListener2) ||
|
||||||
iid.equals(Ci.nsISSLErrorListener) ||
|
aIID.equals(Ci.nsISSLErrorListener) ||
|
||||||
iid.equals(Ci.nsIInterfaceRequestor) ||
|
aIID.equals(Ci.nsIInterfaceRequestor) ||
|
||||||
iid.equals(Ci.nsISupports))
|
aIID.equals(Ci.nsISupports))
|
||||||
return this;
|
return this;
|
||||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function GenericComponentFactory(ctor) {
|
function GenericComponentFactory(aCtor) {
|
||||||
this._ctor = ctor;
|
this._ctor = aCtor;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericComponentFactory.prototype = {
|
GenericComponentFactory.prototype = {
|
||||||
|
@ -714,16 +724,16 @@ GenericComponentFactory.prototype = {
|
||||||
_ctor: null,
|
_ctor: null,
|
||||||
|
|
||||||
// nsIFactory
|
// nsIFactory
|
||||||
createInstance: function(outer, iid) {
|
createInstance: function(aOuter, aIID) {
|
||||||
if (outer != null)
|
if (aOuter != null)
|
||||||
throw Cr.NS_ERROR_NO_AGGREGATION;
|
throw Cr.NS_ERROR_NO_AGGREGATION;
|
||||||
return (new this._ctor()).QueryInterface(iid);
|
return (new this._ctor()).QueryInterface(aIID);
|
||||||
},
|
},
|
||||||
|
|
||||||
// nsISupports
|
// nsISupports
|
||||||
QueryInterface: function(iid) {
|
QueryInterface: function(aIID) {
|
||||||
if (iid.equals(Ci.nsIFactory) ||
|
if (aIID.equals(Ci.nsIFactory) ||
|
||||||
iid.equals(Ci.nsISupports))
|
aIID.equals(Ci.nsISupports))
|
||||||
return this;
|
return this;
|
||||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
},
|
},
|
||||||
|
@ -731,40 +741,40 @@ GenericComponentFactory.prototype = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var Module = {
|
var Module = {
|
||||||
QueryInterface: function(iid) {
|
QueryInterface: function(aIID) {
|
||||||
if (iid.equals(Ci.nsIModule) ||
|
if (aIID.equals(Ci.nsIModule) ||
|
||||||
iid.equals(Ci.nsISupports))
|
aIID.equals(Ci.nsISupports))
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
},
|
},
|
||||||
|
|
||||||
getClassObject: function M_getClassObject(cm, cid, iid) {
|
getClassObject: function M_getClassObject(aCompMgr, aCID, aIID) {
|
||||||
if (!iid.equals(Ci.nsIFactory))
|
if (!aIID.equals(Ci.nsIFactory))
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||||
if (cid.equals(LS_CLASSID))
|
if (aCID.equals(LS_CLASSID))
|
||||||
return new GenericComponentFactory(LivemarkService);
|
return new GenericComponentFactory(LivemarkService);
|
||||||
|
|
||||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
},
|
},
|
||||||
|
|
||||||
registerSelf: function(cm, file, location, type) {
|
registerSelf: function(aCompMgr, aFile, aLocation, aType) {
|
||||||
var cr = cm.QueryInterface(Ci.nsIComponentRegistrar);
|
var cr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
|
||||||
|
|
||||||
cr.registerFactoryLocation(LS_CLASSID, LS_CLASSNAME,
|
cr.registerFactoryLocation(LS_CLASSID, LS_CLASSNAME,
|
||||||
LS_CONTRACTID, file, location, type);
|
LS_CONTRACTID, aFile, aLocation, aType);
|
||||||
},
|
},
|
||||||
|
|
||||||
unregisterSelf: function M_unregisterSelf(cm, location, type) {
|
unregisterSelf: function M_unregisterSelf(aCompMgr, aLocation, aType) {
|
||||||
var cr = cm.QueryInterface(Ci.nsIComponentRegistrar);
|
var cr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
|
||||||
cr.unregisterFactoryLocation(LS_CLASSID, location);
|
cr.unregisterFactoryLocation(LS_CLASSID, aLocation);
|
||||||
},
|
},
|
||||||
|
|
||||||
canUnload: function M_canUnload(cm) {
|
canUnload: function M_canUnload(aCompMgr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function NSGetModule(cm, file) {
|
function NSGetModule(aCompMgr, aFile) {
|
||||||
return Module;
|
return Module;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4422,6 +4422,17 @@ nsNavHistory::OnIdle()
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove dangling livemark annotations
|
||||||
|
// we have moved expiration pageAnnotations to itemAnnotations
|
||||||
|
// we must remove pageAnnotations to allow expire do the cleanup
|
||||||
|
// see bug 388716
|
||||||
|
// XXX REMOVE ME AFTER FINAL
|
||||||
|
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||||
|
"DELETE FROM moz_annos WHERE id IN (SELECT a.id FROM moz_annos a "
|
||||||
|
"JOIN moz_anno_attributes n ON a.anno_attribute_id = n.id "
|
||||||
|
"WHERE n.name = 'livemark/expiration')"));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Currently commented out because vacuum is very slow
|
// Currently commented out because vacuum is very slow
|
||||||
// see bug #390244 for more details.
|
// see bug #390244 for more details.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче