Bug 471547 - move PlacesDBUtils getters to avoid possible leaks, r=sdwilsh

This commit is contained in:
Marco Bonardo 2009-01-08 00:37:01 +01:00
Родитель 4acc96151e
Коммит e1bff9ddc1
1 изменённых файлов: 36 добавлений и 36 удалений

Просмотреть файл

@ -80,6 +80,42 @@ const MAINTENANCE_REPEAT = 24 * 60 * 60;
//// nsPlacesDBUtils class //// nsPlacesDBUtils class
function nsPlacesDBUtils() { function nsPlacesDBUtils() {
//////////////////////////////////////////////////////////////////////////////
//// Smart getters
this.__defineGetter__("_bms", function() {
delete this._bms;
return this._bms = Cc[BS_CONTRACTID].getService(Ci.nsINavBookmarksService);
});
this.__defineGetter__("_hs", function() {
delete this._hs;
return this._hs = Cc[HS_CONTRACTID].getService(Ci.nsINavHistoryService);
});
this.__defineGetter__("_os", function() {
delete this._os;
return this._os = Cc[OS_CONTRACTID].getService(Ci.nsIObserverService);
});
this.__defineGetter__("_idlesvc", function() {
delete this._idlesvc;
return this._idlesvc = Cc[IS_CONTRACTID].getService(Ci.nsIIdleService);
});
this.__defineGetter__("_dbConn", function() {
delete this._dbConn;
return this._dbConn = Cc[HS_CONTRACTID].
getService(Ci.nsPIPlacesDatabase).DBConnection;
});
this.__defineGetter__("_bundle", function() {
delete this._bundle;
return this._bundle = Cc[SB_CONTRACTID].
getService(Ci.nsIStringBundleService).
createBundle(PLACES_STRING_BUNDLE_URI);
});
// register the maintenance timer // register the maintenance timer
try { try {
let tim = Cc[TIM_CONTRACTID].getService(Ci.nsIUpdateTimerManager); let tim = Cc[TIM_CONTRACTID].getService(Ci.nsIUpdateTimerManager);
@ -515,42 +551,6 @@ nsPlacesDBUtils.prototype = {
}, },
}; };
//////////////////////////////////////////////////////////////////////////////
//// Smart getters
nsPlacesDBUtils.prototype.__defineGetter__("_bms", function() {
delete nsPlacesDBUtils._bms;
return nsPlacesDBUtils._bms = Cc[BS_CONTRACTID].getService(Ci.nsINavBookmarksService);
});
nsPlacesDBUtils.prototype.__defineGetter__("_hs", function() {
delete nsPlacesDBUtils._hs;
return nsPlacesDBUtils._hs = Cc[HS_CONTRACTID].getService(Ci.nsINavHistoryService);
});
nsPlacesDBUtils.prototype.__defineGetter__("_os", function() {
delete nsPlacesDBUtils._os;
return nsPlacesDBUtils._os = Cc[OS_CONTRACTID].getService(Ci.nsIObserverService);
});
nsPlacesDBUtils.prototype.__defineGetter__("_idlesvc", function() {
delete nsPlacesDBUtils._idlesvc;
return nsPlacesDBUtils._idlesvc = Cc[IS_CONTRACTID].getService(Ci.nsIIdleService);
});
nsPlacesDBUtils.prototype.__defineGetter__("_dbConn", function() {
delete nsPlacesDBUtils._dbConn;
return nsPlacesDBUtils._dbConn = Cc[HS_CONTRACTID].
getService(Ci.nsPIPlacesDatabase).DBConnection;
});
nsPlacesDBUtils.prototype.__defineGetter__("_bundle", function() {
delete nsPlacesDBUtils._bundle;
return nsPlacesDBUtils._bundle = Cc[SB_CONTRACTID].
getService(Ci.nsIStringBundleService).
createBundle(PLACES_STRING_BUNDLE_URI);
});
__defineGetter__("PlacesDBUtils", function() { __defineGetter__("PlacesDBUtils", function() {
delete this.PlacesDBUtils; delete this.PlacesDBUtils;
return this.PlacesDBUtils = new nsPlacesDBUtils; return this.PlacesDBUtils = new nsPlacesDBUtils;