Bug 885582 - Append version number query parameter to Android about:healthreport URL. r=rnewman a=bajaj
authorNick Alexander <nalexander@mozilla.com>
Fri, 21 Jun 2013 17:42:46 -0700
changeset 142978 48c44c0dbab74e3f3d77d8be9a5497f72eaa9aef
parent 142977 86c2452fd56dcbf464551450d65ba5c9cdd38d3f
child 142981 77a8241ae55d59fd3b8087dc8a824f3ce6473c5a
child 142983 165aad98ce0a661c37af657ec936d83d393d4403
child 142985 9838fbb641f9f0c6214845aecd44493e8cf25df3
push id2583
push usernalexander@mozilla.com
push dateMon, 24 Jun 2013 21:33:29 +0000
treeherdermozilla-beta@48c44c0dbab7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, bajaj
bugs885582
milestone23.0
Bug 885582 - Append version number query parameter to Android about:healthreport URL. r=rnewman a=bajaj
mobile/android/chrome/content/aboutHealthReport.js
--- a/mobile/android/chrome/content/aboutHealthReport.js
+++ b/mobile/android/chrome/content/aboutHealthReport.js
@@ -13,16 +13,19 @@ Cu.import("resource://gre/modules/Shared
 
 // Name of Android SharedPreference controlling whether to upload
 // health reports.
 const PREF_UPLOAD_ENABLED = "android.not_a_preference.healthreport.uploadEnabled";
 
 // Name of Gecko Pref specifying report content location.
 const PREF_REPORTURL = "datareporting.healthreport.about.reportUrl";
 
+// Monotonically increasing wrapper API version number.
+const WRAPPER_VERSION = 1;
+
 const EVENT_HEALTH_REQUEST = "HealthReport:Request";
 const EVENT_HEALTH_RESPONSE = "HealthReport:Response";
 
 function sendMessageToJava(message) {
   return Cc["@mozilla.org/android/bridge;1"]
     .getService(Ci.nsIAndroidBridge)
     .handleGeckoMessage(JSON.stringify(message));
 }
@@ -32,16 +35,17 @@ function sendMessageToJava(message) {
 let sharedPrefs = new SharedPreferences();
 
 let healthReportWrapper = {
   init: function () {
     let iframe = document.getElementById("remote-report");
     iframe.addEventListener("load", healthReportWrapper.initRemotePage, false);
     let report = this._getReportURI();
     iframe.src = report.spec;
+    console.log("AboutHealthReport: loading content from " + report.spec);
 
     sharedPrefs.addObserver(PREF_UPLOAD_ENABLED, this, false);
     Services.obs.addObserver(this, EVENT_HEALTH_RESPONSE, false);
   },
 
   observe: function (subject, topic, data) {
     if (topic == PREF_UPLOAD_ENABLED) {
       this.updatePrefState();
@@ -52,17 +56,20 @@ let healthReportWrapper = {
 
   uninit: function () {
     sharedPrefs.removeObserver(PREF_UPLOAD_ENABLED, this);
     Services.obs.removeObserver(this, EVENT_HEALTH_RESPONSE);
   },
 
   _getReportURI: function () {
     let url = Services.urlFormatter.formatURLPref(PREF_REPORTURL);
-    return Services.io.newURI(url, null, null);
+    // This handles URLs that already have query parameters.
+    let uri = Services.io.newURI(url, null, null).QueryInterface(Ci.nsIURL);
+    uri.query += ((uri.query != "") ? "&v=" : "v=") + WRAPPER_VERSION;
+    return uri;
   },
 
   onOptIn: function () {
     console.log("AboutHealthReport: page sent opt-in command.");
     sharedPrefs.setBoolPref(PREF_UPLOAD_ENABLED, true);
     this.updatePrefState();
   },