Bug 827157 - Part 2: report current session information. r=rnewman
authorGregory Szorc <gps@mozilla.com>
Sat, 19 Jan 2013 00:31:38 -0800
changeset 119357 d15625b7c9c7821974c653d08a00ce0b5c0b7331
parent 119356 3e7e06804ae4ad1f50dc401fad1694f28e851966
child 119358 a97eb4f09112957e54797b332d852195524799f7
push id24196
push usergszorc@mozilla.com
push dateSat, 19 Jan 2013 17:38:09 +0000
treeherdermozilla-central@a97eb4f09112 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs827157
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 827157 - Part 2: report current session information. r=rnewman The previous patch regressed this because HealthReporter was talking directly to storage instead of going through the measurement instance.
services/healthreport/healthreporter.jsm
services/healthreport/providers.jsm
services/healthreport/tests/xpcshell/test_provider_sessions.js
--- a/services/healthreport/healthreporter.jsm
+++ b/services/healthreport/healthreporter.jsm
@@ -635,17 +635,17 @@ HealthReporter.prototype = Object.freeze
           this._log.warn("Error obtaining serializer for measurement: " + name +
                          ": " + CommonUtils.exceptionStr(ex));
           errors.push("Could not obtain serializer: " + name);
           continue;
         }
 
         let data;
         try {
-          data = yield this._storage.getMeasurementValues(measurement.id);
+          data = yield measurement.getValues();
         } catch (ex) {
           this._log.warn("Error obtaining data for measurement: " +
                          name + ": " + CommonUtils.exceptionStr(ex));
           errors.push("Could not obtain data: " + name);
           continue;
         }
 
         if (data.singular.size) {
--- a/services/healthreport/providers.jsm
+++ b/services/healthreport/providers.jsm
@@ -387,16 +387,26 @@ CurrentSessionMeasurement.prototype = Ob
     fields.set("firstPaint", [now, sessions.firstPaint]);
     fields.set("sessionRestored", [now, sessions.sessionRestored]);
 
     return Promise.resolve({
       days: new Metrics.DailyValues(),
       singular: fields,
     });
   },
+
+  _serializeJSONSingular: function (data) {
+    let result = {};
+
+    for (let [field, value] of data) {
+      result[field] = value[1];
+    }
+
+    return result;
+  },
 });
 
 /**
  * Records a history of all application sessions.
  */
 function PreviousSessionsMeasurement() {
   Metrics.Measurement.call(this);
 }
--- a/services/healthreport/tests/xpcshell/test_provider_sessions.js
+++ b/services/healthreport/tests/xpcshell/test_provider_sessions.js
@@ -155,8 +155,28 @@ add_task(function test_collect() {
 
   recorder.onShutdown();
   recorder2.onShutdown();
 
   yield provider.shutdown();
   yield storage.close();
 });
 
+add_task(function test_serialization() {
+  let [provider, storage, recorder] = yield getProvider("serialization");
+
+  let current = provider.getMeasurement("current", 2);
+  let data = yield current.getValues();
+  do_check_true("singular" in data);
+
+  let serializer = current.serializer(current.SERIALIZE_JSON);
+  let fields = serializer.singular(data.singular);
+
+  do_check_eq(fields.activeTicks, 0);
+  do_check_eq(fields.startDay, Metrics.dateToDays(recorder.startDate));
+  do_check_eq(fields.main, 500);
+  do_check_eq(fields.firstPaint, 1000);
+  do_check_eq(fields.sessionRestored, 1500);
+  do_check_true(fields.totalTime > 0);
+
+  yield provider.shutdown();
+  yield storage.close();
+});