Bug 1198009 - Add support to BrowserHealthRecorder for making a snapshot of active experiments in a new profile r=rnewman
authorMark Finkle <mfinkle@mozilla.com>
Sat, 12 Sep 2015 19:26:51 -0400
changeset 294803 13f2b1fad74b5b4f93ee0aaf529eb60681112fa3
parent 294802 b07426112b4520bb263afdd9202ab81632eec262
child 294804 085137ec0ab2905eaafaf572317e4ad51f162d63
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1198009
milestone43.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 1198009 - Add support to BrowserHealthRecorder for making a snapshot of active experiments in a new profile r=rnewman
mobile/android/base/health/BrowserHealthRecorder.java
--- a/mobile/android/base/health/BrowserHealthRecorder.java
+++ b/mobile/android/base/health/BrowserHealthRecorder.java
@@ -637,16 +637,33 @@ public class BrowserHealthRecorder exten
     @Override
     public void handleMessage(String event, JSONObject message) {
         try {
             if (EVENT_SNAPSHOT.equals(event)) {
                 Log.d(LOG_TAG, "Got all add-ons and prefs.");
                 try {
                     JSONObject json = message.getJSONObject("json");
                     JSONObject addons = json.getJSONObject("addons");
+
+                    // Treat active experiments as add-ons
+                    if (AppConstants.MOZ_SWITCHBOARD) {
+                        List<String> experiments = SwitchBoard.getActiveExperiments(GeckoAppShell.getContext());
+                        for (String experiment : experiments) {
+                            // Create a fake add-on name
+                            String fakeName = experiment + "@experiments.mozilla.org";
+                            try {
+                                // Create a dummy JSON object for the experiment.
+                                JSONObject fakeAddon = new JSONObject();
+                                fakeAddon.put("type", "experiment");
+                                addons.put(fakeName, fakeAddon);
+                            } catch (JSONException je) {
+                            }
+                        }
+                    }
+
                     Log.i(LOG_TAG, "Persisting " + addons.length() + " add-ons.");
                     profileCache.setJSONForAddons(addons);
 
                     JSONObject prefs = json.getJSONObject("prefs");
                     Log.i(LOG_TAG, "Persisting prefs.");
                     Iterator<?> keys = prefs.keys();
                     while (keys.hasNext()) {
                         String pref = (String) keys.next();