Backed out changeset 501704300cc1 (bug 1847660) for causing build bustages in GMPChild.cpp CLOSED TREE

This commit is contained in:
Noemi Erli 2023-09-20 16:44:47 +03:00
Родитель cbb5f1e1ac
Коммит 0f87551c1b
13 изменённых файлов: 24 добавлений и 269 удалений

Просмотреть файл

@ -44,7 +44,6 @@
#include "prio.h" #include "prio.h"
#ifdef XP_WIN #ifdef XP_WIN
# include <stdlib.h> // for _exit() # include <stdlib.h> // for _exit()
# include "mozilla/WinDllServices.h"
# include "WinUtils.h" # include "WinUtils.h"
#else #else
# include <unistd.h> // for _exit() # include <unistd.h> // for _exit()
@ -757,38 +756,6 @@ mozilla::ipc::IPCResult GMPChild::RecvShutdown(ShutdownResolver&& aResolver) {
return IPC_OK(); return IPC_OK();
} }
#if defined(XP_WIN)
mozilla::ipc::IPCResult GMPChild::RecvInitDllServices(
const bool& aCanRecordReleaseTelemetry,
const bool& aIsReadyForBackgroundProcessing) {
if (aCanRecordReleaseTelemetry) {
RefPtr<DllServices> dllSvc(DllServices::Get());
dllSvc->StartUntrustedModulesProcessor(aIsReadyForBackgroundProcessing);
}
return IPC_OK();
}
mozilla::ipc::IPCResult GMPChild::RecvGetUntrustedModulesData(
GetUntrustedModulesDataResolver&& aResolver) {
RefPtr<DllServices> dllSvc(DllServices::Get());
dllSvc->GetUntrustedModulesData()->Then(
GetMainThreadSerialEventTarget(), __func__,
[aResolver](Maybe<UntrustedModulesData>&& aData) {
aResolver(std::move(aData));
},
[aResolver](nsresult aReason) { aResolver(Nothing()); });
return IPC_OK();
}
mozilla::ipc::IPCResult GMPChild::RecvUnblockUntrustedModulesThread() {
if (nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService()) {
obs->NotifyObservers(nullptr, "unblock-untrusted-modules-thread", nullptr);
}
return IPC_OK();
}
#endif // defined(XP_WIN)
} // namespace gmp } // namespace gmp
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -82,16 +82,6 @@ class GMPChild : public PGMPChild {
mozilla::ipc::IPCResult RecvShutdown(ShutdownResolver&& aResolver); mozilla::ipc::IPCResult RecvShutdown(ShutdownResolver&& aResolver);
#if defined(XP_WIN)
mozilla::ipc::IPCResult RecvInitDllServices(
const bool& aCanRecordReleaseTelemetry,
const bool& aIsReadyForBackgroundProcessing);
mozilla::ipc::IPCResult RecvGetUntrustedModulesData(
GetUntrustedModulesDataResolver&& aResolver);
mozilla::ipc::IPCResult RecvUnblockUntrustedModulesThread();
#endif // defined(XP_WIN)
void ActorDestroy(ActorDestroyReason aWhy) override; void ActorDestroy(ActorDestroyReason aWhy) override;
void ProcessingError(Result aCode, const char* aReason) override; void ProcessingError(Result aCode, const char* aReason) override;

Просмотреть файл

@ -39,7 +39,6 @@
#include "runnable_utils.h" #include "runnable_utils.h"
#ifdef XP_WIN #ifdef XP_WIN
# include "mozilla/FileUtilsWin.h" # include "mozilla/FileUtilsWin.h"
# include "mozilla/WinDllServices.h"
# include "WMFDecoderModule.h" # include "WMFDecoderModule.h"
#endif #endif
#if defined(MOZ_WIDGET_ANDROID) #if defined(MOZ_WIDGET_ANDROID)
@ -299,23 +298,13 @@ class NotifyGMPProcessLoadedTask : public Runnable {
} }
#endif #endif
nsCOMPtr<nsISerialEventTarget> gmpEventTarget =
mGMPParent->GMPEventTarget();
if (NS_WARN_IF(!gmpEventTarget)) {
return NS_ERROR_FAILURE;
}
#if defined(XP_WIN)
RefPtr<DllServices> dllSvc(DllServices::Get());
bool isReadyForBackgroundProcessing =
dllSvc->IsReadyForBackgroundProcessing();
gmpEventTarget->Dispatch(NewRunnableMethod<bool, bool>(
"GMPParent::SendInitDllServices", mGMPParent,
&GMPParent::SendInitDllServices, isReadyForBackgroundProcessing,
Telemetry::CanRecordReleaseData()));
#endif
if (canProfile) { if (canProfile) {
nsCOMPtr<nsISerialEventTarget> gmpEventTarget =
mGMPParent->GMPEventTarget();
if (!gmpEventTarget) {
return NS_ERROR_FAILURE;
}
ipc::Endpoint<PProfilerChild> profilerParent( ipc::Endpoint<PProfilerChild> profilerParent(
ProfilerParent::CreateForProcess(mProcessId)); ProfilerParent::CreateForProcess(mProcessId));
@ -442,49 +431,6 @@ mozilla::ipc::IPCResult GMPParent::RecvFOGData(ByteBuf&& aBuf) {
return IPC_OK(); return IPC_OK();
} }
#if defined(XP_WIN)
mozilla::ipc::IPCResult GMPParent::RecvGetModulesTrust(
ModulePaths&& aModPaths, bool aRunAtNormalPriority,
GetModulesTrustResolver&& aResolver) {
class ModulesTrustRunnable final : public Runnable {
public:
ModulesTrustRunnable(ModulePaths&& aModPaths, bool aRunAtNormalPriority,
GetModulesTrustResolver&& aResolver)
: Runnable("GMPParent::RecvGetModulesTrust::ModulesTrustRunnable"),
mModPaths(std::move(aModPaths)),
mResolver(std::move(aResolver)),
mEventTarget(GetCurrentSerialEventTarget()),
mRunAtNormalPriority(aRunAtNormalPriority) {}
NS_IMETHOD Run() override {
RefPtr<DllServices> dllSvc(DllServices::Get());
dllSvc->GetModulesTrust(std::move(mModPaths), mRunAtNormalPriority)
->Then(
mEventTarget, __func__,
[self = RefPtr{this}](ModulesMapResult&& aResult) {
self->mResolver(Some(ModulesMapResult(std::move(aResult))));
},
[self = RefPtr{this}](nsresult aRv) {
self->mResolver(Nothing());
});
return NS_OK;
}
private:
~ModulesTrustRunnable() override = default;
ModulePaths mModPaths;
GetModulesTrustResolver mResolver;
nsCOMPtr<nsISerialEventTarget> mEventTarget;
bool mRunAtNormalPriority;
};
NS_DispatchToMainThread(MakeAndAddRef<ModulesTrustRunnable>(
std::move(aModPaths), aRunAtNormalPriority, std::move(aResolver)));
return IPC_OK();
}
#endif // defined(XP_WIN)
void GMPParent::CloseIfUnused() { void GMPParent::CloseIfUnused() {
MOZ_ASSERT(GMPEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GMPEventTarget()->IsOnCurrentThread());
GMP_PARENT_LOG_DEBUG("%s", __FUNCTION__); GMP_PARENT_LOG_DEBUG("%s", __FUNCTION__);

Просмотреть файл

@ -178,12 +178,6 @@ class GMPParent final
mozilla::ipc::IPCResult RecvFOGData(ByteBuf&& aBuf); mozilla::ipc::IPCResult RecvFOGData(ByteBuf&& aBuf);
#if defined(XP_WIN)
mozilla::ipc::IPCResult RecvGetModulesTrust(
ModulePaths&& aModPaths, bool aRunAtNormalPriority,
GetModulesTrustResolver&& aResolver);
#endif // defined(XP_WIN)
bool IsUsed() { bool IsUsed() {
return mGMPContentChildCount > 0 || !mGetContentParentPromises.IsEmpty(); return mGMPContentChildCount > 0 || !mGetContentParentPromises.IsEmpty();
} }

Просмотреть файл

@ -13,10 +13,6 @@
#include "base/time.h" #include "base/time.h"
#include "mozilla/ReentrantMonitor.h" #include "mozilla/ReentrantMonitor.h"
#ifdef XP_WIN
# include "mozilla/UntrustedModulesProcessor.h"
#endif
#include <ctime> #include <ctime>
namespace mozilla::gmp { namespace mozilla::gmp {
@ -221,17 +217,6 @@ void SendFOGData(ipc::ByteBuf&& buf) {
} }
} }
#ifdef XP_WIN
RefPtr<PGMPChild::GetModulesTrustPromise> SendGetModulesTrust(
ModulePaths&& aModules, bool aRunAtNormalPriority) {
if (!sChild) {
return PGMPChild::GetModulesTrustPromise::CreateAndReject(
ipc::ResponseRejectReason::SendError, __func__);
}
return sChild->SendGetModulesTrust(std::move(aModules), aRunAtNormalPriority);
}
#endif
GMPThreadImpl::GMPThreadImpl() : mMutex("GMPThreadImpl"), mThread("GMPThread") { GMPThreadImpl::GMPThreadImpl() : mMutex("GMPThreadImpl"), mThread("GMPThread") {
MOZ_COUNT_CTOR(GMPThread); MOZ_COUNT_CTOR(GMPThread);
} }

Просмотреть файл

@ -6,21 +6,14 @@
#ifndef GMPPlatform_h_ #ifndef GMPPlatform_h_
#define GMPPlatform_h_ #define GMPPlatform_h_
#include "mozilla/RefPtr.h"
#include "gmp-platform.h" #include "gmp-platform.h"
#include <functional> #include <functional>
#include "mozilla/gmp/PGMPChild.h"
namespace mozilla { namespace mozilla::ipc {
#ifdef XP_WIN
struct ModulePaths;
#endif
namespace ipc {
class ByteBuf; class ByteBuf;
} // namespace ipc } // namespace mozilla::ipc
namespace gmp { namespace mozilla::gmp {
class GMPChild; class GMPChild;
@ -34,12 +27,6 @@ GMPErr SetTimerOnMainThread(GMPTask* aTask, int64_t aTimeoutMS);
void SendFOGData(ipc::ByteBuf&& buf); void SendFOGData(ipc::ByteBuf&& buf);
#ifdef XP_WIN } // namespace mozilla::gmp
RefPtr<PGMPChild::GetModulesTrustPromise> SendGetModulesTrust(
ModulePaths&& aModules, bool aRunNormal);
#endif
} // namespace gmp
} // namespace mozilla
#endif // GMPPlatform_h_ #endif // GMPPlatform_h_

Просмотреть файл

@ -31,9 +31,6 @@
#include "mozilla/SyncRunnable.h" #include "mozilla/SyncRunnable.h"
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#if defined(XP_WIN)
# include "mozilla/UntrustedModulesData.h"
#endif
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
@ -714,67 +711,6 @@ void GeckoMediaPluginServiceParent::SendFlushFOGData(
} }
} }
#if defined(XP_WIN)
void GeckoMediaPluginServiceParent::SendGetUntrustedModulesData(
nsTArray<RefPtr<GetUntrustedModulesDataPromise>>& promises) {
MOZ_ASSERT(NS_IsMainThread());
MutexAutoLock lock(mMutex);
for (const RefPtr<GMPParent>& gmp : mPlugins) {
if (gmp->State() != GMPState::Loaded) {
// Plugins that are not in the Loaded state have no process attached to
// them, and any IPC we would attempt to send them would be ignored (or
// result in a warning on debug builds).
continue;
}
RefPtr<GetUntrustedModulesDataPromise::Private> promise =
new GetUntrustedModulesDataPromise::Private(__func__);
// Direct dispatch will resolve the promise on the same thread, which is
// faster; IPC will move execution back to the main thread.
promise->UseDirectTaskDispatch(__func__);
promises.EmplaceBack(promise);
mGMPThread->Dispatch(
NewRunnableMethod<ipc::ResolveCallback<Maybe<UntrustedModulesData>>&&,
ipc::RejectCallback&&>(
"GMPParent::SendGetUntrustedModulesData", gmp,
static_cast<void (GMPParent::*)(
mozilla::ipc::ResolveCallback<Maybe<UntrustedModulesData>>&&
aResolve,
mozilla::ipc::RejectCallback&& aReject)>(
&GMPParent::SendGetUntrustedModulesData),
[promise](Maybe<UntrustedModulesData>&& aValue) {
promise->Resolve(std::move(aValue), __func__);
},
[promise](ipc::ResponseRejectReason&& aReason) {
promise->Reject(std::move(aReason), __func__);
}),
NS_DISPATCH_NORMAL);
}
}
void GeckoMediaPluginServiceParent::SendUnblockUntrustedModulesThread() {
MOZ_ASSERT(NS_IsMainThread());
MutexAutoLock lock(mMutex);
for (const RefPtr<GMPParent>& gmp : mPlugins) {
if (gmp->State() != GMPState::Loaded) {
// Plugins that are not in the Loaded state have no process attached to
// them, and any IPC we would attempt to send them would be ignored (or
// result in a warning on debug builds).
continue;
}
mGMPThread->Dispatch(
NewRunnableMethod<>("GMPParent::SendUnblockUntrustedModulesThread", gmp,
static_cast<bool (GMPParent::*)()>(
&GMPParent::SendUnblockUntrustedModulesThread)),
NS_DISPATCH_NORMAL);
}
}
#endif
RefPtr<PGMPParent::TestTriggerMetricsPromise> RefPtr<PGMPParent::TestTriggerMetricsPromise>
GeckoMediaPluginServiceParent::TestTriggerMetrics() { GeckoMediaPluginServiceParent::TestTriggerMetrics() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());

Просмотреть файл

@ -82,16 +82,6 @@ class GeckoMediaPluginServiceParent final
void SendFlushFOGData(nsTArray<RefPtr<FlushFOGDataPromise>>& promises); void SendFlushFOGData(nsTArray<RefPtr<FlushFOGDataPromise>>& promises);
#if defined(XP_WIN)
using GetUntrustedModulesDataPromise =
PGMPParent::GetUntrustedModulesDataPromise;
void SendGetUntrustedModulesData(
nsTArray<RefPtr<GetUntrustedModulesDataPromise>>& promises);
void SendUnblockUntrustedModulesThread();
#endif
/* /*
* ** Test-only Method ** * ** Test-only Method **
* *

Просмотреть файл

@ -9,12 +9,6 @@ include protocol PGMPTimer;
include protocol PGMPStorage; include protocol PGMPStorage;
include protocol PProfiler; include protocol PProfiler;
#if defined(XP_WIN)
[MoveOnly] using mozilla::UntrustedModulesData from "mozilla/UntrustedModulesData.h";
[MoveOnly] using mozilla::ModulePaths from "mozilla/UntrustedModulesData.h";
[MoveOnly] using mozilla::ModulesMapResult from "mozilla/UntrustedModulesData.h";
#endif
include "mozilla/ipc/ByteBufUtils.h"; include "mozilla/ipc/ByteBufUtils.h";
include "GMPParent.h"; include "GMPParent.h";
include "GMPChild.h"; include "GMPChild.h";
@ -42,11 +36,6 @@ parent:
// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/ipc.html // https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/ipc.html
async FOGData(ByteBuf buf); async FOGData(ByteBuf buf);
#if defined(XP_WIN)
async GetModulesTrust(ModulePaths aModPaths, bool aRunAtNormalPriority)
returns (ModulesMapResult? modMapResult);
#endif // defined(XP_WIN)
child: child:
async CrashPluginNow(); async CrashPluginNow();
[Nested=inside_sync] sync StartPlugin(nsString adapter); [Nested=inside_sync] sync StartPlugin(nsString adapter);
@ -62,20 +51,6 @@ child:
// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/ipc.html // https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/ipc.html
async FlushFOGData() returns (ByteBuf buf); async FlushFOGData() returns (ByteBuf buf);
#if defined(XP_WIN)
async InitDllServices(bool canRecordReleaseTelemetry,
bool aIsReadyForBackgroundProcessing);
async GetUntrustedModulesData() returns (UntrustedModulesData? data);
/**
* This method is used to notify a child process to start
* processing module loading events in UntrustedModulesProcessor.
* This should be called when the parent process has gone idle.
*/
async UnblockUntrustedModulesThread();
#endif // defined(XP_WIN)
// Test-only method. // Test-only method.
// Asks the GMP process to trigger test-only instrumentation. // Asks the GMP process to trigger test-only instrumentation.
// The unused returned value is to have a promise we can await. // The unused returned value is to have a promise we can await.

Просмотреть файл

@ -114,6 +114,7 @@ DIRS += [
IPDL_SOURCES += [ IPDL_SOURCES += [
"GMPTypes.ipdlh", "GMPTypes.ipdlh",
"PChromiumCDM.ipdl", "PChromiumCDM.ipdl",
"PGMP.ipdl",
"PGMPService.ipdl", "PGMPService.ipdl",
"PGMPStorage.ipdl", "PGMPStorage.ipdl",
"PGMPTimer.ipdl", "PGMPTimer.ipdl",
@ -122,7 +123,6 @@ IPDL_SOURCES += [
] ]
PREPROCESSED_IPDL_SOURCES += [ PREPROCESSED_IPDL_SOURCES += [
"PGMP.ipdl",
"PGMPContent.ipdl", "PGMPContent.ipdl",
] ]

Просмотреть файл

@ -6,7 +6,6 @@
#include "UntrustedModules.h" #include "UntrustedModules.h"
#include "GMPServiceParent.h"
#include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ContentParent.h"
#include "mozilla/MozPromise.h" #include "mozilla/MozPromise.h"
#include "mozilla/net/SocketProcessParent.h" #include "mozilla/net/SocketProcessParent.h"
@ -151,17 +150,6 @@ MultiGetUntrustedModulesData::GetUntrustedModuleLoadEvents() {
} }
} }
if (RefPtr<gmp::GeckoMediaPluginServiceParent> gmps =
gmp::GeckoMediaPluginServiceParent::GetSingleton()) {
nsTArray<RefPtr<
gmp::GeckoMediaPluginServiceParent::GetUntrustedModulesDataPromise>>
promises;
gmps->SendGetUntrustedModulesData(promises);
for (auto& promise : promises) {
AddPending(std::move(promise));
}
}
return mPromise; return mPromise;
} }

Просмотреть файл

@ -8,8 +8,6 @@
#include <windows.h> #include <windows.h>
#include "GMPPlatform.h"
#include "GMPServiceParent.h"
#include "mozilla/CmdLineAndEnvUtils.h" #include "mozilla/CmdLineAndEnvUtils.h"
#include "mozilla/DebugOnly.h" #include "mozilla/DebugOnly.h"
#include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentChild.h"
@ -83,11 +81,9 @@ bool UntrustedModulesProcessor::IsSupportedProcessType() {
return Telemetry::CanRecordReleaseData(); return Telemetry::CanRecordReleaseData();
case GeckoProcessType_RDD: case GeckoProcessType_RDD:
case GeckoProcessType_Utility: case GeckoProcessType_Utility:
case GeckoProcessType_GMPlugin: // For RDD and Utility process, we check the telemetry settings in
// For GMPlugin, RDD and Utility process, we check the telemetry settings // RDDChild::Init() / UtilityProcessChild::Init() running in the browser
// in RDDChild::Init() / UtilityProcessChild::Init() / GMPChild::Init() // process because CanRecordReleaseData() always returns false here.
// running in the browser process because CanRecordReleaseData() always
// returns false here.
return true; return true;
default: default:
return false; return false;
@ -201,10 +197,6 @@ NS_IMETHODIMP UntrustedModulesProcessor::Observe(nsISupports* aSubject,
Unused << proc->SendUnblockUntrustedModulesThread(); Unused << proc->SendUnblockUntrustedModulesThread();
} }
} }
if (RefPtr<gmp::GeckoMediaPluginServiceParent> gmps =
gmp::GeckoMediaPluginServiceParent::GetSingleton()) {
gmps->SendUnblockUntrustedModulesThread();
}
} }
return NS_OK; return NS_OK;
@ -767,10 +759,6 @@ UntrustedModulesProcessor::SendGetModulesTrust(ModulePaths&& aModules,
ipc::UtilityProcessChild::GetSingleton().get(), std::move(aModules), ipc::UtilityProcessChild::GetSingleton().get(), std::move(aModules),
runNormal); runNormal);
} }
case GeckoProcessType_GMPlugin: {
return ::mozilla::gmp::SendGetModulesTrust(std::move(aModules),
runNormal);
}
default: { default: {
MOZ_ASSERT_UNREACHABLE("Unsupported process type"); MOZ_ASSERT_UNREACHABLE("Unsupported process type");
return GetModulesTrustIpcPromise::CreateAndReject( return GetModulesTrustIpcPromise::CreateAndReject(

Просмотреть файл

@ -30,7 +30,12 @@ DllServices* DllServices::Get() {
static StaticLocalRefPtr<DllServices> sInstance( static StaticLocalRefPtr<DllServices> sInstance(
[]() -> already_AddRefed<DllServices> { []() -> already_AddRefed<DllServices> {
RefPtr<DllServices> dllSvc(new DllServices()); RefPtr<DllServices> dllSvc(new DllServices());
dllSvc->EnableFull(); // Full DLL services require XPCOM, which GMP doesn't have
if (XRE_IsGMPluginProcess()) {
dllSvc->EnableBasic();
} else {
dllSvc->EnableFull();
}
auto setClearOnShutdown = [ptr = &sInstance]() -> void { auto setClearOnShutdown = [ptr = &sInstance]() -> void {
ClearOnShutdown(ptr); ClearOnShutdown(ptr);
@ -75,6 +80,10 @@ RefPtr<UntrustedModulesPromise> DllServices::GetUntrustedModulesData() {
} }
void DllServices::DisableFull() { void DllServices::DisableFull() {
if (XRE_IsGMPluginProcess()) {
return;
}
if (mUntrustedModulesProcessor) { if (mUntrustedModulesProcessor) {
mUntrustedModulesProcessor->Disable(); mUntrustedModulesProcessor->Disable();
} }