interest and keyword workers in WorkerFactory

This commit is contained in:
Olivier Yiptong 2014-06-12 13:30:59 -04:00
Родитель 1fab4fc189
Коммит 6b19e08706
1 изменённых файлов: 24 добавлений и 2 удалений

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

@ -87,7 +87,7 @@ WorkerFactory.prototype = {
}
},
_setupWorker: function(modelName) {
_setupInterestsWorker: function(modelName) {
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
scriptLoader.loadSubScript(data.url("models/" + this._localeCode + "/" + modelName + "/domainRules.json"));
scriptLoader.loadSubScript(data.url("models/" + this._localeCode + "/" + modelName + "/textModel.json"));
@ -117,7 +117,29 @@ WorkerFactory.prototype = {
let workers = [];
let {modelNames} = this._localeData;
modelNames.forEach(modelName => {
workers.push(this._setupWorker(modelName));
workers.push(this._setupInterestsWorker(modelName));
});
return workers;
},
_setupKeywordsWorker: function(modelName) {
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
scriptLoader.loadSubScript(data.url("models/urlStopwords.json"));
let worker = new ChromeWorker(data.url("interests/keywordsWorker.js"));
worker.postMessage({
message: "bootstrap",
workerRegionCode: this._localeCode,
urlStopwordSet: interestsUrlStopwords
});
return worker;
},
getKeywordsWorkers: function() {
let workers = [];
let {modelNames} = this._localeData;
modelNames.forEach(modelName => {
workers.push(this._setupKeywordsWorker(modelName));
});
return workers;
},