Backed out changeset 6ccfb75c8926 (bug 1260499) for wrong patch
authorWilliam Chen <wchen@mozilla.com>
Wed, 13 Apr 2016 15:37:48 -0700
changeset 330991 0866e929d9e15b00fe85164cac0c09f48c7aba1e
parent 330990 3e17cc4625da9c00f7815f215d89bd3b1af68e2d
child 330992 d37a1a6cbf8f4f8d9b0d439cf3240e215537ca67
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1260499
milestone48.0a1
backs out6ccfb75c8926488004183b9a4bd3aa0ea66b2fba
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
Backed out changeset 6ccfb75c8926 (bug 1260499) for wrong patch
dom/push/PushServiceAndroidGCM.jsm
mobile/android/base/java/org/mozilla/gecko/push/PushService.java
--- a/dom/push/PushServiceAndroidGCM.jsm
+++ b/dom/push/PushServiceAndroidGCM.jsm
@@ -142,29 +142,21 @@ this.PushServiceAndroidGCM = {
   init: function(options, mainPushService, serverURL) {
     console.debug("init()");
     this._mainPushService = mainPushService;
     this._serverURI = serverURL;
 
     prefs.observe("debug", this);
     Services.obs.addObserver(this, "PushServiceAndroidGCM:ReceivedPushMessage", false);
 
-    return this._configure(serverURL, !!prefs.get("debug")).then(() => {
-      return Messaging.sendRequestForResult({
-        type: "PushServiceAndroidGCM:Initialized"
-      });
-    });
+    return this._configure(serverURL, !!prefs.get("debug"));
   },
 
   uninit: function() {
     console.debug("uninit()");
-    Messaging.sendRequest({
-      type: "PushServiceAndroidGCM:Uninitialized"
-    });
-
     this._mainPushService = null;
     Services.obs.removeObserver(this, "PushServiceAndroidGCM:ReceivedPushMessage");
     prefs.ignore("debug", this);
   },
 
   onAlarmFired: function() {
     // No action required.
   },
--- a/mobile/android/base/java/org/mozilla/gecko/push/PushService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/push/PushService.java
@@ -21,46 +21,38 @@ import org.mozilla.gecko.TelemetryContra
 import org.mozilla.gecko.annotation.ReflectionTarget;
 import org.mozilla.gecko.gcm.GcmTokenClient;
 import org.mozilla.gecko.push.autopush.AutopushClientException;
 import org.mozilla.gecko.util.BundleEventListener;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
 import java.util.Map;
 
 /**
  * Class that handles messages used in the Google Cloud Messaging and DOM push API integration.
  * <p/>
  * This singleton services Gecko messages from dom/push/PushServiceAndroidGCM.jsm and Google Cloud
  * Messaging requests.
  * <p/>
- * It is expected that Gecko is started (if not already running) soon after receiving GCM messages
- * otherwise there is a greater risk that pending messages that have not been handle by Gecko will
- * be lost if this service is killed.
- * <p/>
  * It's worth noting that we allow the DOM push API in restricted profiles.
  */
 @ReflectionTarget
 public class PushService implements BundleEventListener {
     private static final String LOG_TAG = "GeckoPushService";
 
     public static final String SERVICE_WEBPUSH = "webpush";
 
     private static PushService sInstance;
 
     private static final String[] GECKO_EVENTS = new String[]{
             "PushServiceAndroidGCM:Configure",
             "PushServiceAndroidGCM:DumpRegistration",
             "PushServiceAndroidGCM:DumpSubscriptions",
-            "PushServiceAndroidGCM:Initialized",
-            "PushServiceAndroidGCM:Uninitialized",
             "PushServiceAndroidGCM:RegisterUserAgent",
             "PushServiceAndroidGCM:UnregisterUserAgent",
             "PushServiceAndroidGCM:SubscribeChannel",
             "PushServiceAndroidGCM:UnsubscribeChannel",
     };
 
     public static synchronized PushService getInstance() {
         if (sInstance == null) {
@@ -77,29 +69,23 @@ public class PushService implements Bund
         sInstance = new PushService(context);
 
         sInstance.registerGeckoEventListener();
         sInstance.onStartup();
     }
 
     protected final PushManager pushManager;
 
-    private boolean canSendPushMessagesToGecko;
-
-    private final List<String> pendingPushMessages;
-
     public PushService(Context context) {
         pushManager = new PushManager(new PushState(context, "GeckoPushState.json"), new GcmTokenClient(context), new PushManager.PushClientFactory() {
             @Override
             public PushClient getPushClient(String autopushEndpoint, boolean debug) {
                 return new PushClient(autopushEndpoint);
             }
         });
-
-        pendingPushMessages = new LinkedList<String>();
     }
 
     public void onStartup() {
         Log.i(LOG_TAG, "Starting up.");
         ThreadUtils.assertOnBackgroundThread();
 
         try {
             pushManager.startup(System.currentTimeMillis());
@@ -192,36 +178,23 @@ public class PushService implements Bund
                 data.put("cryptokey", bundle.getString("cryptokey"));
                 data.put("enckey", bundle.getString("enckey"));
                 data.put("message", bundle.getString("body"));
             } catch (JSONException e) {
                 Log.e(LOG_TAG, "Got exception delivering dom/push message to Gecko!", e);
                 return;
             }
 
-            enqueueOrSendMessage(data.toString());
+            Log.i(LOG_TAG, "Delivering dom/push message to Gecko!");
+            GeckoAppShell.notifyObservers("PushServiceAndroidGCM:ReceivedPushMessage", data.toString());
         } else {
             Log.e(LOG_TAG, "Message directed to unknown service; dropping: " + subscription.service);
         }
     }
 
-    protected void enqueueOrSendMessage(final @NonNull String message) {
-        if (canSendPushMessagesToGecko) {
-            sendMessageToGeckoService(message);
-        } else {
-            Log.i(LOG_TAG, "Service not initialized, adding message to queue.");
-            pendingPushMessages.add(message);
-        }
-    }
-
-    protected void sendMessageToGeckoService(final @NonNull String message) {
-        Log.i(LOG_TAG, "Delivering dom/push message to Gecko!");
-        GeckoAppShell.notifyObservers("PushServiceAndroidGCM:ReceivedPushMessage", message);
-    }
-
     protected void registerGeckoEventListener() {
         Log.d(LOG_TAG, "Registered Gecko event listener.");
         EventDispatcher.getInstance().registerBackgroundThreadListener(this, GECKO_EVENTS);
     }
 
     protected void unregisterGeckoEventListener() {
         Log.d(LOG_TAG, "Unregistered Gecko event listener.");
         EventDispatcher.getInstance().unregisterBackgroundThreadListener(this, GECKO_EVENTS);
@@ -268,34 +241,16 @@ public class PushService implements Bund
                         json.put(entry.getKey(), entry.getValue().toJSONObject());
                     }
                     callback.sendSuccess(json);
                 } catch (JSONException e) {
                     callback.sendError("Got exception handling message [" + event + "]: " + e.toString());
                 }
                 return;
             }
-            if ("PushServiceAndroidGCM:Initialized".equals(event)) {
-                // Send all pending messages to Gecko and set the
-                // canSendPushMessageToGecko flag to true so that
-                // all new push messages are sent directly to Gecko
-                // instead of being queued.
-                canSendPushMessagesToGecko = true;
-                for (String pushMessage : pendingPushMessages) {
-                    sendMessageToGeckoService(pushMessage);
-                }
-                pendingPushMessages.clear();
-                callback.sendSuccess(null);
-                return;
-            }
-            if ("PushServiceAndroidGCM:Uninitialized".equals(event)) {
-                canSendPushMessagesToGecko = false;
-                callback.sendSuccess(null);
-                return;
-            }
             if ("PushServiceAndroidGCM:RegisterUserAgent".equals(event)) {
                 try {
                     pushManager.registerUserAgent(geckoProfile.getName(), System.currentTimeMillis()); // For side-effects.
                     callback.sendSuccess(null);
                 } catch (PushManager.ProfileNeedsConfigurationException | AutopushClientException | PushClient.LocalException | IOException e) {
                     Log.e(LOG_TAG, "Got exception in " + event, e);
                     callback.sendError("Got exception handling message [" + event + "]: " + e.toString());
                 }