Bug 1294903: Add a default constructor to mscom::EnsureMTA that ensures that the MTA thread is running; r?jimm draft
authorAaron Klotz <aklotz@mozilla.com>
Tue, 15 Nov 2016 11:33:57 -0700
changeset 439276 1889d9571d123a0df5471f9c6e9fbc6323d9f85e
parent 437246 d38d06f85ef59c5dbb5d4a1a8d895957a78714de
child 439277 dcd266ffc6c073edcee493200796c1f1f931cdef
push id35953
push useraklotz@mozilla.com
push dateTue, 15 Nov 2016 18:36:56 +0000
reviewersjimm
bugs1294903
milestone52.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;