Tracking support for HistoryEngine. Bug #435321, r=thunder

This commit is contained in:
Anant Narayanan 2008-05-22 18:37:24 -07:00
parent 1743ffc42e
commit 226ed028e3
2 changed files with 53 additions and 1 deletions

View File

@ -981,6 +981,13 @@ HistoryEngine.prototype = {
if (!this.__store) if (!this.__store)
this.__store = new HistoryStore(); this.__store = new HistoryStore();
return this.__store; return this.__store;
},
__tracker: null,
get _tracker() {
if (!this.__tracker)
this.__tracker = new HistoryTracker();
return this.__tracker;
} }
}; };
HistoryEngine.prototype.__proto__ = new Engine(); HistoryEngine.prototype.__proto__ = new Engine();

View File

@ -34,7 +34,7 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
const EXPORTED_SYMBOLS = ['Tracker', 'BookmarksTracker']; const EXPORTED_SYMBOLS = ['Tracker', 'BookmarksTracker', 'HistoryTracker'];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
@ -141,3 +141,48 @@ Function.prototype.async = Async.sugar;
} }
BookmarksTracker.prototype.__proto__ = new Tracker(); BookmarksTracker.prototype.__proto__ = new Tracker();
function HistoryTracker() {
this._init();
}
HistoryTracker.prototype = {
_logName: "HistoryTracker",
/* We don't care about the first four */
onBeginUpdateBatch: function HT_onBeginUpdateBatch() {
},
onEndUpdateBatch: function HT_onEndUpdateBatch() {
},
onPageChanged: function HT_onPageChanged() {
},
onTitleChanged: function HT_onTitleChanged() {
},
/* Every add or remove is worth 1 point.
* Clearing the whole history is worth 50 points,
* to ensure we're above the cutoff for syncing
* ASAP.
*/
onVisit: function HT_onVisit(uri, vid, time, session, referrer, trans) {
this._score += 1;
},
onPageExpired: function HT_onPageExpired(uri, time, entry) {
this._score += 1;
},
onDeleteURI: function HT_onDeleteURI(uri) {
this._score += 1;
},
onClearHistory: function HT_onClearHistory() {
this._score += 50;
},
_init: function HT__init() {
super._init();
Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService).
addObserver(this, false);
}
}
HistoryTracker.prototype.__proto__ = new Tracker();