Bug 1012462 - Part 6: Change Distribution.init() to return an instance (r=rnewman)
authorLucas Rocha <lucasr@mozilla.com>
Tue, 15 Jul 2014 20:54:27 +0100
changeset 216239 13b4b1b388e270cba618a1432410be4ab484e838
parent 216238 6cd4b8d5036c120827894ca0befb96ca789ddf22
child 216240 b9398f6def8be04dccab147645572268bbca052a
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1012462
milestone33.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 1012462 - Part 6: Change Distribution.init() to return an instance (r=rnewman)
mobile/android/base/distribution/Distribution.java
--- a/mobile/android/base/distribution/Distribution.java
+++ b/mobile/android/base/distribution/Distribution.java
@@ -176,47 +176,49 @@ public class Distribution {
 
             this.localizedAbout = Collections.unmodifiableMap(loc);
             this.valid = (null != this.id) &&
                          (null != this.version) &&
                          (null != this.about);
         }
     }
 
-    private static void init(final Distribution distribution) {
+    private static Distribution init(final Distribution distribution) {
         // Read/write preferences and files on the background thread.
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
             public void run() {
                 boolean distributionSet = distribution.doInit();
                 if (distributionSet) {
                     GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Distribution:Set", ""));
                 }
             }
         });
+
+        return distribution;
     }
 
     /**
      * Initializes distribution if it hasn't already been initialized. Sends
      * messages to Gecko as appropriate.
      *
      * @param packagePath where to look for the distribution directory.
      */
     @RobocopTarget
-    public static void init(final Context context, final String packagePath, final String prefsPath) {
-        init(new Distribution(context, packagePath, prefsPath));
+    public static Distribution init(final Context context, final String packagePath, final String prefsPath) {
+        return init(new Distribution(context, packagePath, prefsPath));
     }
 
     /**
      * Use <code>Context.getPackageResourcePath</code> to find an implicit
      * package path. Reuses the existing Distribution if one exists.
      */
     @RobocopTarget
-    public static void init(final Context context) {
-        Distribution.init(Distribution.getInstance(context));
+    public static Distribution init(final Context context) {
+        return init(Distribution.getInstance(context));
     }
 
     /**
      * Returns parsed contents of bookmarks.json.
      * This method should only be called from a background thread.
      */
     public static JSONArray getBookmarks(final Context context) {
         Distribution dist = new Distribution(context);