Adding pref to set ruleset that feeds dashboard.

This commit is contained in:
Marina Samuel 2015-01-22 15:03:21 -05:00
Родитель dd3c6316a0
Коммит 6b915ee155
3 изменённых файлов: 28 добавлений и 7 удалений

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

@ -21,7 +21,8 @@ const bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.n
const ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
// timeout for fetching favicon
let DEFAULT_TIMEOUT = 3000;
const CURRENT_RULESET = "extensions.firefox.interest.dashboard.ruleset";
const DEFAULT_TIMEOUT = 3000;
/**
* Merge obj2 into obj1.
@ -364,6 +365,18 @@ exports.shouldSkip = function shouldSkip(url) {
return skipURL;
};
exports.getRulesetPref = function() {
let ruleset = "dfr_rules";
try {
ruleset = Services.prefs.getCharPref(CURRENT_RULESET);
}
catch(ex) {
// Likely no value set for CURRENT_RULESET pref, so set the pref.
Services.prefs.setCharPref(CURRENT_RULESET, ruleset);
}
return ruleset;
}
exports.DataProcessorHelper = {
initChartInStorage: function(dataNameString, storageBackend) {
let storageObj = storageBackend || storage;

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

@ -6,10 +6,9 @@
const {createNode} = require("streams/core");
const {storage} = require("sdk/simple-storage");
const {TypeNamespace} = require("TypeNamespace");
const {DataProcessorHelper} = require("Utils");
const {Cu} = require("chrome");
const {getHistoryDetails} = require("Utils");
const {getFaviconForHistoryVisit, shouldSkip} = require("Utils");
const {getFaviconForHistoryVisit, shouldSkip, DataProcessorHelper, getHistoryDetails, getRulesetPref} = require("Utils");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/Services.jsm");
@ -174,7 +173,12 @@ let InterestDashboardDataProcessorBolt = {
this.debugReport = this.debugReport.concat(message.errorData);
DataProcessorHelper.initChartInStorage("interestDashboardData", this.storage);
this.storage.chartData.interestDashboardData.sortedDomains = {"all": [], "byInterest": {}};
let interestDashboardTypeNamespace = message.chartData.rules.dfr_rules;
let ruleset = getRulesetPref();
let interestDashboardTypeNamespace = message.chartData.rules[ruleset];
if (!interestDashboardTypeNamespace) {
return;
}
this.debugReport.push("Processing data for pie chart");
let chartData = [];

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

@ -6,7 +6,7 @@
const {createNode} = require("streams/core");
const {storage} = require("sdk/simple-storage");
const {TypeNamespace} = require("TypeNamespace");
const {DataProcessorHelper} = require("Utils");
const {DataProcessorHelper, getRulesetPref} = require("Utils");
const {data} = require("sdk/self");
const {Cu, Cc, Ci} = require("chrome");
Cu.import("resource://gre/modules/Services.jsm");
@ -114,7 +114,11 @@ let SpiderDataProcessorBolt = {
ingest: function _HSB_ingest(message) {
DataProcessorHelper.initChartInStorage("spiderData", this.storage);
let data = message.chartData.rules.dfr_rules;
let ruleset = getRulesetPref();
let data = message.chartData.rules[ruleset];
if (!data) {
return;
}
let categories = data.categories;
this._mainNodes = [{"id": 0,