Bug 1518344 - P3. Launch the RDD process fully asynchronously. r=jld,mjf,bryce

And clarify which thread a method is called from, ensure all members are only ever accessed on the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D96668
This commit is contained in:
Jean-Yves Avenard 2020-11-19 01:21:05 +00:00
parent 0a09476fa2
commit 5318ef7bab
4 changed files with 250 additions and 215 deletions

View File

@ -5,13 +5,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "RDDProcessHost.h"
#include "ProcessUtils.h"
#include "RDDChild.h"
#include "chrome/common/process_watcher.h"
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs_media.h"
#include "ProcessUtils.h"
#include "RDDChild.h"
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
# include "mozilla/Sandbox.h"
#endif
@ -27,11 +26,7 @@ bool RDDProcessHost::sLaunchWithMacSandbox = false;
RDDProcessHost::RDDProcessHost(Listener* aListener)
: GeckoChildProcessHost(GeckoProcessType_RDD),
mListener(aListener),
mTaskFactory(this),
mLaunchPhase(LaunchPhase::Unlaunched),
mProcessToken(0),
mShutdownRequested(false),
mChannelClosed(false) {
mLiveToken(new media::Refcountable<bool>(true)) {
MOZ_COUNT_CTOR(RDDProcessHost);
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
@ -45,6 +40,8 @@ RDDProcessHost::RDDProcessHost(Listener* aListener)
RDDProcessHost::~RDDProcessHost() { MOZ_COUNT_DTOR(RDDProcessHost); }
bool RDDProcessHost::Launch(StringVector aExtraOpts) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mLaunchPhase == LaunchPhase::Unlaunched);
MOZ_ASSERT(!mRDDChild);
@ -61,19 +58,6 @@ bool RDDProcessHost::Launch(StringVector aExtraOpts) {
mLaunchPhase = LaunchPhase::Waiting;
mLaunchTime = TimeStamp::Now();
if (!GeckoChildProcessHost::AsyncLaunch(aExtraOpts)) {
mLaunchPhase = LaunchPhase::Complete;
mPrefSerializer = nullptr;
return false;
}
return true;
}
bool RDDProcessHost::WaitForLaunch() {
if (mLaunchPhase == LaunchPhase::Complete) {
return !!mRDDChild;
}
int32_t timeoutMs = StaticPrefs::media_rdd_process_startup_timeout_ms();
// If one of the following environment variables are set we can
@ -83,13 +67,62 @@ bool RDDProcessHost::WaitForLaunch() {
PR_GetEnv("MOZ_DEBUG_CHILD_PAUSE")) {
timeoutMs = 0;
}
if (timeoutMs) {
// We queue a delayed task. If that task runs before the
// WhenProcessHandleReady promise gets resolved, we will abort the launch.
GetMainThreadSerialEventTarget()->DelayedDispatch(
NS_NewRunnableFunction(
"RDDProcessHost::Launchtimeout",
[this, liveToken = mLiveToken]() {
if (!*liveToken || mTimerChecked) {
// We have been deleted or the runnable has already started, we
// can abort.
return;
}
InitAfterConnect(false);
MOZ_ASSERT(mTimerChecked,
"InitAfterConnect must have acted on the promise");
}),
timeoutMs);
}
// Our caller expects the connection to be finished after we return, so we
// immediately set up the IPDL actor and fire callbacks. The IO thread will
// still dispatch a notification to the main thread - we'll just ignore it.
bool result = GeckoChildProcessHost::WaitUntilConnected(timeoutMs);
InitAfterConnect(result);
return result;
if (!GeckoChildProcessHost::AsyncLaunch(aExtraOpts)) {
mLaunchPhase = LaunchPhase::Complete;
mPrefSerializer = nullptr;
return false;
}
return true;
}
RefPtr<GenericNonExclusivePromise> RDDProcessHost::LaunchPromise() {
MOZ_ASSERT(NS_IsMainThread());
if (mLaunchPromise) {
return mLaunchPromise;
}
mLaunchPromise = MakeRefPtr<GenericNonExclusivePromise::Private>(__func__);
WhenProcessHandleReady()->Then(
GetCurrentSerialEventTarget(), __func__,
[this, liveToken = mLiveToken](
const ipc::ProcessHandlePromise::ResolveOrRejectValue& aResult) {
if (!*liveToken) {
// The RDDProcessHost got deleted. Abort. The promise would have
// already been rejected.
return;
}
if (mTimerChecked) {
// We hit the timeout earlier, abort.
return;
}
mTimerChecked = true;
if (aResult.IsReject()) {
RejectPromise();
}
// If aResult.IsResolve() then we have succeeded in launching the
// RDD process. The promise will be resolved once the channel has
// connected (or failed to) later.
});
return mLaunchPromise;
}
void RDDProcessHost::OnChannelConnected(int32_t peer_pid) {
@ -97,15 +130,12 @@ void RDDProcessHost::OnChannelConnected(int32_t peer_pid) {
GeckoChildProcessHost::OnChannelConnected(peer_pid);
// Post a task to the main thread. Take the lock because mTaskFactory is not
// thread-safe.
RefPtr<Runnable> runnable;
{
MonitorAutoLock lock(mMonitor);
runnable =
mTaskFactory.NewRunnableMethod(&RDDProcessHost::OnChannelConnectedTask);
}
NS_DispatchToMainThread(runnable);
NS_DispatchToMainThread(NS_NewRunnableFunction(
"RDDProcessHost::OnChannelConnected", [this, liveToken = mLiveToken]() {
if (*liveToken && mLaunchPhase == LaunchPhase::Waiting) {
InitAfterConnect(true);
}
}));
}
void RDDProcessHost::OnChannelError() {
@ -113,71 +143,59 @@ void RDDProcessHost::OnChannelError() {
GeckoChildProcessHost::OnChannelError();
// Post a task to the main thread. Take the lock because mTaskFactory is not
// thread-safe.
RefPtr<Runnable> runnable;
{
MonitorAutoLock lock(mMonitor);
runnable =
mTaskFactory.NewRunnableMethod(&RDDProcessHost::OnChannelErrorTask);
}
NS_DispatchToMainThread(runnable);
}
void RDDProcessHost::OnChannelConnectedTask() {
if (mLaunchPhase == LaunchPhase::Waiting) {
InitAfterConnect(true);
}
}
void RDDProcessHost::OnChannelErrorTask() {
if (mLaunchPhase == LaunchPhase::Waiting) {
InitAfterConnect(false);
}
NS_DispatchToMainThread(NS_NewRunnableFunction(
"RDDProcessHost::OnChannelError", [this, liveToken = mLiveToken]() {
if (*liveToken && mLaunchPhase == LaunchPhase::Waiting) {
InitAfterConnect(false);
}
}));
}
static uint64_t sRDDProcessTokenCounter = 0;
void RDDProcessHost::InitAfterConnect(bool aSucceeded) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mLaunchPhase == LaunchPhase::Waiting);
MOZ_ASSERT(!mRDDChild);
mLaunchPhase = LaunchPhase::Complete;
if (aSucceeded) {
mProcessToken = ++sRDDProcessTokenCounter;
mRDDChild = MakeUnique<RDDChild>(this);
DebugOnly<bool> rv = mRDDChild->Open(
TakeChannel(), base::GetProcId(GetChildProcessHandle()));
MOZ_ASSERT(rv);
// Only clear mPrefSerializer in the success case to avoid a
// possible race in the case case of a timeout on Windows launch.
// See Bug 1555076 comment 7:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1555076#c7
mPrefSerializer = nullptr;
if (!mRDDChild->Init()) {
// Can't just kill here because it will create a timing race that
// will crash the tab. We don't really want to crash the tab just
// because RDD linux sandbox failed to initialize. In this case,
// we'll close the child channel which will cause the RDD process
// to shutdown nicely avoiding the tab crash (which manifests as
// Bug 1535335).
mRDDChild->Close();
return;
}
if (!aSucceeded) {
RejectPromise();
return;
}
mProcessToken = ++sRDDProcessTokenCounter;
mRDDChild = MakeUnique<RDDChild>(this);
DebugOnly<bool> rv =
mRDDChild->Open(TakeChannel(), base::GetProcId(GetChildProcessHandle()));
MOZ_ASSERT(rv);
if (mListener) {
mListener->OnProcessLaunchComplete(this);
// Only clear mPrefSerializer in the success case to avoid a
// possible race in the case case of a timeout on Windows launch.
// See Bug 1555076 comment 7:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1555076#c7
mPrefSerializer = nullptr;
if (!mRDDChild->Init()) {
// Can't just kill here because it will create a timing race that
// will crash the tab. We don't really want to crash the tab just
// because RDD linux sandbox failed to initialize. In this case,
// we'll close the child channel which will cause the RDD process
// to shutdown nicely avoiding the tab crash (which manifests as
// Bug 1535335).
mRDDChild->Close();
RejectPromise();
} else {
ResolvePromise();
}
}
void RDDProcessHost::Shutdown() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShutdownRequested);
mListener = nullptr;
RejectPromise();
if (mRDDChild) {
// OnChannelClosed uses this to check if the shutdown was expected or
@ -208,7 +226,10 @@ void RDDProcessHost::Shutdown() {
}
void RDDProcessHost::OnChannelClosed() {
MOZ_ASSERT(NS_IsMainThread());
mChannelClosed = true;
RejectPromise();
if (!mShutdownRequested && mListener) {
// This is an unclean shutdown. Notify our listener that we're going away.
@ -219,10 +240,11 @@ void RDDProcessHost::OnChannelClosed() {
// Release the actor.
RDDChild::Destroy(std::move(mRDDChild));
MOZ_ASSERT(!mRDDChild);
}
void RDDProcessHost::KillHard(const char* aReason) {
MOZ_ASSERT(NS_IsMainThread());
ProcessHandle handle = GetChildProcessHandle();
if (!base::KillProcess(handle, base::PROCESS_END_KILLED_BY_USER, false)) {
NS_WARNING("failed to kill subprocess!");
@ -231,22 +253,46 @@ void RDDProcessHost::KillHard(const char* aReason) {
SetAlreadyDead();
}
uint64_t RDDProcessHost::GetProcessToken() const { return mProcessToken; }
void RDDProcessHost::KillProcess() { KillHard("DiagnosticKill"); }
uint64_t RDDProcessHost::GetProcessToken() const {
MOZ_ASSERT(NS_IsMainThread());
return mProcessToken;
}
void RDDProcessHost::DestroyProcess() {
// Cancel all tasks. We don't want anything triggering after our caller
// expects this to go away.
{
MonitorAutoLock lock(mMonitor);
mTaskFactory.RevokeAll();
}
MOZ_ASSERT(NS_IsMainThread());
RejectPromise();
GetCurrentSerialEventTarget()->Dispatch(
// Any pending tasks will be cancelled from now on.
*mLiveToken = false;
NS_DispatchToMainThread(
NS_NewRunnableFunction("DestroyProcessRunnable", [this] { Destroy(); }));
}
void RDDProcessHost::ResolvePromise() {
MOZ_ASSERT(NS_IsMainThread());
if (!mLaunchPromiseSettled) {
mLaunchPromise->Resolve(true, __func__);
mLaunchPromiseSettled = true;
}
// We have already acted on the promise; the timeout runnable no longer needs
// to interrupt anything.
mTimerChecked = true;
}
void RDDProcessHost::RejectPromise() {
MOZ_ASSERT(NS_IsMainThread());
if (!mLaunchPromiseSettled) {
mLaunchPromise->Reject(NS_ERROR_FAILURE, __func__);
mLaunchPromiseSettled = true;
}
// We have already acted on the promise; the timeout runnable no longer needs
// to interrupt anything.
mTimerChecked = true;
}
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
bool RDDProcessHost::FillMacSandboxInfo(MacSandboxInfo& aInfo) {
GeckoChildProcessHost::FillMacSandboxInfo(aInfo);

View File

@ -6,12 +6,10 @@
#ifndef _include_dom_media_ipc_RDDProcessHost_h_
#define _include_dom_media_ipc_RDDProcessHost_h_
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "mozilla/Maybe.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/TaskFactory.h"
#include "mozilla/media/MediaUtils.h"
namespace mozilla {
namespace ipc {
@ -37,8 +35,6 @@ class RDDProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
public:
class Listener {
public:
virtual void OnProcessLaunchComplete(RDDProcessHost* aHost) {}
// The RDDProcessHost has unexpectedly shutdown or had its connection
// severed. This is not called if an error occurs after calling
// Shutdown().
@ -48,19 +44,18 @@ class RDDProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
explicit RDDProcessHost(Listener* listener);
// Launch the subprocess asynchronously. On failure, false is returned.
// Otherwise, true is returned, and the OnProcessLaunchComplete listener
// callback will be invoked either when a connection has been established, or
// if a connection could not be established due to an asynchronous error.
// Otherwise, true is returned. If succeeded, a follow-up call should be made
// to LaunchPromise() which will return a promise that will be resolved once
// the RDD process has launched and a channel has been established.
//
// @param aExtraOpts (StringVector)
// Extra options to pass to the subprocess.
bool Launch(StringVector aExtraOpts);
// If the process is being launched, block until it has launched and
// connected. If a launch task is pending, it will fire immediately.
//
// Returns true if the process is successfully connected; false otherwise.
bool WaitForLaunch();
// Return a promise that will be resolved once the process has completed its
// launch. The promise will be immediately resolved if the launch has already
// succeeded.
RefPtr<GenericNonExclusivePromise> LaunchPromise();
// Inform the process that it should clean up its resources and shut
// down. This initiates an asynchronous shutdown sequence. After this
@ -72,13 +67,19 @@ class RDDProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
// Return the actor for the top-level actor of the process. If the process
// has not connected yet, this returns null.
RDDChild* GetActor() const { return mRDDChild.get(); }
RDDChild* GetActor() const {
MOZ_ASSERT(NS_IsMainThread());
return mRDDChild.get();
}
// Return a unique id for this process, guaranteed not to be shared with any
// past or future instance of RDDProcessHost.
uint64_t GetProcessToken() const;
bool IsConnected() const { return !!mRDDChild; }
bool IsConnected() const {
MOZ_ASSERT(NS_IsMainThread());
return !!mRDDChild;
}
// Return the time stamp for when we tried to launch the RDD process.
// This is currently used for Telemetry so that we can determine how
@ -92,9 +93,6 @@ class RDDProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
void SetListener(Listener* aListener);
// Used for tests and diagnostics
void KillProcess();
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
// Return the sandbox type to be used with this process type.
static MacSandboxType GetMacSandboxType();
@ -103,11 +101,8 @@ class RDDProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
private:
~RDDProcessHost();
// Called on the main thread.
void OnChannelConnectedTask();
void OnChannelErrorTask();
// Called on the main thread after a connection has been established.
// Called on the main thread with true after a connection has been established
// or false if it failed (including if it failed before the timeout kicked in)
void InitAfterConnect(bool aSucceeded);
// Called on the main thread when the mRDDChild actor is shutting down.
@ -130,21 +125,37 @@ class RDDProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
DISALLOW_COPY_AND_ASSIGN(RDDProcessHost);
Listener* mListener;
mozilla::ipc::TaskFactory<RDDProcessHost> mTaskFactory;
Listener* const mListener;
// All members below are only ever accessed on the main thread.
enum class LaunchPhase { Unlaunched, Waiting, Complete };
LaunchPhase mLaunchPhase;
LaunchPhase mLaunchPhase = LaunchPhase::Unlaunched;
UniquePtr<RDDChild> mRDDChild;
uint64_t mProcessToken;
uint64_t mProcessToken = 0;
UniquePtr<ipc::SharedPreferenceSerializer> mPrefSerializer;
bool mShutdownRequested;
bool mChannelClosed;
bool mShutdownRequested = false;
bool mChannelClosed = false;
TimeStamp mLaunchTime;
void RejectPromise();
void ResolvePromise();
// Set to true on construction and to false just prior deletion.
// The RDDProcessHost isn't refcounted; so we can capture this by value in
// lambdas along with a strong reference to mLiveToken and check if that value
// is true before accessing "this".
// While a reference to mLiveToken can be taken on any thread; its value can
// only be read on the main thread.
const RefPtr<media::Refcountable<bool>> mLiveToken;
RefPtr<GenericNonExclusivePromise::Private> mLaunchPromise;
bool mLaunchPromiseSettled = false;
// Will be set to true if we've exceeded the allowed startup time or if the
// RDD process as successfully started. This is used to determine if the
// timeout runnable needs to execute code or not.
bool mTimerChecked = false;
};
} // namespace mozilla

View File

@ -101,47 +101,77 @@ void RDDProcessManager::OnPreferenceChange(const char16_t* aData) {
auto RDDProcessManager::EnsureRDDProcessAndCreateBridge(
base::ProcessId aOtherProcess) -> RefPtr<EnsureRDDPromise> {
return InvokeAsync(GetMainThreadSerialEventTarget(), __func__,
[aOtherProcess, this]() -> RefPtr<EnsureRDDPromise> {
if (!Get()) {
// Shutdown?
return EnsureRDDPromise::CreateAndReject(
NS_ERROR_NOT_AVAILABLE, __func__);
}
if (mProcess) {
ipc::Endpoint<PRemoteDecoderManagerChild> endpoint;
if (!CreateContentBridge(aOtherProcess, &endpoint)) {
return EnsureRDDPromise::CreateAndReject(
NS_ERROR_NOT_AVAILABLE, __func__);
}
return EnsureRDDPromise::CreateAndResolve(
std::move(endpoint), __func__);
}
return InvokeAsync(
GetMainThreadSerialEventTarget(), __func__,
[aOtherProcess, this]() -> RefPtr<EnsureRDDPromise> {
if (!Get()) {
// Shutdown?
return EnsureRDDPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__);
}
if (mProcess) {
return mProcess->LaunchPromise()->Then(
GetMainThreadSerialEventTarget(), __func__,
[aOtherProcess, this](bool) {
ipc::Endpoint<PRemoteDecoderManagerChild> endpoint;
if (!CreateContentBridge(aOtherProcess, &endpoint)) {
return EnsureRDDPromise::CreateAndReject(
NS_ERROR_NOT_AVAILABLE, __func__);
}
return EnsureRDDPromise::CreateAndResolve(std::move(endpoint),
__func__);
},
[](nsresult aError) {
return EnsureRDDPromise::CreateAndReject(aError, __func__);
});
}
mNumProcessAttempts++;
// Launch the RDD process.
std::vector<std::string> extraArgs;
nsCString parentBuildID(mozilla::PlatformBuildID());
extraArgs.push_back("-parentBuildID");
extraArgs.push_back(parentBuildID.get());
std::vector<std::string> extraArgs;
nsCString parentBuildID(mozilla::PlatformBuildID());
extraArgs.push_back("-parentBuildID");
extraArgs.push_back(parentBuildID.get());
// The subprocess is launched asynchronously, so we
// wait for the promise to be resolved to acquire the IPDL actor.
mProcess = new RDDProcessHost(this);
if (!mProcess->Launch(extraArgs)) {
DestroyProcess();
return EnsureRDDPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__);
}
return mProcess->LaunchPromise()->Then(
GetMainThreadSerialEventTarget(), __func__,
[aOtherProcess, this](bool) {
mRDDChild = mProcess->GetActor();
mProcessToken = mProcess->GetProcessToken();
// The subprocess is launched asynchronously, so we wait
// for a callback to acquire the IPDL actor.
mProcess = new RDDProcessHost(this);
if (!mProcess->Launch(extraArgs)) {
DestroyProcess();
return EnsureRDDPromise::CreateAndReject(
NS_ERROR_NOT_AVAILABLE, __func__);
}
ipc::Endpoint<PRemoteDecoderManagerChild> endpoint;
if (!EnsureRDDReady() || !CreateVideoBridge() ||
!CreateContentBridge(aOtherProcess, &endpoint)) {
return EnsureRDDPromise::CreateAndReject(
NS_ERROR_NOT_AVAILABLE, __func__);
}
return EnsureRDDPromise::CreateAndResolve(
std::move(endpoint), __func__);
});
// Flush any pref updates that happened during
// launch and weren't included in the blobs set
// up in LaunchRDDProcess.
for (const mozilla::dom::Pref& pref : mQueuedPrefs) {
Unused << NS_WARN_IF(!mRDDChild->SendPreferenceUpdate(pref));
}
mQueuedPrefs.Clear();
CrashReporter::AnnotateCrashReport(
CrashReporter::Annotation::RDDProcessStatus, "Running"_ns);
ipc::Endpoint<PRemoteDecoderManagerChild> endpoint;
if (!CreateVideoBridge() ||
!CreateContentBridge(aOtherProcess, &endpoint)) {
return EnsureRDDPromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__);
}
return EnsureRDDPromise::CreateAndResolve(std::move(endpoint),
__func__);
},
[this](nsresult aError) {
DestroyProcess();
return EnsureRDDPromise::CreateAndReject(aError, __func__);
});
});
}
bool RDDProcessManager::IsRDDProcessLaunching() {
@ -149,41 +179,6 @@ bool RDDProcessManager::IsRDDProcessLaunching() {
return !!mProcess && !mRDDChild;
}
bool RDDProcessManager::EnsureRDDReady() {
MOZ_ASSERT(NS_IsMainThread());
if (mProcess && !mProcess->IsConnected() && !mProcess->WaitForLaunch()) {
// If this fails, we should have fired OnProcessLaunchComplete and
// removed the process.
MOZ_ASSERT(!mProcess && !mRDDChild);
return false;
}
return true;
}
void RDDProcessManager::OnProcessLaunchComplete(RDDProcessHost* aHost) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mProcess && mProcess == aHost);
if (!mProcess->IsConnected()) {
DestroyProcess();
return;
}
mRDDChild = mProcess->GetActor();
mProcessToken = mProcess->GetProcessToken();
// Flush any pref updates that happened during launch and weren't
// included in the blobs set up in LaunchRDDProcess.
for (const mozilla::dom::Pref& pref : mQueuedPrefs) {
Unused << NS_WARN_IF(!mRDDChild->SendPreferenceUpdate(pref));
}
mQueuedPrefs.Clear();
CrashReporter::AnnotateCrashReport(
CrashReporter::Annotation::RDDProcessStatus, "Running"_ns);
}
void RDDProcessManager::OnProcessUnexpectedShutdown(RDDProcessHost* aHost) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mProcess && mProcess == aHost);
@ -214,15 +209,6 @@ void RDDProcessManager::NotifyRemoteActorDestroyed(
void RDDProcessManager::CleanShutdown() { DestroyProcess(); }
void RDDProcessManager::KillProcess() {
MOZ_ASSERT(NS_IsMainThread());
if (!mProcess) {
return;
}
mProcess->KillProcess();
}
void RDDProcessManager::DestroyProcess() {
MOZ_ASSERT(NS_IsMainThread());
if (!mProcess) {
@ -345,7 +331,7 @@ class RDDMemoryReporter : public MemoryReportingProcess {
};
RefPtr<MemoryReportingProcess> RDDProcessManager::GetProcessMemoryReporter() {
if (!EnsureRDDReady()) {
if (!mProcess || !mProcess->IsConnected()) {
return nullptr;
}
return new RDDMemoryReporter();

View File

@ -35,16 +35,12 @@ class RDDProcessManager final : public RDDProcessHost::Listener {
RefPtr<EnsureRDDPromise> EnsureRDDProcessAndCreateBridge(
base::ProcessId aOtherProcess);
void OnProcessLaunchComplete(RDDProcessHost* aHost) override;
void OnProcessUnexpectedShutdown(RDDProcessHost* aHost) override;
// Notify the RDDProcessManager that a top-level PRDD protocol has been
// terminated. This may be called from any thread.
void NotifyRemoteActorDestroyed(const uint64_t& aProcessToken);
// Used for tests and diagnostics
void KillProcess();
// Returns -1 if there is no RDD process, or the platform pid for it.
base::ProcessId RDDProcessPid();
@ -63,10 +59,6 @@ class RDDProcessManager final : public RDDProcessHost::Listener {
private:
bool IsRDDProcessLaunching();
// Ensure that RDD-bound methods can be used. If no RDD process is being
// used, or one is launched and ready, this function returns immediately.
// Otherwise it blocks until the RDD process has finished launching.
bool EnsureRDDReady();
bool CreateVideoBridge();
// Called from our xpcom-shutdown observer.