Bug 837292 - Part 1: Don't give each provider its own Preferences object; r=rnewman, a=bajaj
authorGregory Szorc <gps@mozilla.com>
Mon, 18 Mar 2013 20:48:13 -0700
changeset 128719 f3a6fc9019f9f60e18c80e9911c270fa956f01b6
parent 128718 06b482d67485319ac9cf4e6bda2bc770c761f0f9
child 128720 1b45e55944898f2f7c1a455cc6b83920fd5b179a
push id3568
push usergszorc@mozilla.com
push dateThu, 28 Mar 2013 22:57:01 +0000
treeherdermozilla-aurora@a084be958224 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, bajaj
bugs837292
milestone21.0a2
Bug 837292 - Part 1: Don't give each provider its own Preferences object; r=rnewman, a=bajaj
services/healthreport/healthreporter.jsm
services/healthreport/tests/xpcshell/test_provider_sessions.js
services/metrics/dataprovider.jsm
services/metrics/tests/xpcshell/test_metrics_provider.js
--- a/services/healthreport/healthreporter.jsm
+++ b/services/healthreport/healthreporter.jsm
@@ -426,17 +426,16 @@ AbstractHealthReporter.prototype = Objec
    * a provider is lazy initialized (like pull-only providers) this
    * will likely not return anything.
    */
   getProvider: function (name) {
     return this._providerManager.getProvider(name);
   },
 
   _initProvider: function (provider) {
-    provider.initPreferences(this._branch + "provider.");
     provider.healthReporter = this;
   },
 
   /**
    * Record an exception for reporting in the payload.
    *
    * A side effect is the exception is logged.
    *
--- a/services/healthreport/tests/xpcshell/test_provider_sessions.js
+++ b/services/healthreport/tests/xpcshell/test_provider_sessions.js
@@ -22,17 +22,16 @@ add_test(function test_constructor() {
   let provider = new SessionsProvider();
 
   run_next_test();
 });
 
 add_task(function test_init() {
   let storage = yield Metrics.Storage("init");
   let provider = new SessionsProvider();
-  provider.initPreferences("testing.init.");
   yield provider.init(storage);
   yield provider.shutdown();
 
   yield storage.close();
 });
 
 function monkeypatchStartupInfo(recorder, start=new Date(), offset=500) {
   Object.defineProperty(recorder, "_getStartupInfo", {
@@ -56,17 +55,16 @@ function sleep(wait) {
 
   return deferred.promise;
 }
 
 function getProvider(name, now=new Date(), init=true) {
   return Task.spawn(function () {
     let storage = yield Metrics.Storage(name);
     let provider = new SessionsProvider();
-    provider.initPreferences("testing." + name + ".healthreport.provider.");
 
     let recorder = new SessionRecorder("testing." + name + ".sessions.");
     monkeypatchStartupInfo(recorder, now);
     provider.healthReporter = {sessionRecorder: recorder};
     recorder.onStartup();
 
     if (init) {
       yield provider.init(storage);
--- a/services/metrics/dataprovider.jsm
+++ b/services/metrics/dataprovider.jsm
@@ -503,33 +503,16 @@ Provider.prototype = Object.freeze({
 
     if (!m) {
       throw new Error("Unknown measurement: " + name + " v" + version);
     }
 
     return m;
   },
 
-  /**
-   * Initializes preferences storage for this provider.
-   *
-   * Providers are allocated preferences storage under a pref branch named
-   * after the provider.
-   *
-   * This function is typically only called by the entity that constructs the
-   * Provider instance.
-   */
-  initPreferences: function (branchParent) {
-    if (!branchParent.endsWith(".")) {
-      throw new Error("branchParent must end with '.': " + branchParent);
-    }
-
-    this._prefs = new Preferences(branchParent + this.name + ".");
-  },
-
   init: function (storage) {
     if (this.storage !== null) {
       throw new Error("Provider() not called. Did the sub-type forget to call it?");
     }
 
     if (this.storage) {
       throw new Error("Provider has already been initialized.");
     }
--- a/services/metrics/tests/xpcshell/test_metrics_provider.js
+++ b/services/metrics/tests/xpcshell/test_metrics_provider.js
@@ -56,28 +56,16 @@ add_task(function test_init() {
   do_check_eq(m.id, 1);
   do_check_eq(Object.keys(m._fields).length, 7);
   do_check_true(m.hasField("daily-counter"));
   do_check_false(m.hasField("does-not-exist"));
 
   yield storage.close();
 });
 
-add_test(function test_prefs_integration() {
-  let branch = "testing.prefs_integration.";
-  let provider = new DummyProvider();
-  provider.initPreferences(branch);
-  let prefs = new Preferences(branch);
-
-  prefs.set("DummyProvider.foo", "bar");
-  do_check_eq(provider._prefs.get("foo"), "bar");
-
-  run_next_test();
-});
-
 add_task(function test_default_collectors() {
   let provider = new DummyProvider();
   let storage = yield Metrics.Storage("default_collectors");
   yield provider.init(storage);
 
   for (let property in Metrics.Provider.prototype) {
     if (!property.startsWith("collect")) {
       continue;