Backed out 4 changesets (bug 1489317) for windows test failures CLOSED TREE
authorCiure Andrei <aciure@mozilla.com>
Tue, 11 Sep 2018 04:22:44 +0300
changeset 494032 91136930be6477b2c2495e2045874c437a9a94bb
parent 494031 c661bb000e34e56ab7780ff6053e0dd628dfc0e2
child 494033 91109fedb3b07acf96bc93229b18fdd6a37f35e3
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1489317
milestone64.0a1
backs out07b44bee061cf080e70e6872f5f15e22e23819e0
b340f5acb7b58a9a00b7190cf9a710712b34e18f
62b404e59c325af23d9133a5e18cc7cc477cafdd
2787fb454f40584ad146c61fd9b375c419efe803
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
Backed out 4 changesets (bug 1489317) for windows test failures CLOSED TREE Backed out changeset 07b44bee061c (bug 1489317) Backed out changeset b340f5acb7b5 (bug 1489317) Backed out changeset 62b404e59c32 (bug 1489317) Backed out changeset 2787fb454f40 (bug 1489317)
ipc/mscom/AgileReference.cpp
ipc/mscom/AgileReference.h
ipc/mscom/Utils.cpp
ipc/mscom/Utils.h
mfbt/RefPtr.h
widget/windows/JumpListBuilder.cpp
widget/windows/JumpListBuilder.h
--- a/ipc/mscom/AgileReference.cpp
+++ b/ipc/mscom/AgileReference.cpp
@@ -1,21 +1,20 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/mscom/AgileReference.h"
 
-#include "mozilla/Assertions.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/DynamicallyLinkedFunctionPtr.h"
+#include "mozilla/Assertions.h"
 #include "mozilla/Move.h"
-#include "mozilla/mscom/Utils.h"
 
 #if NTDDI_VERSION < NTDDI_WINBLUE
 
 // Declarations from Windows SDK specific to Windows 8.1
 
 enum AgileReferenceOptions
 {
     AGILEREFERENCE_DEFAULT        = 0,
@@ -26,124 +25,77 @@ HRESULT WINAPI RoGetAgileReference(Agile
                                    REFIID riid, IUnknown* pUnk,
                                    IAgileReference** ppAgileReference);
 
 #endif // NTDDI_VERSION < NTDDI_WINBLUE
 
 namespace mozilla {
 namespace mscom {
 
-AgileReference::AgileReference()
-  : mIid()
-  , mGitCookie(0)
-{
-}
-
 AgileReference::AgileReference(REFIID aIid, IUnknown* aObject)
   : mIid(aIid)
   , mGitCookie(0)
 {
-  AssignInternal(aObject);
-}
-
-void
-AgileReference::Assign(REFIID aIid, IUnknown* aObject)
-{
-  Clear();
-  mIid = aIid;
-  AssignInternal(aObject);
-}
-
-void
-AgileReference::AssignInternal(IUnknown* aObject)
-{
-  // We expect mIid to already be set
-  DebugOnly<IID> zeroIid = {};
-  MOZ_ASSERT(mIid != zeroIid);
-
   /*
    * There are two possible techniques for creating agile references. Starting
    * with Windows 8.1, we may use the RoGetAgileReference API, which is faster.
    * If that API is not available, we fall back to using the Global Interface
    * Table.
    */
   static const DynamicallyLinkedFunctionPtr<decltype(&::RoGetAgileReference)>
     pRoGetAgileReference(L"ole32.dll", "RoGetAgileReference");
 
   MOZ_ASSERT(aObject);
 
   if (pRoGetAgileReference &&
-      SUCCEEDED(pRoGetAgileReference(AGILEREFERENCE_DEFAULT, mIid, aObject,
+      SUCCEEDED(pRoGetAgileReference(AGILEREFERENCE_DEFAULT, aIid, aObject,
                                      getter_AddRefs(mAgileRef)))) {
     return;
   }
 
   IGlobalInterfaceTable* git = ObtainGit();
   MOZ_ASSERT(git);
   if (!git) {
     return;
   }
 
-  DebugOnly<HRESULT> hr = git->RegisterInterfaceInGlobal(aObject, mIid,
+  DebugOnly<HRESULT> hr = git->RegisterInterfaceInGlobal(aObject, aIid,
                                                          &mGitCookie);
   MOZ_ASSERT(SUCCEEDED(hr));
 }
 
 AgileReference::AgileReference(AgileReference&& aOther)
   : mIid(aOther.mIid)
   , mAgileRef(std::move(aOther.mAgileRef))
   , mGitCookie(aOther.mGitCookie)
 {
   aOther.mGitCookie = 0;
 }
 
 AgileReference::~AgileReference()
 {
-  Clear();
-}
-
-void
-AgileReference::Clear()
-{
-  mIid = {};
-
   if (!mGitCookie) {
-    mAgileRef = nullptr;
     return;
   }
 
   IGlobalInterfaceTable* git = ObtainGit();
   MOZ_ASSERT(git);
   if (!git) {
     return;
   }
 
   DebugOnly<HRESULT> hr = git->RevokeInterfaceFromGlobal(mGitCookie);
   MOZ_ASSERT(SUCCEEDED(hr));
-  mGitCookie = 0;
-}
-
-AgileReference&
-AgileReference::operator=(AgileReference&& aOther)
-{
-  Clear();
-  mIid = aOther.mIid;
-  aOther.mIid = {};
-  mAgileRef = std::move(aOther.mAgileRef);
-  mGitCookie = aOther.mGitCookie;
-  aOther.mGitCookie = 0;
-  return *this;
 }
 
 HRESULT
-AgileReference::Resolve(REFIID aIid, void** aOutInterface) const
+AgileReference::Resolve(REFIID aIid, void** aOutInterface)
 {
   MOZ_ASSERT(aOutInterface);
   MOZ_ASSERT(mAgileRef || mGitCookie);
-  MOZ_ASSERT(IsCOMInitializedOnCurrentThread());
 
   if (!aOutInterface) {
     return E_INVALIDARG;
   }
 
   *aOutInterface = nullptr;
 
   if (mAgileRef) {
@@ -173,17 +125,17 @@ AgileReference::Resolve(REFIID aIid, voi
     return S_OK;
   }
 
   // ...Whereas the GIT requires us to obtain the same interface that we
   // requested and then QI for the desired interface afterward.
   return originalInterface->QueryInterface(aIid, aOutInterface);
 }
 
-/* static */ IGlobalInterfaceTable*
+IGlobalInterfaceTable*
 AgileReference::ObtainGit()
 {
   // Internally to COM, the Global Interface Table is a singleton, therefore we
   // don't worry about holding onto this reference indefinitely.
   static IGlobalInterfaceTable* sGit = []() -> IGlobalInterfaceTable* {
     IGlobalInterfaceTable* result = nullptr;
     DebugOnly<HRESULT> hr =
       ::CoCreateInstance(CLSID_StdGlobalInterfaceTable, nullptr,
--- a/ipc/mscom/AgileReference.h
+++ b/ipc/mscom/AgileReference.h
@@ -28,87 +28,40 @@ namespace mscom {
  *
  * // myAgileRef is passed to our main thread, which runs in a single-threaded
  * // apartment:
  *
  * RefPtr<IFoo> foo;
  * HRESULT hr = myAgileRef->Resolve(IID_IFoo, getter_AddRefs(foo));
  * // Now foo may be called from the main thread
  */
-class AgileReference final
+class AgileReference
 {
 public:
-  AgileReference();
-
-  template <typename InterfaceT>
-  explicit AgileReference(RefPtr<InterfaceT>& aObject)
-    : AgileReference(__uuidof(InterfaceT), aObject)
-  {
-  }
-
   AgileReference(REFIID aIid, IUnknown* aObject);
   AgileReference(AgileReference&& aOther);
 
   ~AgileReference();
 
   explicit operator bool() const
   {
     return mAgileRef || mGitCookie;
   }
 
-  template <typename T>
-  void Assign(const RefPtr<T>& aOther)
-  {
-    Assign(__uuidof(T), aOther);
-  }
-
-  template <typename T>
-  AgileReference& operator=(const RefPtr<T>& aOther)
-  {
-    Assign(aOther);
-    return *this;
-  }
-
-  HRESULT Resolve(REFIID aIid, void** aOutInterface) const;
+  HRESULT Resolve(REFIID aIid, void** aOutInterface);
 
   AgileReference(const AgileReference& aOther) = delete;
   AgileReference& operator=(const AgileReference& aOther) = delete;
-
-  AgileReference& operator=(AgileReference&& aOther);
+  AgileReference& operator=(AgileReference&& aOther) = delete;
 
 private:
-  void Assign(REFIID aIid, IUnknown* aObject);
-  void AssignInternal(IUnknown* aObject);
-  void Clear();
-  static IGlobalInterfaceTable* ObtainGit();
+  IGlobalInterfaceTable* ObtainGit();
 
 private:
   IID                     mIid;
   RefPtr<IAgileReference> mAgileRef;
   DWORD                   mGitCookie;
 };
 
 } // namespace mscom
 } // namespace mozilla
 
-template <typename T>
-RefPtr<T>::RefPtr(const mozilla::mscom::AgileReference& aAgileRef)
-{
-  void* newRawPtr;
-  if (FAILED(aAgileRef.Resolve(__uuidof(T), &newRawPtr))) {
-    newRawPtr = nullptr;
-  }
-  mRawPtr = static_cast<T*>(newRawPtr);
-}
-
-template <typename T>
-RefPtr<T>&
-RefPtr<T>::operator=(const mozilla::mscom::AgileReference& aAgileRef)
-{
-  void* newRawPtr;
-  if (FAILED(aAgileRef.Resolve(__uuidof(T), &newRawPtr))) {
-    newRawPtr = nullptr;
-  }
-  assign_assuming_AddRef(static_cast<T*>(newRawPtr));
-  return *this;
-}
-
 #endif // mozilla_mscom_AgileReference_h
--- a/ipc/mscom/Utils.cpp
+++ b/ipc/mscom/Utils.cpp
@@ -28,25 +28,16 @@
 #if defined(_MSC_VER)
 extern "C" IMAGE_DOS_HEADER __ImageBase;
 #endif
 
 namespace mozilla {
 namespace mscom {
 
 bool
-IsCOMInitializedOnCurrentThread()
-{
-  APTTYPE aptType;
-  APTTYPEQUALIFIER aptTypeQualifier;
-  HRESULT hr = CoGetApartmentType(&aptType, &aptTypeQualifier);
-  return hr != CO_E_NOTINITIALIZED;
-}
-
-bool
 IsCurrentThreadMTA()
 {
   APTTYPE aptType;
   APTTYPEQUALIFIER aptTypeQualifier;
   HRESULT hr = CoGetApartmentType(&aptType, &aptTypeQualifier);
   if (FAILED(hr)) {
     return false;
   }
--- a/ipc/mscom/Utils.h
+++ b/ipc/mscom/Utils.h
@@ -15,17 +15,16 @@
 #include <guiddef.h>
 
 struct IStream;
 struct IUnknown;
 
 namespace mozilla {
 namespace mscom {
 
-bool IsCOMInitializedOnCurrentThread();
 bool IsCurrentThreadMTA();
 bool IsProxy(IUnknown* aUnknown);
 bool IsValidGUID(REFGUID aCheckGuid);
 uintptr_t GetContainingModuleHandle();
 
 /**
  * Given a buffer, create a new IStream object.
  * @param aBuf Buffer containing data to initialize the stream. This parameter
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -17,21 +17,16 @@
 
 class nsQueryReferent;
 class nsCOMPtr_helper;
 class nsISupports;
 
 namespace mozilla {
 template<class T> class OwningNonNull;
 template<class T> class StaticRefPtr;
-#if defined(XP_WIN)
-namespace mscom {
-class AgileReference;
-} // namespace mscom
-#endif // defined(XP_WIN)
 
 // Traditionally, RefPtr supports automatic refcounting of any pointer type
 // with AddRef() and Release() methods that follow the traditional semantics.
 //
 // This traits class can be specialized to operate on other pointer types. For
 // example, we specialize this trait for opaque FFI types that represent
 // refcounted objects in Rust.
 //
@@ -152,19 +147,16 @@ public:
   MOZ_IMPLICIT RefPtr(RefPtr<I>&& aSmartPtr)
     : mRawPtr(aSmartPtr.forget().take())
     // construct from |Move(RefPtr<SomeSubclassOfT>)|.
   {
   }
 
   MOZ_IMPLICIT RefPtr(const nsQueryReferent& aHelper);
   MOZ_IMPLICIT RefPtr(const nsCOMPtr_helper& aHelper);
-#if defined(XP_WIN)
-  MOZ_IMPLICIT RefPtr(const mozilla::mscom::AgileReference& aAgileRef);
-#endif // defined(XP_WIN)
 
   // Defined in OwningNonNull.h
   template<class U>
   MOZ_IMPLICIT RefPtr(const mozilla::OwningNonNull<U>& aOther);
 
   // Defined in StaticPtr.h
   template<class U>
   MOZ_IMPLICIT RefPtr(const mozilla::StaticRefPtr<U>& aOther);
@@ -218,19 +210,16 @@ public:
   // assign from |otherRefPtr.forget()|
   {
     assign_assuming_AddRef(aRhs.take());
     return *this;
   }
 
   RefPtr<T>& operator=(const nsQueryReferent& aQueryReferent);
   RefPtr<T>& operator=(const nsCOMPtr_helper& aHelper);
-#if defined(XP_WIN)
-  RefPtr<T>& operator=(const mozilla::mscom::AgileReference& aAgileRef);
-#endif // defined(XP_WIN)
 
   RefPtr<T>&
   operator=(RefPtr<T> && aRefPtr)
   {
     assign_assuming_AddRef(aRefPtr.mRawPtr);
     aRefPtr.mRawPtr = nullptr;
     return *this;
   }
--- a/widget/windows/JumpListBuilder.cpp
+++ b/widget/windows/JumpListBuilder.cpp
@@ -15,20 +15,18 @@
 #include "WinTaskbar.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsISimpleEnumerator.h"
 #include "mozilla/Preferences.h"
 #include "nsStringStream.h"
 #include "nsThreadUtils.h"
 #include "mozilla/LazyIdleThread.h"
 #include "nsIObserverService.h"
-#include "mozilla/ScopeExit.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/Promise.h"
-#include "mozilla/mscom/COMApartmentRegion.h"
 
 #include <shellapi.h>
 #include "WinUtils.h"
 
 using mozilla::dom::Promise;
 
 // The amount of time, in milliseconds, that our IO thread will stay alive after the last event it processes.
 #define DEFAULT_THREAD_TIMEOUT_MS 30000
@@ -104,32 +102,20 @@ NS_IMPL_ISUPPORTS(DoneCommitListBuildCal
 } // namespace detail
 
 
 JumpListBuilder::JumpListBuilder() :
   mMaxItems(0),
   mHasCommit(false),
   mMonitor("JumpListBuilderMonitor")
 {
-  MOZ_ASSERT(NS_IsMainThread());
+  ::CoInitialize(nullptr);
 
-  RefPtr<ICustomDestinationList> jumpListMgr;
-  HRESULT hr = CoCreateInstance(CLSID_DestinationList, nullptr,
-                                CLSCTX_INPROC_SERVER, IID_ICustomDestinationList,
-                                getter_AddRefs(jumpListMgr));
-  if (FAILED(hr)) {
-    return;
-  }
-
-  // Since we are accessing mJumpListMgr across different threads
-  // (ie, different apartments), mJumpListMgr must be an agile reference.
-  mJumpListMgr = jumpListMgr;
-  if (!mJumpListMgr) {
-    return;
-  }
+  CoCreateInstance(CLSID_DestinationList, nullptr, CLSCTX_INPROC_SERVER,
+                   IID_ICustomDestinationList, getter_AddRefs(mJumpListMgr));
 
   // Make a lazy thread for any IO
   mIOThread = new LazyIdleThread(DEFAULT_THREAD_TIMEOUT_MS,
                                  NS_LITERAL_CSTRING("Jump List"),
                                  LazyIdleThread::ManualShutdown);
   Preferences::AddStrongObserver(this, kPrefTaskbarEnabled);
 
   nsCOMPtr<nsIObserverService> observerService =
@@ -138,16 +124,18 @@ JumpListBuilder::JumpListBuilder() :
     observerService->AddObserver(this, TOPIC_PROFILE_BEFORE_CHANGE, false);
     observerService->AddObserver(this, TOPIC_CLEAR_PRIVATE_DATA, false);
   }
 }
 
 JumpListBuilder::~JumpListBuilder()
 {
   Preferences::RemoveObserver(this, kPrefTaskbarEnabled);
+  mJumpListMgr = nullptr;
+  ::CoUninitialize();
 }
 
 NS_IMETHODIMP JumpListBuilder::GetAvailable(int16_t *aAvailable)
 {
   *aAvailable = false;
 
   ReentrantMonitorAutoEnter lock(mMonitor);
   if (mJumpListMgr)
@@ -171,29 +159,24 @@ NS_IMETHODIMP JumpListBuilder::GetMaxLis
 
   *aMaxItems = 0;
 
   if (sBuildingList) {
     *aMaxItems = mMaxItems;
     return NS_OK;
   }
 
-  RefPtr<ICustomDestinationList> jumpListMgr = mJumpListMgr;
-  if (!jumpListMgr) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
   IObjectArray *objArray;
-  if (SUCCEEDED(jumpListMgr->BeginList(&mMaxItems, IID_PPV_ARGS(&objArray)))) {
+  if (SUCCEEDED(mJumpListMgr->BeginList(&mMaxItems, IID_PPV_ARGS(&objArray)))) {
     *aMaxItems = mMaxItems;
 
     if (objArray)
       objArray->Release();
 
-    jumpListMgr->AbortList();
+    mJumpListMgr->AbortList();
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP JumpListBuilder::InitListBuild(JSContext* aCx,
                                              Promise** aPromise)
 {
@@ -224,65 +207,46 @@ NS_IMETHODIMP JumpListBuilder::InitListB
   }
 
   promise.forget(aPromise);
   return NS_OK;
 }
 
 void JumpListBuilder::DoInitListBuild(RefPtr<Promise>&& aPromise)
 {
-  // Since we're invoking COM interfaces to talk to the shell on a background
-  // thread, we need to be running inside a single-threaded apartment.
-  mscom::STARegion sta;
-  MOZ_ASSERT(sta.IsValid());
-
   ReentrantMonitorAutoEnter lock(mMonitor);
   MOZ_ASSERT(mJumpListMgr);
 
-  if (sBuildingList) {
+  if(sBuildingList) {
     AbortListBuild();
   }
 
-  HRESULT hr = E_UNEXPECTED;
-  auto errorHandler = MakeScopeExit([&aPromise, &hr]() {
-    if (SUCCEEDED(hr)) {
-      return;
-    }
+  nsTArray<nsString> urisToRemove;
+  RefPtr<IObjectArray> objArray;
+  HRESULT hr = mJumpListMgr->BeginList(&mMaxItems,
+                                       IID_PPV_ARGS(static_cast<IObjectArray**>
+                                                    (getter_AddRefs(objArray))));
+  // The returned objArray of removed items are for manually removed items.
+  // This does not return items which are removed because they were previously
+  // part of the jump list but are no longer part of the jump list.
+  if (SUCCEEDED(hr)) {
+    sBuildingList = true;
+    RemoveIconCacheAndGetJumplistShortcutURIs(objArray, urisToRemove);
 
+    NS_DispatchToMainThread(NS_NewRunnableFunction("InitListBuildResolve",
+                                                   [urisToRemove = std::move(urisToRemove),
+                                                    promise = std::move(aPromise)]() {
+      promise->MaybeResolve(urisToRemove);
+    }));
+  } else {
     NS_DispatchToMainThread(NS_NewRunnableFunction("InitListBuildReject",
                                                    [promise = std::move(aPromise)]() {
       promise->MaybeReject(NS_ERROR_FAILURE);
     }));
-  });
-
-  RefPtr<ICustomDestinationList> jumpListMgr = mJumpListMgr;
-  if (!jumpListMgr) {
-    return;
   }
-
-  nsTArray<nsString> urisToRemove;
-  RefPtr<IObjectArray> objArray;
-  hr = jumpListMgr->BeginList(&mMaxItems,
-                              IID_PPV_ARGS(static_cast<IObjectArray**>
-                                           (getter_AddRefs(objArray))));
-  if (FAILED(hr)) {
-    return;
-  }
-
-  // The returned objArray of removed items are for manually removed items.
-  // This does not return items which are removed because they were previously
-  // part of the jump list but are no longer part of the jump list.
-  sBuildingList = true;
-  RemoveIconCacheAndGetJumplistShortcutURIs(objArray, urisToRemove);
-
-  NS_DispatchToMainThread(NS_NewRunnableFunction("InitListBuildResolve",
-                                                 [urisToRemove = std::move(urisToRemove),
-                                                  promise = std::move(aPromise)]() {
-    promise->MaybeResolve(urisToRemove);
-  }));
 }
 
 // Ensures that we have no old ICO files left in the jump list cache
 nsresult JumpListBuilder::RemoveIconCacheForAllItems()
 {
   // Construct the path of our jump list cache
   nsCOMPtr<nsIFile> jumpListCacheDir;
   nsresult rv = NS_GetSpecialDirectory("ProfLDS",
@@ -325,21 +289,16 @@ NS_IMETHODIMP JumpListBuilder::AddListTo
   nsresult rv;
 
   *_retval = false;
 
   ReentrantMonitorAutoEnter lock(mMonitor);
   if (!mJumpListMgr)
     return NS_ERROR_NOT_AVAILABLE;
 
-  RefPtr<ICustomDestinationList> jumpListMgr = mJumpListMgr;
-  if (!jumpListMgr) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
   switch(aCatType) {
     case nsIJumpListBuilder::JUMPLIST_CATEGORY_TASKS:
     {
       NS_ENSURE_ARG_POINTER(items);
 
       HRESULT hr;
       RefPtr<IObjectCollection> collection;
       hr = CoCreateInstance(CLSID_EnumerableObjectCollection, nullptr,
@@ -374,32 +333,32 @@ NS_IMETHODIMP JumpListBuilder::AddListTo
 
       // We need IObjectArray to submit
       RefPtr<IObjectArray> pArray;
       hr = collection->QueryInterface(IID_IObjectArray, getter_AddRefs(pArray));
       if (FAILED(hr))
         return NS_ERROR_UNEXPECTED;
 
       // Add the tasks
-      hr = jumpListMgr->AddUserTasks(pArray);
+      hr = mJumpListMgr->AddUserTasks(pArray);
       if (SUCCEEDED(hr))
         *_retval = true;
       return NS_OK;
     }
     break;
     case nsIJumpListBuilder::JUMPLIST_CATEGORY_RECENT:
     {
-      if (SUCCEEDED(jumpListMgr->AppendKnownCategory(KDC_RECENT)))
+      if (SUCCEEDED(mJumpListMgr->AppendKnownCategory(KDC_RECENT)))
         *_retval = true;
       return NS_OK;
     }
     break;
     case nsIJumpListBuilder::JUMPLIST_CATEGORY_FREQUENT:
     {
-      if (SUCCEEDED(jumpListMgr->AppendKnownCategory(KDC_FREQUENT)))
+      if (SUCCEEDED(mJumpListMgr->AppendKnownCategory(KDC_FREQUENT)))
         *_retval = true;
       return NS_OK;
     }
     break;
     case nsIJumpListBuilder::JUMPLIST_CATEGORY_CUSTOMLIST:
     {
       NS_ENSURE_ARG_POINTER(items);
 
@@ -456,17 +415,17 @@ NS_IMETHODIMP JumpListBuilder::AddListTo
 
       // We need IObjectArray to submit
       RefPtr<IObjectArray> pArray;
       hr = collection->QueryInterface(IID_IObjectArray, (LPVOID*)&pArray);
       if (FAILED(hr))
         return NS_ERROR_UNEXPECTED;
 
       // Add the tasks
-      hr = jumpListMgr->AppendCategory(reinterpret_cast<const wchar_t*>(catName.BeginReading()), pArray);
+      hr = mJumpListMgr->AppendCategory(reinterpret_cast<const wchar_t*>(catName.BeginReading()), pArray);
       if (SUCCEEDED(hr))
         *_retval = true;
 
       // Get rid of the old icons
       nsCOMPtr<nsIRunnable> event =
         new mozilla::widget::AsyncDeleteAllFaviconsFromDisk(true);
       mIOThread->Dispatch(event, NS_DISPATCH_NORMAL);
 
@@ -478,22 +437,17 @@ NS_IMETHODIMP JumpListBuilder::AddListTo
 }
 
 NS_IMETHODIMP JumpListBuilder::AbortListBuild()
 {
   ReentrantMonitorAutoEnter lock(mMonitor);
   if (!mJumpListMgr)
     return NS_ERROR_NOT_AVAILABLE;
 
-  RefPtr<ICustomDestinationList> jumpListMgr = mJumpListMgr;
-  if (!jumpListMgr) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  jumpListMgr->AbortList();
+  mJumpListMgr->AbortList();
   sBuildingList = false;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP JumpListBuilder::CommitListBuild(nsIJumpListCommittedCallback* aCallback)
 {
   ReentrantMonitorAutoEnter lock(mMonitor);
@@ -512,69 +466,49 @@ NS_IMETHODIMP JumpListBuilder::CommitLis
        &JumpListBuilder::DoCommitListBuild, std::move(callback));
   Unused << mIOThread->Dispatch(event, NS_DISPATCH_NORMAL);
 
   return NS_OK;
 }
 
 void JumpListBuilder::DoCommitListBuild(RefPtr<detail::DoneCommitListBuildCallback> aCallback)
 {
-  // Since we're invoking COM interfaces to talk to the shell on a background
-  // thread, we need to be running inside a single-threaded apartment.
-  mscom::STARegion sta;
-  MOZ_ASSERT(sta.IsValid());
-
   ReentrantMonitorAutoEnter lock(mMonitor);
   MOZ_ASSERT(mJumpListMgr);
   MOZ_ASSERT(aCallback);
 
-  HRESULT hr = E_UNEXPECTED;
-  auto onExit = MakeScopeExit([&hr, &aCallback]() {
-    // XXX We might want some specific error data here.
-    aCallback->SetResult(SUCCEEDED(hr));
-    Unused << NS_DispatchToMainThread(aCallback);
-  });
-
-  RefPtr<ICustomDestinationList> jumpListMgr = mJumpListMgr;
-  if (!jumpListMgr) {
-    return;
-  }
-
-  hr = jumpListMgr->CommitList();
+  HRESULT hr = mJumpListMgr->CommitList();
   sBuildingList = false;
 
   if (SUCCEEDED(hr)) {
     mHasCommit = true;
   }
+
+  // XXX We might want some specific error data here.
+  aCallback->SetResult(SUCCEEDED(hr));
+  Unused << NS_DispatchToMainThread(aCallback);
 }
 
 NS_IMETHODIMP JumpListBuilder::DeleteActiveList(bool *_retval)
 {
   *_retval = false;
 
   ReentrantMonitorAutoEnter lock(mMonitor);
   if (!mJumpListMgr)
     return NS_ERROR_NOT_AVAILABLE;
 
-  if (sBuildingList) {
+  if(sBuildingList)
     AbortListBuild();
-  }
 
   nsAutoString uid;
   if (!WinTaskbar::GetAppUserModelID(uid))
     return NS_OK;
 
-  RefPtr<ICustomDestinationList> jumpListMgr = mJumpListMgr;
-  if (!jumpListMgr) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  if (SUCCEEDED(jumpListMgr->DeleteList(uid.get()))) {
+  if (SUCCEEDED(mJumpListMgr->DeleteList(uid.get())))
     *_retval = true;
-  }
 
   return NS_OK;
 }
 
 /* internal */
 
 bool JumpListBuilder::IsSeparator(nsCOMPtr<nsIJumpListItem>& item)
 {
@@ -615,17 +549,17 @@ void JumpListBuilder::RemoveIconCacheAnd
 
     wchar_t buf[MAX_PATH];
     HRESULT hres = pLink->GetArguments(buf, MAX_PATH);
     if (SUCCEEDED(hres)) {
       LPWSTR *arglist;
       int32_t numArgs;
 
       arglist = ::CommandLineToArgvW(buf, &numArgs);
-      if (arglist && numArgs > 0) {
+      if(arglist && numArgs > 0) {
         nsString spec(arglist[0]);
         aURISpecs.AppendElement(std::move(spec));
         ::LocalFree(arglist);
       }
     }
 
     int iconIdx = 0;
     hres = pLink->GetIconLocation(buf, MAX_PATH, &iconIdx);
--- a/widget/windows/JumpListBuilder.h
+++ b/widget/windows/JumpListBuilder.h
@@ -18,17 +18,16 @@
 #include "nsIMutableArray.h"
 
 #include "nsIJumpListBuilder.h"
 #include "nsIJumpListItem.h"
 #include "JumpListItem.h"
 #include "nsIObserver.h"
 #include "nsTArray.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/mscom/AgileReference.h"
 #include "mozilla/ReentrantMonitor.h"
 
 namespace mozilla {
 namespace widget {
 
 namespace detail {
 class DoneCommitListBuildCallback;
 } // namespace detail
@@ -44,17 +43,17 @@ public:
   NS_DECL_NSIOBSERVER
 
   JumpListBuilder();
 
 protected:
   static Atomic<bool> sBuildingList;
 
 private:
-  mscom::AgileReference mJumpListMgr;
+  RefPtr<ICustomDestinationList> mJumpListMgr;
   uint32_t mMaxItems;
   bool mHasCommit;
   nsCOMPtr<nsIThread> mIOThread;
   ReentrantMonitor mMonitor;
 
   bool IsSeparator(nsCOMPtr<nsIJumpListItem>& item);
   void RemoveIconCacheAndGetJumplistShortcutURIs(IObjectArray *aObjArray, nsTArray<nsString>& aURISpecs);
   void DeleteIconFromDisk(const nsAString& aPath);