Bug 1294903: Add a default constructor to mscom::EnsureMTA that ensures that the MTA thread is running; r=jimm
authorAaron Klotz <aklotz@mozilla.com>
Tue, 15 Nov 2016 11:33:57 -0700
changeset 322895 be0fb2d8d0368ddfc49a977332f6338ec0110ccb
parent 322722 530bbb41afc4bc18fc02049c529b18e071595848
child 322896 eae1056ae373b94d922c3a78cfaf72b3f80190b2
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersjimm
bugs1294903
milestone53.0a1
Bug 1294903: Add a default constructor to mscom::EnsureMTA that ensures that the MTA thread is running; r=jimm MozReview-Commit-ID: IN4maTgdL4l
ipc/mscom/EnsureMTA.h
--- a/ipc/mscom/EnsureMTA.h
+++ b/ipc/mscom/EnsureMTA.h
@@ -21,16 +21,26 @@
 
 namespace mozilla {
 namespace mscom {
 
 // This class is OK to use as a temporary on the stack.
 class MOZ_STACK_CLASS EnsureMTA
 {
 public:
+  /**
+   * This constructor just ensures that the MTA thread is up and running.
+   */
+  EnsureMTA()
+  {
+    MOZ_ASSERT(NS_IsMainThread());
+    nsCOMPtr<nsIThread> thread = GetMTAThread();
+    MOZ_ASSERT(thread);
+  }
+
   template <typename FuncT>
   EnsureMTA(const FuncT& aClosure)
   {
     MOZ_ASSERT(NS_IsMainThread());
     if (IsCurrentThreadMTA()) {
       // We're already on the MTA, we can run aClosure directly
       aClosure();
       return;