Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2013-05-09 00:20:17 -04:00
commit a1b282a2d4
10 changed files with 61 additions and 13 deletions

View File

@ -185,6 +185,7 @@ let FormAssistant = {
addEventListener("resize", this, true, false);
addEventListener("submit", this, true, false);
addEventListener("pagehide", this, true, false);
addEventListener("beforeunload", this, true, false);
addEventListener("input", this, true, false);
addEventListener("keydown", this, true, false);
addMessageListener("Forms:Select:Choice", this);
@ -292,7 +293,9 @@ let FormAssistant = {
break;
case "pagehide":
// We are only interested to the pagehide event from the root document.
case "beforeunload":
// We are only interested to the pagehide and beforeunload events from
// the root document.
if (target && target != content.document) {
break;
}

View File

@ -16,6 +16,8 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>&abouthealth.pagetitle;</title>
<link rel="icon" type="image/png" id="favicon"
href="chrome://branding/content/icon32.png"/>
<link rel="stylesheet"
href="chrome://browser/content/abouthealthreport/abouthealth.css"
type="text/css" />

View File

@ -145,6 +145,15 @@ var gAdvancedPane = {
// DATA CHOICES TAB
/**
* opening links behind a modal dialog is poor form. Work around flawed text-link handling here.
*/
openTextLink: function (evt) {
let where = Services.prefs.getBoolPref("browser.preferences.instantApply") ? "tab" : "window";
openUILinkIn(evt.target.getAttribute("href"), where);
evt.preventDefault();
},
/**
* Set up or hide the Learn More links for various data collection options
*/

View File

@ -207,7 +207,8 @@
<spacer flex="1"/>
<label id="telemetryLearnMore"
class="text-link"
value="&telemetryLearnMore.label;"/>
value="&telemetryLearnMore.label;"
onclick="gAdvancedPane.openTextLink(event)"/>
</hbox>
</groupbox>
#endif
@ -223,7 +224,8 @@
<spacer flex="1"/>
<label id="FHRLearnMore"
class="text-link"
value="&healthReportLearnMore.label;"/>
value="&healthReportLearnMore.label;"
onclick="gAdvancedPane.openTextLink(event)"/>
</hbox>
</groupbox>
#endif
@ -240,7 +242,8 @@
<spacer flex="1"/>
<label id="crashReporterLearnMore"
class="text-link"
value="&crashReporterLearnMore.label;"/>
value="&crashReporterLearnMore.label;"
onclick="gAdvancedPane.openTextLink(event)"/>
</hbox>
</groupbox>
#endif

View File

@ -927,6 +927,12 @@ CrashesProvider.prototype = Object.freeze({
let m = this.getMeasurement("crashes", 1);
// Aggregate counts locally to avoid excessive storage interaction.
let counts = {
pending: new Metrics.DailyValues(),
submitted: new Metrics.DailyValues(),
};
// FUTURE detect mtimes in the future and react more intelligently.
for (let filename in pending) {
let modified = pending[filename].modified;
@ -935,7 +941,7 @@ CrashesProvider.prototype = Object.freeze({
continue;
}
yield m.incrementDailyCounter("pending", modified);
counts.pending.appendValue(modified, 1);
}
for (let filename in submitted) {
@ -945,7 +951,15 @@ CrashesProvider.prototype = Object.freeze({
continue;
}
yield m.incrementDailyCounter("submitted", modified);
counts.submitted.appendValue(modified, 1);
}
for (let [date, values] in counts.pending) {
yield m.incrementDailyCounter("pending", date, values.length);
}
for (let [date, values] in counts.submitted) {
yield m.incrementDailyCounter("submitted", date, values.length);
}
yield this.setState("lastCheck", "" + now.getTime());

View File

@ -126,13 +126,17 @@ add_task(function test_collect() {
let tomorrow = new Date(now.getTime() + MILLISECONDS_PER_DAY);
let yesterday = new Date(now.getTime() - MILLISECONDS_PER_DAY);
let yesterdayID = createFakeCrash(false, yesterday);
let tomorrowID = createFakeCrash(false, tomorrow);
createFakeCrash(false, yesterday);
// Create multiple to test that multiple are handled properly.
createFakeCrash(false, tomorrow);
createFakeCrash(false, tomorrow);
createFakeCrash(false, tomorrow);
yield provider.collectConstantData();
values = yield m.getValues();
do_check_eq(values.days.size, 11);
do_check_eq(values.days.getDay(tomorrow).get("pending"), 1);
do_check_eq(values.days.getDay(tomorrow).get("pending"), 3);
for each (let date in gPending) {
let day = values.days.getDay(date);

View File

@ -233,11 +233,13 @@ Measurement.prototype = Object.freeze({
* (string) The name of the field whose value to increment.
* @param date
* (Date) Day on which to increment the counter.
* @param by
* (integer) How much to increment by.
* @return Promise<>
*/
incrementDailyCounter: function (field, date=new Date()) {
incrementDailyCounter: function (field, date=new Date(), by=1) {
return this.storage.incrementDailyCounterFromFieldID(this.fieldID(field),
date);
date, by);
},
/**

View File

@ -491,7 +491,7 @@ const SQL = {
"field_id = :field_id AND day = :days " +
"), " +
"0" +
") + 1)",
") + :by)",
deleteLastNumericFromFieldID:
"DELETE FROM last_numeric WHERE field_id = :field_id",
@ -1614,13 +1614,16 @@ MetricsStorageSqliteBackend.prototype = Object.freeze({
* @param date
* (Date) When the increment occurred. This is typically "now" but can
* be explicitly defined for events that occurred in the past.
* @param by
* (integer) How much to increment the value by. Defaults to 1.
*/
incrementDailyCounterFromFieldID: function (id, date=new Date()) {
incrementDailyCounterFromFieldID: function (id, date=new Date(), by=1) {
this._ensureFieldType(id, this.FIELD_DAILY_COUNTER);
let params = {
field_id: id,
days: dateToDays(date),
by: by,
};
return this._connection.executeCached(SQL.incrementDailyCounterFromFieldID,

View File

@ -97,6 +97,10 @@ add_task(function test_measurement_storage_basic() {
count = yield provider.storage.getDailyCounterCountFromFieldID(counterID, yesterday);
do_check_eq(count, 1);
yield m.incrementDailyCounter("daily-counter", now, 4);
count = yield provider.storage.getDailyCounterCountFromFieldID(counterID, now);
do_check_eq(count, 6);
// Daily discrete numeric.
let dailyDiscreteNumericID = m.fieldID("daily-discrete-numeric");
yield m.addDailyDiscreteNumeric("daily-discrete-numeric", 5, now);

View File

@ -445,6 +445,10 @@ add_task(function test_increment_daily_counter_basic() {
count = yield backend.getDailyCounterCountFromFieldID(fieldID, now);
do_check_eq(count, 2);
yield backend.incrementDailyCounterFromFieldID(fieldID, now, 10);
count = yield backend.getDailyCounterCountFromFieldID(fieldID, now);
do_check_eq(count, 12);
yield backend.close();
});