mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
sync only the last 150 history items (pending some special sauce to sync high-scoring items); various sql fixes. history is syncing now, though there are bugs here and there
This commit is contained in:
parent
7f2139c4af
commit
06dc4da97f
@ -40,6 +40,8 @@ const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
Cu.import("resource://weave/log4moz.js");
|
||||
Cu.import("resource://weave/util.js");
|
||||
Cu.import("resource://weave/engines.js");
|
||||
@ -136,14 +138,21 @@ HistoryStore.prototype = {
|
||||
|
||||
get _urlStm() {
|
||||
let stmt = this._db.createStatement(
|
||||
"SELECT url FROM moz_places WHERE id = ?1");
|
||||
"SELECT url FROM moz_places WHERE id = :id");
|
||||
this.__defineGetter__("_urlStm", function() stmt);
|
||||
return stmt;
|
||||
},
|
||||
|
||||
get _annoAttrIdStm() {
|
||||
let stmt = this._db.createStatement(
|
||||
"SELECT id from moz_anno_attributes WHERE name = :name");
|
||||
this.__defineGetter__("_annoAttrIdStm", function() stmt);
|
||||
return stmt;
|
||||
},
|
||||
|
||||
get _findPidByAnnoStm() {
|
||||
let stmt = this._db.createStatement(
|
||||
"SELECT place_id FROM moz_annos WHERE type = ?1 AND content = ?2");
|
||||
"SELECT place_id AS id FROM moz_annos WHERE anno_attribute_id = :attr AND content = :content");
|
||||
this.__defineGetter__("_findPidByAnnoStm", function() stmt);
|
||||
return stmt;
|
||||
},
|
||||
@ -200,22 +209,39 @@ HistoryStore.prototype = {
|
||||
// throw e;
|
||||
}
|
||||
let guid = Utils.makeGUID();
|
||||
this._anno.setPageAnnotation(uri, "weave/guid", guid, 0, 0);
|
||||
this._anno.setPageAnnotation(uri, "weave/guid", guid, 0, this._anno.EXPIRE_WITH_HISTORY);
|
||||
return guid;
|
||||
},
|
||||
|
||||
// See bug 468732 for why we use SQL here
|
||||
_findURLByGUID: function HistStore__findByGUID(guid) {
|
||||
this._findPidByAnnoStm.bindUTF8Parameter(0, "weave/guid");
|
||||
this._findPidByAnnoStm.bindUTF8Parameter(1, guid);
|
||||
if (this._findPidByAnnoStm.executeStep()) {
|
||||
let placeId = this._findPidByAnnoStm.getInt32(0);
|
||||
this._urlStm.bindInt32Parameter(0, placeId);
|
||||
if (this._urlStm.executeStep()) {
|
||||
return this._urlStm.getString(0);
|
||||
}
|
||||
try {
|
||||
this._annoAttrIdStm.params.name = "weave/guid";
|
||||
if (!this._annoAttrIdStm.step())
|
||||
return null;
|
||||
let annoId = this._annoAttrIdStm.row.id;
|
||||
|
||||
this._findPidByAnnoStm.params.attr = annoId;
|
||||
this._findPidByAnnoStm.params.content = guid;
|
||||
if (!this._findPidByAnnoStm.step())
|
||||
return null;
|
||||
let placeId = this._findPidByAnnoStm.row.id;
|
||||
|
||||
this._urlStm.params.id = placeId;
|
||||
if (!this._urlStm.step())
|
||||
return null;
|
||||
|
||||
return this._urlStm.row.url;
|
||||
} finally {
|
||||
this._annoAttrIdStm.reset();
|
||||
this._findPidByAnnoStm.reset();
|
||||
this._urlStm.reset();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
changeItemID: function HStore_changeItemID(oldID, newID) {
|
||||
let uri = Utils.makeURI(this._findURLByGUID(oldID));
|
||||
this._anno.setPageAnnotation(uri, "weave/guid", newID, 0, 0);
|
||||
},
|
||||
|
||||
// XXX need a better way to query Places for all GUIDs
|
||||
@ -229,6 +255,9 @@ HistoryStore.prototype = {
|
||||
options = this._hsvc.getNewQueryOptions();
|
||||
|
||||
query.minVisits = 1;
|
||||
options.maxResults = 150;
|
||||
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
|
||||
options.queryType = options.QUERY_TYPE_HISTORY;
|
||||
|
||||
let root = this._hsvc.executeQuery(query, options).root;
|
||||
root.QueryInterface(Ci.nsINavHistoryQueryResultNode);
|
||||
@ -268,6 +297,8 @@ HistoryTracker.prototype = {
|
||||
__proto__: Tracker.prototype,
|
||||
_logName: "HistoryTracker",
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver]),
|
||||
|
||||
get _hsvc() {
|
||||
let hsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
@ -302,17 +333,17 @@ HistoryTracker.prototype = {
|
||||
},
|
||||
|
||||
onVisit: function HT_onVisit(uri, vid, time, session, referrer, trans) {
|
||||
this._log.trace("onVisit: " + itemId);
|
||||
this._log.trace("onVisit: " + uri.spec);
|
||||
this.addChangedID(this._store._getGUID(uri));
|
||||
this._upScore();
|
||||
},
|
||||
onPageExpired: function HT_onPageExpired(uri, time, entry) {
|
||||
this._log.trace("onPageExpired: " + itemId);
|
||||
this._log.trace("onPageExpired: " + uri.spec);
|
||||
this.addChangedID(this._store._getGUID(uri)); // XXX eek ?
|
||||
this._upScore();
|
||||
},
|
||||
onDeleteURI: function HT_onDeleteURI(uri) {
|
||||
this._log.trace("onDeleteURI: " + itemId);
|
||||
this._log.trace("onDeleteURI: " + uri.spec);
|
||||
this.addChangedID(this._store._getGUID(uri)); // FIXME eek
|
||||
this._upScore();
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user