Backed out changesets 61314f00fede and 125947b0ec85 (bug 1267419) for Android test_get_last_visited.html failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 30 May 2016 14:21:00 -0400
changeset 333156 59db6ee36a9903b871f75d848c9a9ca0478cc5f1
parent 333155 bbabde19da559b30b75824b881165b6e38f66b35
child 333157 e5a71ecae4b453008c9191d874b4f76f3e3ac092
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)
bugs1267419
milestone48.0a2
backs out61314f00fede1a8e67a27e8169df43af2cf8eddf
125947b0ec85f5d8f5c1ba5849bd096e57437a15
Backed out changesets 61314f00fede and 125947b0ec85 (bug 1267419) for Android test_get_last_visited.html failures.
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
mobile/android/base/java/org/mozilla/gecko/push/PushService.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -31,16 +31,17 @@ import org.mozilla.gecko.preferences.Gec
 import org.mozilla.gecko.prompts.PromptService;
 import org.mozilla.gecko.restrictions.Restrictions;
 import org.mozilla.gecko.tabqueue.TabQueueHelper;
 import org.mozilla.gecko.text.FloatingToolbarTextSelection;
 import org.mozilla.gecko.text.TextSelection;
 import org.mozilla.gecko.updater.UpdateServiceHelper;
 import org.mozilla.gecko.util.ActivityResultHandler;
 import org.mozilla.gecko.util.ActivityUtils;
+import org.mozilla.gecko.util.BundleEventListener;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.FileUtils;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.GeckoRequest;
 import org.mozilla.gecko.util.HardwareUtils;
 import org.mozilla.gecko.util.NativeEventListener;
 import org.mozilla.gecko.util.NativeJSObject;
 import org.mozilla.gecko.util.PrefUtils;
@@ -121,16 +122,17 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
 public abstract class GeckoApp
     extends GeckoActivity
     implements
+    BundleEventListener,
     ContextGetter,
     GeckoAppShell.GeckoInterface,
     GeckoEventListener,
     GeckoMenu.Callback,
     GeckoMenu.MenuPresenter,
     LocationListener,
     NativeEventListener,
     SensorEventListener,
@@ -701,16 +703,34 @@ public abstract class GeckoApp
             } else if (event.equals("Accessibility:Event")) {
                 GeckoAccessibility.sendAccessibilityEvent(message);
             }
         } catch (Exception e) {
             Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
         }
     }
 
+    @Override
+    public void handleMessage(final String event, final Bundle message, final EventCallback callback) {
+        if ("History:GetPrePathLastVisitedTimeMilliseconds".equals(event)) {
+            if (callback == null) {
+                Log.e(LOGTAG, "callback must not be null in " + event);
+                return;
+            }
+            final String prePath = message.getString("prePath");
+            if (prePath == null) {
+                callback.sendError("prePath must not be null in " + event);
+                return;
+            }
+            // We're on a background thread, so we can be synchronous.
+            final long millis = getProfile().getDB().getPrePathLastVisitedTimeMilliseconds(getContentResolver(), prePath);
+            callback.sendSuccess(millis);
+        }
+    }
+
     void onStatePurged() { }
 
     /**
      * @param permissions
      *        Array of JSON objects to represent site permissions.
      *        Example: { type: "offline-app", setting: "Store Offline Data", value: "Allow" }
      */
     private void showSiteSettingsDialog(final NativeJSObject[] permissions) {
@@ -1214,16 +1234,19 @@ public abstract class GeckoApp
             "SystemUI:Visibility",
             "ToggleChrome:Focus",
             "ToggleChrome:Hide",
             "ToggleChrome:Show",
             "Update:Check",
             "Update:Download",
             "Update:Install");
 
+        EventDispatcher.getInstance().registerBackgroundThreadListener((BundleEventListener) this,
+                "History:GetPrePathLastVisitedTimeMilliseconds");
+
         GeckoThread.launch();
 
         Bundle stateBundle = ContextUtils.getBundleExtra(getIntent(), EXTRA_STATE_BUNDLE);
         if (stateBundle != null) {
             // Use the state bundle if it was given as an intent extra. This is
             // only intended to be used internally via Robocop, so a boolean
             // is read from a private shared pref to prevent other apps from
             // injecting states.
@@ -2112,16 +2135,19 @@ public abstract class GeckoApp
             "SystemUI:Visibility",
             "ToggleChrome:Focus",
             "ToggleChrome:Hide",
             "ToggleChrome:Show",
             "Update:Check",
             "Update:Download",
             "Update:Install");
 
+        EventDispatcher.getInstance().unregisterBackgroundThreadListener((BundleEventListener) this,
+                "History:GetPrePathLastVisitedTimeMilliseconds");
+
         deleteTempFiles();
 
         if (mDoorHangerPopup != null)
             mDoorHangerPopup.destroy();
         if (mFormAssistPopup != null)
             mFormAssistPopup.destroy();
         if (mContactService != null)
             mContactService.destroy();
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
@@ -907,17 +907,17 @@ public class GeckoAppShell
         // Put the strings into the intent as an URI "alert:?name=<alertName>&app=<appName>&cookie=<cookie>"
         Uri.Builder b = new Uri.Builder();
         Uri dataUri = b.scheme("alert").path(Integer.toString(notificationID))
                                        .appendQueryParameter("name", aAlertName)
                                        .appendQueryParameter("cookie", aAlertCookie)
                                        .build();
         notificationIntent.setData(dataUri);
         PendingIntent contentIntent = PendingIntent.getActivity(
-                getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+                getContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
 
         ALERT_COOKIES.put(aAlertName, aAlertCookie);
         callObserver(aAlertName, "alertshow", aAlertCookie);
 
         notificationClient.add(notificationID, aImageUrl, aHost, aAlertTitle, aAlertText, contentIntent);
     }
 
     @WrapForJNI
--- a/mobile/android/base/java/org/mozilla/gecko/push/PushService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/push/PushService.java
@@ -58,17 +58,16 @@ public class PushService implements Bund
             "PushServiceAndroidGCM:DumpRegistration",
             "PushServiceAndroidGCM:DumpSubscriptions",
             "PushServiceAndroidGCM:Initialized",
             "PushServiceAndroidGCM:Uninitialized",
             "PushServiceAndroidGCM:RegisterUserAgent",
             "PushServiceAndroidGCM:UnregisterUserAgent",
             "PushServiceAndroidGCM:SubscribeChannel",
             "PushServiceAndroidGCM:UnsubscribeChannel",
-            "History:GetPrePathLastVisitedTimeMilliseconds",
     };
 
     public static synchronized PushService getInstance() {
         if (sInstance == null) {
             throw new IllegalStateException("PushService not yet created!");
         }
         return sInstance;
     }
@@ -226,20 +225,19 @@ public class PushService implements Bund
         EventDispatcher.getInstance().unregisterBackgroundThreadListener(this, GECKO_EVENTS);
     }
 
     @Override
     public void handleMessage(final String event, final Bundle message, final EventCallback callback) {
         Log.i(LOG_TAG, "Handling event: " + event);
         ThreadUtils.assertOnBackgroundThread();
 
-        final Context context = GeckoAppShell.getApplicationContext();
         // We're invoked in response to a Gecko message on a background thread.  We should always
         // be able to safely retrieve the current Gecko profile.
-        final GeckoProfile geckoProfile = GeckoProfile.get(context);
+        final GeckoProfile geckoProfile = GeckoProfile.get(GeckoAppShell.getApplicationContext());
 
         if (callback == null) {
             Log.e(LOG_TAG, "callback must not be null in " + event);
             return;
         }
 
         try {
             if ("PushServiceAndroidGCM:Configure".equals(event)) {
@@ -358,32 +356,16 @@ public class PushService implements Bund
                     Telemetry.sendUIEvent(TelemetryContract.Event.UNSAVE, TelemetryContract.Method.SERVICE, "dom-push-api");
                     callback.sendSuccess(null);
                     return;
                 }
 
                 callback.sendError("Could not unsubscribe from channel: " + channelID);
                 return;
             }
-            if ("History:GetPrePathLastVisitedTimeMilliseconds".equals(event)) {
-                if (callback == null) {
-                    Log.e(LOG_TAG, "callback must not be null in " + event);
-                    return;
-                }
-                final String prePath = message.getString("prePath");
-                if (prePath == null) {
-                    callback.sendError("prePath must not be null in " + event);
-                    return;
-                }
-                // We're on a background thread, so we can be synchronous.
-                final long millis = geckoProfile.getDB().getPrePathLastVisitedTimeMilliseconds(
-                        context.getContentResolver(), prePath);
-                callback.sendSuccess(millis);
-                return;
-            }
         } catch (GcmTokenClient.NeedsGooglePlayServicesException e) {
             // TODO: improve this.  Can we find a point where the user is *definitely* interacting
             // with the WebPush?  Perhaps we can show a dialog when interacting with the Push
             // permissions, and then be more aggressive showing this notification when we have
             // registrations and subscriptions that can't be advanced.
             callback.sendError("To handle event [" + event + "], user interaction is needed to enable Google Play Services.");
         }
     }