Bug 1292323 - Update usage of UsesNativeCallProxy; r=snorp
authorJim Chen <nchen@mozilla.com>
Fri, 12 Aug 2016 23:15:53 -0400
changeset 309360 15a4865df1dceef073c23fa83c7776a303aa6c64
parent 309359 3e07a094e8c24f370b7f2b1dbdd16ad3188d5967
child 309361 4f12c8a5ea7146b9c306e883a7aa7471d93796d8
push id30561
push userkwierso@gmail.com
push dateMon, 15 Aug 2016 21:20:49 +0000
treeherdermozilla-central@91a319101587 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1292323
milestone51.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 1292323 - Update usage of UsesNativeCallProxy; r=snorp Remove uses of UsesNativeCallProxy and UsesGeckoThreadProxy, now that they are not needed. Remove cases where we had to invoke a call in a proxy, because the call is now specified to be invoked directly in the WrapForJNI annotation, without the need to go through the proxy. For SmsManager and AlarmReceiver, we no longer need to manually dispatch everything to the Gecko thread because that's now handled automatically.
dom/gamepad/android/AndroidGamepad.cpp
dom/mobilemessage/android/SmsManager.cpp
hal/android/AndroidAlarm.cpp
widget/android/GeckoNetworkManager.h
widget/android/GeckoScreenOrientation.h
widget/android/PrefsHelper.h
widget/android/Telemetry.h
widget/android/ThumbnailHelper.h
widget/android/nsAppShell.cpp
widget/android/nsWindow.cpp
--- a/dom/gamepad/android/AndroidGamepad.cpp
+++ b/dom/gamepad/android/AndroidGamepad.cpp
@@ -8,27 +8,20 @@
 #include "GeneratedJNINatives.h"
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 class AndroidGamepadManager final
   : public java::AndroidGamepadManager::Natives<AndroidGamepadManager>
-  , public jni::UsesNativeCallProxy
 {
   AndroidGamepadManager() = delete;
 
 public:
-  template<class Functor>
-  static void OnNativeCall(Functor&& aCall)
-  {
-    NS_DispatchToMainThread(NS_NewRunnableFunction(Move(aCall)));
-  }
-
   static void
   OnGamepadChange(int32_t aID, bool aAdded)
   {
     RefPtr<GamepadPlatformService> service =
         GamepadPlatformService::GetParentService();
     if (!service) {
       return;
     }
--- a/dom/mobilemessage/android/SmsManager.cpp
+++ b/dom/mobilemessage/android/SmsManager.cpp
@@ -10,17 +10,16 @@
 #include "mozilla/dom/mobilemessage/SmsParent.h"
 #include "mozilla/dom/mobilemessage/SmsTypes.h"
 #include "mozilla/dom/mobilemessage/Types.h"
 #include "MobileMessageThreadInternal.h"
 #include "SmsMessageInternal.h"
 #include "mozilla/Services.h"
 #include "nsIMobileMessageDatabaseService.h"
 #include "nsIObserverService.h"
-#include "nsThreadUtils.h"
 
 using namespace mozilla::dom;
 using namespace mozilla::dom::mobilemessage;
 
 namespace mozilla {
 
 /*static*/
 void
@@ -42,26 +41,23 @@ SmsManager::NotifySmsReceived(int32_t aI
     message.receiver() = EmptyString();
     message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = static_cast<MessageClass>(aMessageClass);
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aSentTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = false;
 
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=] () {
-        nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-        if (!obs) {
-            return;
-        }
+    nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+    if (!obs) {
+        return;
+    }
 
-        nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
-        obs->NotifyObservers(domMessage, kSmsReceivedObserverTopic, nullptr);
-    });
-    NS_DispatchToMainThread(runnable);
+    nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
+    obs->NotifyObservers(domMessage, kSmsReceivedObserverTopic, nullptr);
 }
 
 /*static*/
 void
 SmsManager::NotifySmsSent(int32_t aId,
                           jni::String::Param aReceiver,
                           jni::String::Param aBody,
                           int64_t aTimestamp,
@@ -79,38 +75,35 @@ SmsManager::NotifySmsSent(int32_t aId,
     message.receiver() = aReceiver ? aReceiver->ToString() : EmptyString();
     message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = eMessageClass_Normal;
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = true;
 
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        /*
-         * First, we are going to notify all SmsManager that a message has
-         * been sent. Then, we will notify the SmsRequest object about it.
-         */
-        nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-        if (!obs) {
-            return;
-        }
+    /*
+     * First, we are going to notify all SmsManager that a message has
+     * been sent. Then, we will notify the SmsRequest object about it.
+     */
+    nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+    if (!obs) {
+        return;
+    }
 
-        nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
-        obs->NotifyObservers(domMessage, kSmsSentObserverTopic, nullptr);
+    nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
+    obs->NotifyObservers(domMessage, kSmsSentObserverTopic, nullptr);
 
-        nsCOMPtr<nsIMobileMessageCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        request->NotifyMessageSent(domMessage);
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifyMessageSent(domMessage);
 }
 
 /*static*/
 void
 SmsManager::NotifySmsDelivery(int32_t aId,
                               int32_t aDeliveryStatus,
                               jni::String::Param aReceiver,
                               jni::String::Param aBody,
@@ -128,45 +121,39 @@ SmsManager::NotifySmsDelivery(int32_t aI
     message.receiver() = aReceiver ? aReceiver->ToString() : EmptyString();
     message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = eMessageClass_Normal;
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = true;
 
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-        if (!obs) {
-            return;
-        }
+    nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
+    if (!obs) {
+        return;
+    }
 
-        nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
-        const char* topic = (message.deliveryStatus() == eDeliveryStatus_Success)
-                            ? kSmsDeliverySuccessObserverTopic
-                            : kSmsDeliveryErrorObserverTopic;
-        obs->NotifyObservers(domMessage, topic, nullptr);
-    });
-    NS_DispatchToMainThread(runnable);
+    nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
+    const char* topic = (message.deliveryStatus() == eDeliveryStatus_Success)
+                        ? kSmsDeliverySuccessObserverTopic
+                        : kSmsDeliveryErrorObserverTopic;
+    obs->NotifyObservers(domMessage, topic, nullptr);
 }
 
 /*static*/
 void
 SmsManager::NotifySmsSendFailed(int32_t aError, int32_t aRequestId)
 {
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-        if(!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
+    if(!request) {
+        return;
+    }
 
-        request->NotifySendMessageFailed(aError, nullptr);
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifySendMessageFailed(aError, nullptr);
 }
 
 /*static*/
 void
 SmsManager::NotifyGetSms(int32_t aId,
                          int32_t aDeliveryStatus,
                          jni::String::Param aReceiver,
                          jni::String::Param aSender,
@@ -191,93 +178,78 @@ SmsManager::NotifyGetSms(int32_t aId,
     message.receiver() = receiver;
     message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = eMessageClass_Normal;
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = aRead;
 
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
-        request->NotifyMessageGot(domMessage);
-    });
-    NS_DispatchToMainThread(runnable);
+    nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
+    request->NotifyMessageGot(domMessage);
 }
 
 /*static*/
 void
 SmsManager::NotifyGetSmsFailed(int32_t aError, int32_t aRequestId)
 {
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        request->NotifyGetMessageFailed(aError);
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifyGetMessageFailed(aError);
 }
 
 /*static*/
 void
 SmsManager::NotifySmsDeleted(bool aDeleted, int32_t aRequestId)
 {
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        // For android, we support only single SMS deletion.
-        bool deleted = aDeleted;
-        request->NotifyMessageDeleted(&deleted, 1);
-    });
-    NS_DispatchToMainThread(runnable);
+    // For android, we support only single SMS deletion.
+    bool deleted = aDeleted;
+    request->NotifyMessageDeleted(&deleted, 1);
 }
 
 /*static*/
 void
 SmsManager::NotifySmsDeleteFailed(int32_t aError, int32_t aRequestId)
 {
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        request->NotifyDeleteMessageFailed(aError);
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifyDeleteMessageFailed(aError);
 }
 
 /*static*/
 void
 SmsManager::NotifyCursorError(int32_t aError, int32_t aRequestId)
 {
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCursorCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsCursorRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCursorCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsCursorRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        request->NotifyCursorError(aError);
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifyCursorError(aError);
 }
 
 /*static*/
 void
 SmsManager::NotifyThreadCursorResult(int64_t aId,
                                      jni::String::Param aLastMessageSubject,
                                      jni::String::Param aBody,
                                      int64_t aUnreadCount,
@@ -291,46 +263,44 @@ SmsManager::NotifyThreadCursorResult(int
     thread.lastMessageSubject() = aLastMessageSubject ?
                                     aLastMessageSubject->ToString() :
                                     EmptyString();
     thread.body() = aBody ? aBody->ToString() : EmptyString();
     thread.unreadCount() = aUnreadCount;
     thread.timestamp() = aTimestamp;
     thread.lastMessageType() = eMessageType_SMS;
 
-    JNIEnv* const env = jni::GetEnvForThread();
+    JNIEnv* const env = jni::GetGeckoThreadEnv();
 
     jobjectArray participants = aParticipants.Get();
     jsize length = env->GetArrayLength(participants);
     for (jsize i = 0; i < length; ++i) {
         jstring participant =
             static_cast<jstring>(env->GetObjectArrayElement(participants, i));
         if (participant) {
             thread.participants().AppendElement(nsJNIString(participant, env));
+            env->DeleteLocalRef(participant);
         }
     }
 
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCursorCallback> request =
-            AndroidBridge::Bridge()->GetSmsCursorRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCursorCallback> request =
+        AndroidBridge::Bridge()->GetSmsCursorRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        nsCOMArray<nsIMobileMessageThread> arr;
-        arr.AppendElement(new MobileMessageThreadInternal(thread));
+    nsCOMArray<nsIMobileMessageThread> arr;
+    arr.AppendElement(new MobileMessageThreadInternal(thread));
 
-        nsIMobileMessageThread** elements;
-        int32_t size;
-        size = arr.Forget(&elements);
+    nsIMobileMessageThread** elements;
+    int32_t size;
+    size = arr.Forget(&elements);
 
-        request->NotifyCursorResult(reinterpret_cast<nsISupports**>(elements),
-                                    size);
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifyCursorResult(reinterpret_cast<nsISupports**>(elements),
+                                size);
 }
 
 /*static*/
 void
 SmsManager::NotifyMessageCursorResult(int32_t aMessageId,
                                       int32_t aDeliveryStatus,
                                       jni::String::Param aReceiver,
                                       jni::String::Param aSender,
@@ -355,77 +325,65 @@ SmsManager::NotifyMessageCursorResult(in
     message.receiver() = receiver;
     message.body() = aBody ? aBody->ToString() : EmptyString();
     message.messageClass() = eMessageClass_Normal;
     message.timestamp() = aTimestamp;
     message.sentTimestamp() = aTimestamp;
     message.deliveryTimestamp() = aTimestamp;
     message.read() = aRead;
 
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCursorCallback> request =
-            AndroidBridge::Bridge()->GetSmsCursorRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCursorCallback> request =
+        AndroidBridge::Bridge()->GetSmsCursorRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        nsCOMArray<nsISmsMessage> arr;
-        arr.AppendElement(new SmsMessageInternal(message));
+    nsCOMArray<nsISmsMessage> arr;
+    arr.AppendElement(new SmsMessageInternal(message));
 
-        nsISmsMessage** elements;
-        int32_t size;
-        size = arr.Forget(&elements);
+    nsISmsMessage** elements;
+    int32_t size;
+    size = arr.Forget(&elements);
 
-        request->NotifyCursorResult(reinterpret_cast<nsISupports**>(elements),
-                                    size);
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifyCursorResult(reinterpret_cast<nsISupports**>(elements),
+                                size);
 }
 
 /*static*/
 void
 SmsManager::NotifyCursorDone(int32_t aRequestId)
 {
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCursorCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsCursorRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCursorCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsCursorRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        request->NotifyCursorDone();
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifyCursorDone();
 }
 
 /*static*/
 void
 SmsManager::NotifySmsMarkedAsRead(bool aMarkedAsRead, int32_t aRequestId)
 {
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        request->NotifyMessageMarkedRead(aMarkedAsRead);
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifyMessageMarkedRead(aMarkedAsRead);
 }
 
 /*static*/
 void
 SmsManager::NotifySmsMarkAsReadFailed(int32_t aError, int32_t aRequestId)
 {
-    nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-        nsCOMPtr<nsIMobileMessageCallback> request =
-            AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-        if (!request) {
-            return;
-        }
+    nsCOMPtr<nsIMobileMessageCallback> request =
+        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
+    if (!request) {
+        return;
+    }
 
-        request->NotifyMarkMessageReadFailed(aError);
-    });
-    NS_DispatchToMainThread(runnable);
+    request->NotifyMarkMessageReadFailed(aError);
 }
 
 } // namespace
--- a/hal/android/AndroidAlarm.cpp
+++ b/hal/android/AndroidAlarm.cpp
@@ -14,20 +14,17 @@ namespace mozilla {
 
 class AlarmReceiver : public java::AlarmReceiver::Natives<AlarmReceiver>
 {
 private:
     AlarmReceiver();
 
 public:
     static void NotifyAlarmFired() {
-        nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([=]() {
-            hal::NotifyAlarmFired();
-        });
-        NS_DispatchToMainThread(runnable);
+        hal::NotifyAlarmFired();
     }
 };
 
 namespace hal_impl {
 
 bool
 EnableAlarm()
 {
--- a/widget/android/GeckoNetworkManager.h
+++ b/widget/android/GeckoNetworkManager.h
@@ -12,17 +12,16 @@
 #include "nsINetworkLinkService.h"
 
 #include "mozilla/Services.h"
 
 namespace mozilla {
 
 class GeckoNetworkManager final
     : public java::GeckoNetworkManager::Natives<GeckoNetworkManager>
-    , public UsesGeckoThreadProxy
 {
     GeckoNetworkManager() = delete;
 
 public:
     static void
     OnConnectionChanged(int32_t aType, jni::String::Param aSubType,
                         bool aIsWifi, int32_t aGateway)
     {
--- a/widget/android/GeckoScreenOrientation.h
+++ b/widget/android/GeckoScreenOrientation.h
@@ -13,17 +13,16 @@
 
 #include "mozilla/Hal.h"
 #include "mozilla/dom/ScreenOrientation.h"
 
 namespace mozilla {
 
 class GeckoScreenOrientation final
     : public java::GeckoScreenOrientation::Natives<GeckoScreenOrientation>
-    , public UsesGeckoThreadProxy
 {
     GeckoScreenOrientation() = delete;
 
 public:
     static void
     OnOrientationChange(int16_t aOrientation, int16_t aAngle)
     {
         nsCOMPtr<nsIScreenManager> screenMgr =
--- a/widget/android/PrefsHelper.h
+++ b/widget/android/PrefsHelper.h
@@ -14,17 +14,16 @@
 
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 
 namespace mozilla {
 
 class PrefsHelper
     : public java::PrefsHelper::Natives<PrefsHelper>
-    , public UsesGeckoThreadProxy
 {
     PrefsHelper() = delete;
 
     static bool GetVariantPref(nsIObserverService* aObsServ,
                                nsIWritableVariant* aVariant,
                                jni::Object::Param aPrefHandler,
                                const jni::String::LocalRef& aPrefName)
     {
--- a/widget/android/Telemetry.h
+++ b/widget/android/Telemetry.h
@@ -12,17 +12,16 @@
 
 #include "mozilla/Telemetry.h"
 
 namespace mozilla {
 namespace widget {
 
 class Telemetry final
     : public java::Telemetry::Natives<Telemetry>
-    , public UsesGeckoThreadProxy
 {
     Telemetry() = delete;
 
     static already_AddRefed<nsIUITelemetryObserver>
     GetObserver()
     {
         nsAppShell* const appShell = nsAppShell::Get();
         if (!appShell) {
--- a/widget/android/ThumbnailHelper.h
+++ b/widget/android/ThumbnailHelper.h
@@ -24,17 +24,16 @@
 
 #include "mozilla/Preferences.h"
 
 namespace mozilla {
 
 class ThumbnailHelper final
     : public java::ThumbnailHelper::Natives<ThumbnailHelper>
     , public java::ZoomedView::Natives<ThumbnailHelper>
-    , public UsesGeckoThreadProxy
 {
     ThumbnailHelper() = delete;
 
     static already_AddRefed<mozIDOMWindowProxy>
     GetWindowForTab(int32_t aTabId)
     {
         nsAppShell* const appShell = nsAppShell::Get();
         if (!appShell) {
@@ -197,21 +196,16 @@ public:
     {
         java::ThumbnailHelper::Natives<ThumbnailHelper>::Init();
         java::ZoomedView::Natives<ThumbnailHelper>::Init();
     }
 
     template<class Functor>
     static void OnNativeCall(Functor&& aCall)
     {
-        if (!aCall.IsTarget(&RequestThumbnail)) {
-            UsesGeckoThreadProxy::OnNativeCall(Move(aCall));
-            return;
-        }
-
         class IdleEvent : public nsAppShell::LambdaEvent<Functor>
         {
             using Base = nsAppShell::LambdaEvent<Functor>;
 
         public:
             IdleEvent(Functor&& aCall)
                 : Base(Forward<Functor>(aCall))
             {}
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -91,33 +91,20 @@ public:
 
 NS_IMPL_ISUPPORTS(WakeLockListener, nsIDOMMozWakeLockListener)
 nsCOMPtr<nsIPowerManagerService> sPowerManagerService = nullptr;
 StaticRefPtr<WakeLockListener> sWakeLockListener;
 
 
 class GeckoThreadSupport final
     : public java::GeckoThread::Natives<GeckoThreadSupport>
-    , public UsesGeckoThreadProxy
 {
     static uint32_t sPauseCount;
 
 public:
-    template<typename Functor>
-    static void OnNativeCall(Functor&& aCall)
-    {
-        if (aCall.IsTarget(&SpeculativeConnect) ||
-            aCall.IsTarget(&WaitOnGecko)) {
-
-            aCall();
-            return;
-        }
-        return UsesGeckoThreadProxy::OnNativeCall(aCall);
-    }
-
     static void SpeculativeConnect(jni::String::Param aUriStr)
     {
         if (!NS_IsMainThread()) {
             // We will be on the main thread if the call was queued on the Java
             // side during startup. Otherwise, the call was not queued, which
             // means Gecko is already sufficiently loaded, and we don't really
             // care about speculative connections at this point.
             return;
@@ -196,44 +183,35 @@ public:
         // to foreground status
         nsCOMPtr<nsIObserverService> obsServ =
             mozilla::services::GetObserverService();
         obsServ->NotifyObservers(nullptr, "application-foreground", nullptr);
     }
 
     static void CreateServices(jni::String::Param aCategory, jni::String::Param aData)
     {
+        MOZ_ASSERT(NS_IsMainThread());
+
         nsCString category(aCategory->ToCString());
 
         NS_CreateServicesFromCategory(
                 category.get(),
                 nullptr, // aOrigin
                 category.get(),
                 aData ? aData->ToString().get() : nullptr);
     }
 };
 
 uint32_t GeckoThreadSupport::sPauseCount;
 
 
 class GeckoAppShellSupport final
     : public java::GeckoAppShell::Natives<GeckoAppShellSupport>
-    , public UsesGeckoThreadProxy
 {
 public:
-    template<typename Functor>
-    static void OnNativeCall(Functor&& aCall)
-    {
-        if (aCall.IsTarget(&SyncNotifyObservers)) {
-            aCall();
-            return;
-        }
-        return UsesGeckoThreadProxy::OnNativeCall(aCall);
-    }
-
     static void SyncNotifyObservers(jni::String::Param aTopic,
                                     jni::String::Param aData)
     {
         MOZ_RELEASE_ASSERT(NS_IsMainThread());
         NotifyObservers(aTopic, aData);
     }
 
     static void NotifyObservers(jni::String::Param aTopic,
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -179,17 +179,16 @@ public:
         return mEventType;
     }
 };
 
 class nsWindow::GeckoViewSupport final
     : public GeckoView::Window::Natives<GeckoViewSupport>
     , public GeckoEditable::Natives<GeckoViewSupport>
     , public SupportsWeakPtr<GeckoViewSupport>
-    , public UsesGeckoThreadProxy
 {
     nsWindow& window;
 
 public:
     typedef GeckoView::Window::Natives<GeckoViewSupport> Base;
     typedef GeckoEditable::Natives<GeckoViewSupport> EditableBase;
 
     MOZ_DECLARE_WEAKREFERENCE_TYPENAME(GeckoViewSupport);
@@ -875,17 +874,16 @@ public:
 
 /**
  * Compositor has some unique requirements for its native calls, so make it
  * separate from GeckoViewSupport.
  */
 class nsWindow::LayerViewSupport final
     : public LayerView::Compositor::Natives<LayerViewSupport>
     , public SupportsWeakPtr<LayerViewSupport>
-    , public UsesGeckoThreadProxy
 {
     nsWindow& window;
     LayerView::Compositor::GlobalRef mCompositor;
     GeckoLayerClient::GlobalRef mLayerClient;
     Atomic<bool, ReleaseAcquire> mCompositorPaused;
     mozilla::jni::GlobalRef<mozilla::jni::Object> mSurface;
 
     // In order to use Event::HasSameTypeAs in PostTo(), we cannot make
@@ -925,17 +923,16 @@ public:
     typedef LayerView::Compositor::Natives<LayerViewSupport> Base;
 
     MOZ_DECLARE_WEAKREFERENCE_TYPENAME(LayerViewSupport);
 
     template<class Functor>
     static void OnNativeCall(Functor&& aCall)
     {
         if (aCall.IsTarget(&LayerViewSupport::CreateCompositor)) {
-
             // This call is blocking.
             nsAppShell::SyncRunEvent(WindowEvent<Functor>(
                     mozilla::Move(aCall)), &LayerViewEvent::MakeEvent);
             return;
 
         } else if (aCall.IsTarget(
                 &LayerViewSupport::SyncResumeResizeCompositor)) {
             // This call is synchronous. Perform the original call using a copy
@@ -945,22 +942,16 @@ public:
             // object lifetimes for us.
             (Functor(aCall))();
             aCall.SetTarget(&LayerViewSupport::OnResumedCompositor);
             nsAppShell::PostEvent(
                     mozilla::MakeUnique<LayerViewEvent>(
                     mozilla::MakeUnique<WindowEvent<Functor>>(
                     mozilla::Move(aCall))));
             return;
-
-        } else if (aCall.IsTarget(
-                &LayerViewSupport::SyncInvalidateAndScheduleComposite) ||
-                aCall.IsTarget(&LayerViewSupport::SyncPauseCompositor)) {
-            // This call is synchronous.
-            return aCall();
         }
 
         // LayerViewEvent (i.e. prioritized event) applies to
         // CreateCompositor, PauseCompositor, and OnResumedCompositor. For all
         // other events, use regular WindowEvent.
         nsAppShell::PostEvent(
                 mozilla::MakeUnique<WindowEvent<Functor>>(
                 mozilla::Move(aCall)));