Bug 1319850 - part 1, Add MessagePumpForAndroidUI r=nfroyd
☠☠ backed out by b1213723e156 ☠ ☠
authorRandall Barker <rbarker@mozilla.com>
Wed, 30 Nov 2016 14:56:53 -0800
changeset 327100 8717bea884c99079359f7cfcc1e1ecea46b61ed9
parent 327099 7e747433d1c9fae8a0acb4090f61335fcc165e4c
child 327101 2a8012945a74914ef0d51052d4fbdbf637d06573
push id31119
push userkwierso@gmail.com
push dateFri, 23 Dec 2016 22:34:59 +0000
treeherdermozilla-central@da22155a2dc3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1319850
milestone53.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 1319850 - part 1, Add MessagePumpForAndroidUI r=nfroyd
ipc/glue/MessagePump.cpp
ipc/glue/MessagePump.h
--- a/ipc/glue/MessagePump.cpp
+++ b/ipc/glue/MessagePump.cpp
@@ -458,8 +458,34 @@ MessagePumpForNonMainUIThreads::OnProces
 NS_IMETHODIMP
 MessagePumpForNonMainUIThreads::AfterProcessNextEvent(nsIThreadInternal *thread,
                                                       bool eventWasProcessed)
 {
   return NS_OK;
 }
 
 #endif // XP_WIN
+
+#if defined(MOZ_WIDGET_ANDROID)
+void
+MessagePumpForAndroidUI::Run(Delegate* delegate)
+{
+  MOZ_CRASH("MessagePumpForAndroidUI should never be Run.");
+}
+
+void
+MessagePumpForAndroidUI::Quit()
+{
+  MOZ_CRASH("MessagePumpForAndroidUI should never be Quit.");
+}
+
+void
+MessagePumpForAndroidUI::ScheduleWork()
+{
+  MOZ_CRASH("MessagePumpForAndroidUI should never ScheduleWork");
+}
+
+void
+MessagePumpForAndroidUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time)
+{
+  MOZ_CRASH("MessagePumpForAndroidUI should never ScheduleDelayedWork");
+}
+#endif // defined(MOZ_WIDGET_ANDROID)
--- a/ipc/glue/MessagePump.h
+++ b/ipc/glue/MessagePump.h
@@ -159,12 +159,49 @@ private:
   {
   }
 
   bool mInWait;
   mozilla::Mutex mWaitLock;
 };
 #endif // defined(XP_WIN)
 
+#if defined(MOZ_WIDGET_ANDROID)
+/*`
+ * The MessagePumpForAndroidUI exists to enable IPDL in the Android UI thread. The Android
+ * UI thread event loop is controlled by Android. This prevents running an existing
+ * MessagePump implementation in the Android UI thread. In order to enable IPDL on the
+ * Android UI thread it is necessary to have a non-looping MessagePump. This class enables
+ * forwarding of nsIRunnables from MessageLoop::PostTask_Helper to the registered
+ * nsIEventTarget with out the need to control the event loop. The only member function
+ * that should be invoked is GetXPCOMThread. All other member functions will invoke MOZ_CRASH
+*/
+class MessagePumpForAndroidUI : public base::MessagePump {
+
+public:
+  MessagePumpForAndroidUI(nsIEventTarget* aEventTarget)
+    : mEventTarget(aEventTarget)
+  { }
+
+  virtual void Run(Delegate* delegate);
+  virtual void Quit();
+  virtual void ScheduleWork();
+  virtual void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time);
+  virtual nsIEventTarget* GetXPCOMThread()
+  {
+    return mEventTarget;
+  }
+
+private:
+  ~MessagePumpForAndroidUI()
+  { }
+  MessagePumpForAndroidUI()
+  { }
+
+  nsIEventTarget* mEventTarget;
+};
+#endif // defined(MOZ_WIDGET_ANDROID)
+
+
 } /* namespace ipc */
 } /* namespace mozilla */
 
 #endif /* __IPC_GLUE_MESSAGEPUMP_H__ */