mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Moved all history-related functionality into modules/engines/history.js.
This commit is contained in:
parent
f365f924cf
commit
e2ce660c53
@ -36,7 +36,6 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const EXPORTED_SYMBOLS = ['Engines', 'Engine',
|
||||
'HistoryEngine',
|
||||
'PasswordEngine', 'FormEngine', 'TabEngine'];
|
||||
|
||||
const Cc = Components.classes;
|
||||
@ -758,37 +757,6 @@ Engine.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
function HistoryEngine(pbeId) {
|
||||
this._init(pbeId);
|
||||
}
|
||||
HistoryEngine.prototype = {
|
||||
get name() { return "history"; },
|
||||
get logName() { return "HistEngine"; },
|
||||
get serverPrefix() { return "user-data/history/"; },
|
||||
|
||||
__core: null,
|
||||
get _core() {
|
||||
if (!this.__core)
|
||||
this.__core = new HistorySyncCore();
|
||||
return this.__core;
|
||||
},
|
||||
|
||||
__store: null,
|
||||
get _store() {
|
||||
if (!this.__store)
|
||||
this.__store = new HistoryStore();
|
||||
return this.__store;
|
||||
},
|
||||
|
||||
__tracker: null,
|
||||
get _tracker() {
|
||||
if (!this.__tracker)
|
||||
this.__tracker = new HistoryTracker();
|
||||
return this.__tracker;
|
||||
}
|
||||
};
|
||||
HistoryEngine.prototype.__proto__ = new Engine();
|
||||
|
||||
function PasswordEngine(pbeId) {
|
||||
this._init(pbeId);
|
||||
}
|
||||
|
193
services/sync/modules/engines/history.js
Normal file
193
services/sync/modules/engines/history.js
Normal file
@ -0,0 +1,193 @@
|
||||
const EXPORTED_SYMBOLS = ['HistoryEngine'];
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://weave/log4moz.js");
|
||||
Cu.import("resource://weave/util.js");
|
||||
Cu.import("resource://weave/engines.js");
|
||||
Cu.import("resource://weave/syncCores.js");
|
||||
Cu.import("resource://weave/stores.js");
|
||||
Cu.import("resource://weave/trackers.js");
|
||||
|
||||
function HistoryEngine(pbeId) {
|
||||
this._init(pbeId);
|
||||
}
|
||||
HistoryEngine.prototype = {
|
||||
get name() { return "history"; },
|
||||
get logName() { return "HistEngine"; },
|
||||
get serverPrefix() { return "user-data/history/"; },
|
||||
|
||||
__core: null,
|
||||
get _core() {
|
||||
if (!this.__core)
|
||||
this.__core = new HistorySyncCore();
|
||||
return this.__core;
|
||||
},
|
||||
|
||||
__store: null,
|
||||
get _store() {
|
||||
if (!this.__store)
|
||||
this.__store = new HistoryStore();
|
||||
return this.__store;
|
||||
},
|
||||
|
||||
__tracker: null,
|
||||
get _tracker() {
|
||||
if (!this.__tracker)
|
||||
this.__tracker = new HistoryTracker();
|
||||
return this.__tracker;
|
||||
}
|
||||
};
|
||||
HistoryEngine.prototype.__proto__ = new Engine();
|
||||
|
||||
function HistorySyncCore() {
|
||||
this._init();
|
||||
}
|
||||
HistorySyncCore.prototype = {
|
||||
_logName: "HistSync",
|
||||
|
||||
_itemExists: function HSC__itemExists(GUID) {
|
||||
// we don't care about already-existing items; just try to re-add them
|
||||
return false;
|
||||
},
|
||||
|
||||
_commandLike: function HSC_commandLike(a, b) {
|
||||
// History commands never qualify for likeness. We will always
|
||||
// take the union of all client/server items. We use the URL as
|
||||
// the GUID, so the same sites will map to the same item (same
|
||||
// GUID), without our intervention.
|
||||
return false;
|
||||
}
|
||||
};
|
||||
HistorySyncCore.prototype.__proto__ = new SyncCore();
|
||||
|
||||
function HistoryStore() {
|
||||
this._init();
|
||||
}
|
||||
HistoryStore.prototype = {
|
||||
_logName: "HistStore",
|
||||
|
||||
__hsvc: null,
|
||||
get _hsvc() {
|
||||
if (!this.__hsvc) {
|
||||
this.__hsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
this.__hsvc.QueryInterface(Ci.nsIGlobalHistory2);
|
||||
this.__hsvc.QueryInterface(Ci.nsIBrowserHistory);
|
||||
}
|
||||
return this.__hsvc;
|
||||
},
|
||||
|
||||
_createCommand: function HistStore__createCommand(command) {
|
||||
this._log.debug(" -> creating history entry: " + command.GUID);
|
||||
try {
|
||||
let uri = Utils.makeURI(command.data.URI);
|
||||
this._hsvc.addVisit(uri, command.data.time, null,
|
||||
this._hsvc.TRANSITION_TYPED, false, null);
|
||||
this._hsvc.setPageTitle(uri, command.data.title);
|
||||
} catch (e) {
|
||||
this._log.error("Exception caught: " + (e.message? e.message : e));
|
||||
}
|
||||
},
|
||||
|
||||
_removeCommand: function HistStore__removeCommand(command) {
|
||||
this._log.trace(" -> NOT removing history entry: " + command.GUID);
|
||||
// we can't remove because we only sync the last 1000 items, not
|
||||
// the whole store. So we don't know if remove commands were
|
||||
// generated due to the user removing an entry or because it
|
||||
// dropped past the 1000 item mark.
|
||||
},
|
||||
|
||||
_editCommand: function HistStore__editCommand(command) {
|
||||
this._log.trace(" -> FIXME: NOT editing history entry: " + command.GUID);
|
||||
// FIXME: implement!
|
||||
},
|
||||
|
||||
_historyRoot: function HistStore__historyRoot() {
|
||||
let query = this._hsvc.getNewQuery(),
|
||||
options = this._hsvc.getNewQueryOptions();
|
||||
|
||||
query.minVisits = 1;
|
||||
options.maxResults = 1000;
|
||||
options.resultType = options.RESULTS_AS_VISIT; // FULL_VISIT does not work
|
||||
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);
|
||||
return root;
|
||||
},
|
||||
|
||||
wrap: function HistStore_wrap() {
|
||||
let root = this._historyRoot();
|
||||
root.containerOpen = true;
|
||||
let items = {};
|
||||
for (let i = 0; i < root.childCount; i++) {
|
||||
let item = root.getChild(i);
|
||||
let guid = item.time + ":" + item.uri
|
||||
items[guid] = {parentGUID: '',
|
||||
title: item.title,
|
||||
URI: item.uri,
|
||||
time: item.time
|
||||
};
|
||||
// FIXME: sync transition type - requires FULL_VISITs
|
||||
}
|
||||
return items;
|
||||
},
|
||||
|
||||
wipe: function HistStore_wipe() {
|
||||
this._hsvc.removeAllPages();
|
||||
}
|
||||
};
|
||||
HistoryStore.prototype.__proto__ = new Store();
|
||||
|
||||
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() {
|
||||
this._log = Log4Moz.Service.getLogger("Service." + this._logName);
|
||||
this._score = 0;
|
||||
|
||||
Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService).
|
||||
addObserver(this, false);
|
||||
}
|
||||
}
|
||||
HistoryTracker.prototype.__proto__ = new Tracker();
|
@ -53,6 +53,7 @@ Cu.import("resource://weave/identity.js");
|
||||
Cu.import("resource://weave/async.js");
|
||||
Cu.import("resource://weave/engines/cookies.js");
|
||||
Cu.import("resource://weave/engines/bookmarks.js");
|
||||
Cu.import("resource://weave/engines/history.js");
|
||||
|
||||
Function.prototype.async = Async.sugar;
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const EXPORTED_SYMBOLS = ['Store', 'SnapshotStore',
|
||||
'HistoryStore', 'PasswordStore', 'FormStore',
|
||||
'PasswordStore', 'FormStore',
|
||||
'TabStore'];
|
||||
|
||||
const Cc = Components.classes;
|
||||
@ -272,86 +272,6 @@ SnapshotStore.prototype = {
|
||||
};
|
||||
SnapshotStore.prototype.__proto__ = new Store();
|
||||
|
||||
function HistoryStore() {
|
||||
this._init();
|
||||
}
|
||||
HistoryStore.prototype = {
|
||||
_logName: "HistStore",
|
||||
|
||||
__hsvc: null,
|
||||
get _hsvc() {
|
||||
if (!this.__hsvc) {
|
||||
this.__hsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
this.__hsvc.QueryInterface(Ci.nsIGlobalHistory2);
|
||||
this.__hsvc.QueryInterface(Ci.nsIBrowserHistory);
|
||||
}
|
||||
return this.__hsvc;
|
||||
},
|
||||
|
||||
_createCommand: function HistStore__createCommand(command) {
|
||||
this._log.debug(" -> creating history entry: " + command.GUID);
|
||||
try {
|
||||
let uri = Utils.makeURI(command.data.URI);
|
||||
this._hsvc.addVisit(uri, command.data.time, null,
|
||||
this._hsvc.TRANSITION_TYPED, false, null);
|
||||
this._hsvc.setPageTitle(uri, command.data.title);
|
||||
} catch (e) {
|
||||
this._log.error("Exception caught: " + (e.message? e.message : e));
|
||||
}
|
||||
},
|
||||
|
||||
_removeCommand: function HistStore__removeCommand(command) {
|
||||
this._log.trace(" -> NOT removing history entry: " + command.GUID);
|
||||
// we can't remove because we only sync the last 1000 items, not
|
||||
// the whole store. So we don't know if remove commands were
|
||||
// generated due to the user removing an entry or because it
|
||||
// dropped past the 1000 item mark.
|
||||
},
|
||||
|
||||
_editCommand: function HistStore__editCommand(command) {
|
||||
this._log.trace(" -> FIXME: NOT editing history entry: " + command.GUID);
|
||||
// FIXME: implement!
|
||||
},
|
||||
|
||||
_historyRoot: function HistStore__historyRoot() {
|
||||
let query = this._hsvc.getNewQuery(),
|
||||
options = this._hsvc.getNewQueryOptions();
|
||||
|
||||
query.minVisits = 1;
|
||||
options.maxResults = 1000;
|
||||
options.resultType = options.RESULTS_AS_VISIT; // FULL_VISIT does not work
|
||||
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);
|
||||
return root;
|
||||
},
|
||||
|
||||
wrap: function HistStore_wrap() {
|
||||
let root = this._historyRoot();
|
||||
root.containerOpen = true;
|
||||
let items = {};
|
||||
for (let i = 0; i < root.childCount; i++) {
|
||||
let item = root.getChild(i);
|
||||
let guid = item.time + ":" + item.uri
|
||||
items[guid] = {parentGUID: '',
|
||||
title: item.title,
|
||||
URI: item.uri,
|
||||
time: item.time
|
||||
};
|
||||
// FIXME: sync transition type - requires FULL_VISITs
|
||||
}
|
||||
return items;
|
||||
},
|
||||
|
||||
wipe: function HistStore_wipe() {
|
||||
this._hsvc.removeAllPages();
|
||||
}
|
||||
};
|
||||
HistoryStore.prototype.__proto__ = new Store();
|
||||
|
||||
function PasswordStore() {
|
||||
this._init();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const EXPORTED_SYMBOLS = ['SyncCore', 'HistorySyncCore',
|
||||
const EXPORTED_SYMBOLS = ['SyncCore',
|
||||
'PasswordSyncCore', 'FormSyncCore',
|
||||
'TabSyncCore'];
|
||||
|
||||
@ -313,27 +313,6 @@ SyncCore.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
function HistorySyncCore() {
|
||||
this._init();
|
||||
}
|
||||
HistorySyncCore.prototype = {
|
||||
_logName: "HistSync",
|
||||
|
||||
_itemExists: function HSC__itemExists(GUID) {
|
||||
// we don't care about already-existing items; just try to re-add them
|
||||
return false;
|
||||
},
|
||||
|
||||
_commandLike: function HSC_commandLike(a, b) {
|
||||
// History commands never qualify for likeness. We will always
|
||||
// take the union of all client/server items. We use the URL as
|
||||
// the GUID, so the same sites will map to the same item (same
|
||||
// GUID), without our intervention.
|
||||
return false;
|
||||
}
|
||||
};
|
||||
HistorySyncCore.prototype.__proto__ = new SyncCore();
|
||||
|
||||
function PasswordSyncCore() {
|
||||
this._init();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const EXPORTED_SYMBOLS = ['Tracker', 'HistoryTracker',
|
||||
const EXPORTED_SYMBOLS = ['Tracker',
|
||||
'FormsTracker', 'TabTracker'];
|
||||
|
||||
const Cc = Components.classes;
|
||||
@ -94,55 +94,6 @@ Tracker.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
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() {
|
||||
this._log = Log4Moz.Service.getLogger("Service." + this._logName);
|
||||
this._score = 0;
|
||||
|
||||
Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService).
|
||||
addObserver(this, false);
|
||||
}
|
||||
}
|
||||
HistoryTracker.prototype.__proto__ = new Tracker();
|
||||
|
||||
function FormsTracker() {
|
||||
this._init();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user