Bug 938827 - Part 9: Remove unregisterEventListener reflection. r=rnewman
authorMichael Comella <michael.l.comella@gmail.com>
Fri, 06 Dec 2013 11:43:12 -0800
changeset 174923 16a66a870a7a411434c0eee0516c3ea04b9b46aa
parent 174922 6607f4bf80e5f6f2906af327cea7ff527dbc11c3
child 174924 3778c2024dbeaa892954507bd96fd562bff32bd0
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs938827
milestone28.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 938827 - Part 9: Remove unregisterEventListener reflection. r=rnewman
build/mobile/robocop/FennecNativeActions.java
mobile/android/base/GeckoAppShell.java
mobile/android/base/RobocopAPI.java
--- a/build/mobile/robocop/FennecNativeActions.java
+++ b/build/mobile/robocop/FennecNativeActions.java
@@ -37,19 +37,17 @@ import static org.mozilla.gecko.FennecNa
 public class FennecNativeActions implements Actions {
     private Solo mSolo;
     private Instrumentation mInstr;
     private Assert mAsserter;
 
     // Objects for reflexive access of fennec classes.
     private ClassLoader mClassLoader;
     private Class mApiClass;
-    private Class mEventListenerClass;
     private Class mDrawListenerClass;
-    private Method mUnregisterEventListener;
     private Method mSetDrawListener;
     private Object mRobocopApi;
 
     private static final String LOGTAG = "FennecNativeActions";
 
     public FennecNativeActions(Activity activity, Solo robocop, Instrumentation instrumentation, Assert asserter) {
         mSolo = robocop;
         mInstr = instrumentation;
@@ -57,20 +55,18 @@ public class FennecNativeActions impleme
 
         GeckoLoader.loadSQLiteLibs(activity, activity.getApplication().getPackageResourcePath());
 
         // Set up reflexive access of java classes and methods.
         try {
             mClassLoader = activity.getClassLoader();
 
             mApiClass = mClassLoader.loadClass("org.mozilla.gecko.RobocopAPI");
-            mEventListenerClass = mClassLoader.loadClass("org.mozilla.gecko.util.GeckoEventListener");
             mDrawListenerClass = mClassLoader.loadClass("org.mozilla.gecko.gfx.GeckoLayerClient$DrawListener");
 
-            mUnregisterEventListener = mApiClass.getMethod("unregisterEventListener", String.class, mEventListenerClass);
             mSetDrawListener = mApiClass.getMethod("setDrawListener", mDrawListenerClass);
 
             mRobocopApi = mApiClass.getConstructor(Activity.class).newInstance(activity);
         } catch (Exception e) {
             FennecNativeDriver.log(LogLevel.ERROR, e);
         }
     }
 
@@ -184,27 +180,21 @@ public class FennecNativeActions impleme
             return mEventData;
         }
 
         public void unregisterListener() {
             if (!mIsRegistered) {
                 throw new IllegalStateException("listener not registered");
             }
 
-            try {
-                FennecNativeDriver.log(LogLevel.INFO, "EventExpecter: no longer listening for "+mGeckoEvent);
+            FennecNativeDriver.log(LogLevel.INFO,
+                    "EventExpecter: no longer listening for " + mGeckoEvent);
 
-                mUnregisterEventListener.invoke(mRobocopApi,
-                        new Object[] { mGeckoEvent, mListener });
-                mIsRegistered = false;
-            } catch (IllegalAccessException e) {
-                FennecNativeDriver.log(LogLevel.ERROR, e);
-            } catch (InvocationTargetException e) {
-                FennecNativeDriver.log(LogLevel.ERROR, e);
-            }
+            GeckoAppShell.unregisterEventListener(mGeckoEvent, mListener);
+            mIsRegistered = false;
         }
 
         public boolean eventReceived() {
             return mEventEverReceived;
         }
 
         void notifyOfEvent(final JSONObject message) {
             FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG,
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -2302,16 +2302,17 @@ public class GeckoAppShell
 
     /**
      * Remove a previously-registered listener for a gecko event.
      * This method is thread-safe and may be called at any time. In particular, calling it
      * with an event that is currently being processed has the properly-defined behaviour that
      * any removed listeners will still be invoked on the event currently being processed, but
      * will not be invoked on future events of that type.
      */
+    @RobocopTarget
     public static void unregisterEventListener(String event, GeckoEventListener listener) {
         sEventDispatcher.unregisterEventListener(event, listener);
     }
 
     /*
      * Battery API related methods.
      */
     @WrapElementForJNI
--- a/mobile/android/base/RobocopAPI.java
+++ b/mobile/android/base/RobocopAPI.java
@@ -36,16 +36,12 @@ import java.util.List;
 @RobocopTarget
 public class RobocopAPI {
     private final GeckoApp mGeckoApp;
 
     public RobocopAPI(Activity activity) {
         mGeckoApp = (GeckoApp)activity;
     }
 
-    public void unregisterEventListener(String event, GeckoEventListener listener) {
-        GeckoAppShell.unregisterEventListener(event, listener);
-    }
-
     public void setDrawListener(GeckoLayerClient.DrawListener listener) {
         GeckoAppShell.getLayerView().getLayerClient().setDrawListener(listener);
     }
 }