Bug 1546154 p6: Remove MSCOMInitThreadPoolListener. r=padenot

Threads are implicitly members of the multi-threaded apartment and calls to
CoInitializeEx (and CoUninitializeEx) cause user32 to load.

Differential Revision: https://phabricator.services.mozilla.com/D124934
This commit is contained in:
Bob Owen 2021-09-20 10:09:02 +00:00
parent f9afd195ff
commit 4e3f0dcd50
5 changed files with 0 additions and 73 deletions

View File

@ -1,28 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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 "ThreadPoolCOMListener.h"
namespace mozilla {
NS_IMPL_ISUPPORTS(MSCOMInitThreadPoolListener, nsIThreadPoolListener)
NS_IMETHODIMP
MSCOMInitThreadPoolListener::OnThreadCreated() {
HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hr)) {
NS_WARNING("Failed to initialize MSCOM on decoder thread.");
}
return NS_OK;
}
NS_IMETHODIMP
MSCOMInitThreadPoolListener::OnThreadShuttingDown() {
CoUninitialize();
return NS_OK;
}
} // namespace mozilla

View File

@ -1,28 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#ifndef MSCOMInitThreadPoolListener_h_
#define MSCOMInitThreadPoolListener_h_
#include "nsIThreadPool.h"
#include <objbase.h>
namespace mozilla {
// Thread pool listener which ensures that MSCOM is initialized and
// deinitialized on the thread pool thread. We may call into WMF on this thread,
// so we need MSCOM working.
class MSCOMInitThreadPoolListener final : public nsIThreadPoolListener {
~MSCOMInitThreadPoolListener() {}
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITHREADPOOLLISTENER
};
} // namespace mozilla
#endif // MSCOMInitThreadPoolListener_h_

View File

@ -181,7 +181,6 @@ EXPORTS += [
"SeekTarget.h",
"SelfRef.h",
"SharedBuffer.h",
"ThreadPoolCOMListener.h",
"TimeUnits.h",
"Tracing.h",
"VideoFrameContainer.h",
@ -304,11 +303,6 @@ if CONFIG["OS_TARGET"] == "Linux":
else:
UNIFIED_SOURCES += ["UnderrunHandlerNoop.cpp"]
if CONFIG["OS_TARGET"] == "WINNT":
SOURCES += [
"ThreadPoolCOMListener.cpp",
]
# CubebUtils.cpp needs to be built separately due to what appears to be some kind
# of compiler bug on Android 4.2 x86 opt. See bug 1408459.
# DecoderTraits.cpp needs to be built separately because of Mac OS X headers.

View File

@ -28,7 +28,6 @@ forbid-mscom-init:
- browser/components/migration/nsIEHistoryEnumerator.cpp
- browser/components/migration/tests/unit/insertIEHistory/InsertIEHistory.cpp
- browser/components/shell/nsWindowsShellService.cpp
- dom/media/ThreadPoolCOMListener.cpp
- gfx/thebes/gfxWindowsPlatform.cpp
- image/DecodePool.cpp
- intl/locale/windows/OSPreferences_win.cpp

View File

@ -17,9 +17,6 @@
#include "nsIObserverService.h"
#include "nsIThreadManager.h"
#include "nsThreadPool.h"
#ifdef XP_WIN
# include "ThreadPoolCOMListener.h"
#endif
namespace mozilla {
@ -220,13 +217,6 @@ static already_AddRefed<nsIThreadPool> CreateThreadPool(
rv = pool->SetThreadStackSize(nsIThreadManager::kThreadPoolStackSize);
NS_ENSURE_SUCCESS(rv, nullptr);
#ifdef XP_WIN
// Ensure MSCOM is initialized on the thread pools threads.
nsCOMPtr<nsIThreadPoolListener> listener = new MSCOMInitThreadPoolListener();
rv = pool->SetListener(listener);
NS_ENSURE_SUCCESS(rv, nullptr);
#endif
return pool.forget();
}