Bug 1673513 - ProfilerParent::RequestGatherProfileProgress(aChildPid) - r=florian

This helper function in ProfilerParent sends a progress request to a child process. If successfully sent, the response will resolve the returned promise.

Differential Revision: https://phabricator.services.mozilla.com/D135486
This commit is contained in:
Gerald Squelart 2022-01-31 02:22:29 +00:00
Родитель 9ffde9c15b
Коммит 75fffbdebe
2 изменённых файлов: 23 добавлений и 0 удалений

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

@ -660,6 +660,17 @@ ProfilerParent::GatherProfiles() {
return results;
}
/* static */
RefPtr<ProfilerParent::SingleProcessProgressPromise>
ProfilerParent::RequestGatherProfileProgress(base::ProcessId aChildPid) {
RefPtr<SingleProcessProgressPromise> promise;
ProfilerParentTracker::ForChild(
aChildPid, [&promise](ProfilerParent* profilerParent) {
promise = profilerParent->SendGetGatherProfileProgress();
});
return promise;
}
// Magic value for ProfileBufferChunkManagerUpdate::unreleasedBytes meaning
// that this is a final update from a child.
constexpr static uint64_t scUpdateUnreleasedBytesFINAL = uint64_t(-1);

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

@ -45,6 +45,9 @@ class ProfilerParent final : public PProfilerParent {
base::ProcessId childPid;
};
using SingleProcessProgressPromise =
MozPromise<GatherProfileProgress, ResponseRejectReason, true>;
// The following static methods can be called on any thread, but they are
// no-ops on anything other than the main thread.
// If called on the main thread, the call will be broadcast to all
@ -59,6 +62,15 @@ class ProfilerParent final : public PProfilerParent {
// Returns the profiles to expect, as promises and child pids.
static nsTArray<SingleProcessProfilePromiseAndChildPid> GatherProfiles();
// Send a request to get the GatherProfiles() progress update from one child
// process, returns a promise to be resolved with that progress.
// The promise RefPtr may be null if the child process is unknown.
// Progress may be invalid, if the request arrived after the child process
// had already responded to the main GatherProfile() IPC, or something went
// very wrong in that process.
static RefPtr<SingleProcessProgressPromise> RequestGatherProfileProgress(
base::ProcessId aChildPid);
static void ProfilerStarted(nsIProfilerStartParams* aParams);
static void ProfilerWillStopIfStarted();
static void ProfilerStopped();