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"
#ifdef XP_WIN
# include <stdlib.h> // for _exit()
# include "mozilla/WinDllServices.h"
# include "WinUtils.h"
#else
# include <unistd.h> // for _exit()
@ -757,38 +756,6 @@ mozilla::ipc::IPCResult GMPChild::RecvShutdown(ShutdownResolver&& aResolver) {
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 mozilla

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

@ -82,16 +82,6 @@ class GMPChild : public PGMPChild {
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 ProcessingError(Result aCode, const char* aReason) override;

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

@ -39,7 +39,6 @@
#include "runnable_utils.h"
#ifdef XP_WIN
# include "mozilla/FileUtilsWin.h"
# include "mozilla/WinDllServices.h"
# include "WMFDecoderModule.h"
#endif
#if defined(MOZ_WIDGET_ANDROID)
@ -299,23 +298,13 @@ class NotifyGMPProcessLoadedTask : public Runnable {
}
#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) {
nsCOMPtr<nsISerialEventTarget> gmpEventTarget =
mGMPParent->GMPEventTarget();
if (!gmpEventTarget) {
return NS_ERROR_FAILURE;
}
ipc::Endpoint<PProfilerChild> profilerParent(
ProfilerParent::CreateForProcess(mProcessId));
@ -442,49 +431,6 @@ mozilla::ipc::IPCResult GMPParent::RecvFOGData(ByteBuf&& aBuf) {
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() {
MOZ_ASSERT(GMPEventTarget()->IsOnCurrentThread());
GMP_PARENT_LOG_DEBUG("%s", __FUNCTION__);

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

@ -178,12 +178,6 @@ class GMPParent final
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() {
return mGMPContentChildCount > 0 || !mGetContentParentPromises.IsEmpty();
}

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

@ -13,10 +13,6 @@
#include "base/time.h"
#include "mozilla/ReentrantMonitor.h"
#ifdef XP_WIN
# include "mozilla/UntrustedModulesProcessor.h"
#endif
#include <ctime>
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") {
MOZ_COUNT_CTOR(GMPThread);
}

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

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

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

@ -31,9 +31,6 @@
#include "mozilla/SyncRunnable.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Unused.h"
#if defined(XP_WIN)
# include "mozilla/UntrustedModulesData.h"
#endif
#include "nsAppDirectoryServiceDefs.h"
#include "nsComponentManagerUtils.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>
GeckoMediaPluginServiceParent::TestTriggerMetrics() {
MOZ_ASSERT(NS_IsMainThread());

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

@ -82,16 +82,6 @@ class GeckoMediaPluginServiceParent final
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 **
*

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

@ -9,12 +9,6 @@ include protocol PGMPTimer;
include protocol PGMPStorage;
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 "GMPParent.h";
include "GMPChild.h";
@ -42,11 +36,6 @@ parent:
// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/ipc.html
async FOGData(ByteBuf buf);
#if defined(XP_WIN)
async GetModulesTrust(ModulePaths aModPaths, bool aRunAtNormalPriority)
returns (ModulesMapResult? modMapResult);
#endif // defined(XP_WIN)
child:
async CrashPluginNow();
[Nested=inside_sync] sync StartPlugin(nsString adapter);
@ -62,20 +51,6 @@ child:
// https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/ipc.html
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.
// Asks the GMP process to trigger test-only instrumentation.
// The unused returned value is to have a promise we can await.

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

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

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

@ -6,7 +6,6 @@
#include "UntrustedModules.h"
#include "GMPServiceParent.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/MozPromise.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;
}

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

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

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

@ -30,7 +30,12 @@ DllServices* DllServices::Get() {
static StaticLocalRefPtr<DllServices> sInstance(
[]() -> already_AddRefed<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 {
ClearOnShutdown(ptr);
@ -75,6 +80,10 @@ RefPtr<UntrustedModulesPromise> DllServices::GetUntrustedModulesData() {
}
void DllServices::DisableFull() {
if (XRE_IsGMPluginProcess()) {
return;
}
if (mUntrustedModulesProcessor) {
mUntrustedModulesProcessor->Disable();
}