Bug 1745444 - Merge TestTriggerGPUMetrics and TestTriggerRDDMetrics into a method taking a process type as parameter, r=chutten.

Differential Revision: https://phabricator.services.mozilla.com/D133508
This commit is contained in:
Florian Quèze 2021-12-15 16:27:57 +00:00
Родитель 90b4404217
Коммит e665115136
11 изменённых файлов: 50 добавлений и 43 удалений

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

@ -625,8 +625,10 @@ mozilla::ipc::IPCResult GPUParent::RecvFlushFOGData(
return IPC_OK();
}
mozilla::ipc::IPCResult GPUParent::RecvTestTriggerMetrics() {
mozilla::ipc::IPCResult GPUParent::RecvTestTriggerMetrics(
TestTriggerMetricsResolver&& aResolve) {
mozilla::glean::test_only_ipc::a_counter.Add(45326);
aResolve(true);
return IPC_OK();
}

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

@ -99,7 +99,8 @@ class GPUParent final : public PGPUParent {
mozilla::ipc::IPCResult RecvFlushFOGData(FlushFOGDataResolver&& aResolver);
mozilla::ipc::IPCResult RecvTestTriggerMetrics();
mozilla::ipc::IPCResult RecvTestTriggerMetrics(
TestTriggerMetricsResolver&& aResolve);
mozilla::ipc::IPCResult RecvCrashProcess();

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

@ -1273,10 +1273,14 @@ RefPtr<MemoryReportingProcess> GPUProcessManager::GetProcessMemoryReporter() {
return new GPUMemoryReporter();
}
void GPUProcessManager::TestTriggerMetrics() {
RefPtr<PGPUChild::TestTriggerMetricsPromise>
GPUProcessManager::TestTriggerMetrics() {
if (!NS_WARN_IF(!mGPUChild)) {
mGPUChild->SendTestTriggerMetrics();
return mGPUChild->SendTestTriggerMetrics();
}
return PGPUChild::TestTriggerMetricsPromise::CreateAndReject(
ipc::ResponseRejectReason::SendError, __func__);
}
} // namespace gfx

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

@ -12,6 +12,7 @@
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/ipc/IdType.h"
#include "mozilla/gfx/GPUProcessHost.h"
#include "mozilla/gfx/PGPUChild.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/TaskFactory.h"
@ -200,7 +201,7 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
*
* Trigger GPU-process test metric instrumentation.
*/
void TestTriggerMetrics();
RefPtr<PGPUChild::TestTriggerMetricsPromise> TestTriggerMetrics();
private:
// Called from our xpcom-shutdown observer.

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

@ -120,7 +120,8 @@ parent:
// Test-only method.
// Asks the gpu process to trigger test-only instrumentation.
async TestTriggerMetrics();
// The unused returned value is to have a promise we can await.
async TestTriggerMetrics() returns (bool unused);
// Causes the GPU process to crash. Used for tests and diagnostics.
async CrashProcess();

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

@ -21,6 +21,7 @@
#include "mozilla/RDDParent.h"
#include "mozilla/RDDProcessManager.h"
#include "mozilla/Unused.h"
#include "nsIXULRuntime.h"
#include "nsTArray.h"
#include "nsThreadUtils.h"
@ -202,15 +203,25 @@ RefPtr<GenericPromise> FlushAndUseFOGData() {
return ret;
}
void TestTriggerGPUMetrics() {
gfx::GPUProcessManager::Get()->TestTriggerMetrics();
}
void TestTriggerRDDMetrics(const RefPtr<dom::Promise>& promise) {
RDDProcessManager::Get()->TestTriggerMetrics()->Then(
GetCurrentSerialEventTarget(), __func__,
[promise]() { promise->MaybeResolveWithUndefined(); },
[promise]() { promise->MaybeRejectWithUndefined(); });
void TestTriggerMetrics(uint32_t aProcessType,
const RefPtr<dom::Promise>& promise) {
switch (aProcessType) {
case nsIXULRuntime::PROCESS_TYPE_GPU:
gfx::GPUProcessManager::Get()->TestTriggerMetrics()->Then(
GetCurrentSerialEventTarget(), __func__,
[promise]() { promise->MaybeResolveWithUndefined(); },
[promise]() { promise->MaybeRejectWithUndefined(); });
break;
case nsIXULRuntime::PROCESS_TYPE_RDD:
RDDProcessManager::Get()->TestTriggerMetrics()->Then(
GetCurrentSerialEventTarget(), __func__,
[promise]() { promise->MaybeResolveWithUndefined(); },
[promise]() { promise->MaybeRejectWithUndefined(); });
break;
default:
promise->MaybeRejectWithUndefined();
break;
}
}
} // namespace glean

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

@ -62,19 +62,14 @@ RefPtr<GenericPromise> FlushAndUseFOGData();
/**
* ** Test-only Method **
*
* Trigger GPU-process test instrumentation.
*/
void TestTriggerGPUMetrics();
/**
* ** Test-only Method **
*
* Trigger RDD-process test instrumentation.
* Trigger GPU or RDD process test instrumentation.
*
* @param processType - one of the PROCESS_TYPE_* constant from nsIXULRuntime.
* @param promise - a promise that will be resolved when the data has made it to
* the RDD process.
*/
void TestTriggerRDDMetrics(const RefPtr<dom::Promise>& promise);
void TestTriggerMetrics(uint32_t processType,
const RefPtr<dom::Promise>& promise);
} // namespace glean
} // namespace mozilla

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

@ -26,7 +26,7 @@ add_task(async () => {
"Ensure we begin without value."
);
Services.fog.testTriggerGPUMetrics();
await Services.fog.testTriggerMetrics(Ci.nsIXULRuntime.PROCESS_TYPE_GPU);
await Services.fog.testFlushAllChildren();
is(

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

@ -47,7 +47,7 @@ add_task(async () => {
await TestUtils.waitForCondition(async () => {
try {
await Services.fog.testTriggerRDDMetrics();
await Services.fog.testTriggerMetrics(Ci.nsIXULRuntime.PROCESS_TYPE_RDD);
return true;
} catch (e) {
return false;

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

@ -299,14 +299,8 @@ FOG::TestResetFOG(const nsACString& aDataPathOverride,
}
NS_IMETHODIMP
FOG::TestTriggerGPUMetrics() {
glean::TestTriggerGPUMetrics();
return NS_OK;
}
NS_IMETHODIMP
FOG::TestTriggerRDDMetrics(JSContext* aCx,
mozilla::dom::Promise** aOutPromise) {
FOG::TestTriggerMetrics(uint32_t aProcessType, JSContext* aCx,
mozilla::dom::Promise** aOutPromise) {
NS_ENSURE_ARG(aOutPromise);
*aOutPromise = nullptr;
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
@ -320,7 +314,7 @@ FOG::TestTriggerRDDMetrics(JSContext* aCx,
return erv.StealNSResult();
}
glean::TestTriggerRDDMetrics(promise);
glean::TestTriggerMetrics(aProcessType, promise);
promise.forget(aOutPromise);
return NS_OK;

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

@ -122,17 +122,15 @@ interface nsIFOG : nsISupports
/**
* ** Test-only Method **
*
* Trigger test metric instrumentation on the GPU process.
*/
void testTriggerGPUMetrics();
/**
* ** Test-only Method **
* Trigger test metric instrumentation on the GPU, RDD or Socket process.
*
* Trigger test metric instrumentation on the RDD process.
* @param aProcessType - A PROCESS_TYPE_* value from the constants defined
* in the nsIXULRuntime interface.
*
* @returns A promise that resolves when the test data has been added.
* The promise will be rejected if the process type is not supported
* or if sending the IPC to the child process fails.
*/
[implicit_jscontext]
Promise testTriggerRDDMetrics();
Promise testTriggerMetrics(in unsigned long aProcessType);
};