mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1562763 - Move some types around. r=jld
Having to namespace these into GeckoChildProcessHost is annoying. The |using| declarations help to some extent, but it's easier to just put them in mozilla::ipc. Differential Revision: https://phabricator.services.mozilla.com/D36538 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
91d8d02207
commit
3b7fbc734f
@ -2052,8 +2052,8 @@ void ContentParent::LaunchSubprocessInternal(
|
||||
if (isSync) {
|
||||
*aRetval.as<bool*>() = false;
|
||||
} else {
|
||||
*aRetval.as<RefPtr<LaunchPromise>*>() = LaunchPromise::CreateAndReject(
|
||||
GeckoChildProcessHost::LaunchError(), __func__);
|
||||
*aRetval.as<RefPtr<LaunchPromise>*>() =
|
||||
LaunchPromise::CreateAndReject(LaunchError(), __func__);
|
||||
}
|
||||
};
|
||||
|
||||
@ -2119,7 +2119,7 @@ void ContentParent::LaunchSubprocessInternal(
|
||||
|
||||
RefPtr<ContentParent> self(this);
|
||||
|
||||
auto reject = [self, this](GeckoChildProcessHost::LaunchError err) {
|
||||
auto reject = [self, this](LaunchError err) {
|
||||
NS_ERROR("failed to launch child in the parent");
|
||||
MarkAsDead();
|
||||
return LaunchPromise::CreateAndReject(err, __func__);
|
||||
@ -2207,19 +2207,19 @@ void ContentParent::LaunchSubprocessInternal(
|
||||
if (ok) {
|
||||
Unused << resolve(mSubprocess->GetChildProcessHandle());
|
||||
} else {
|
||||
Unused << reject(GeckoChildProcessHost::LaunchError{});
|
||||
Unused << reject(LaunchError{});
|
||||
}
|
||||
*aRetval.as<bool*>() = ok;
|
||||
} else {
|
||||
auto* retptr = aRetval.as<RefPtr<LaunchPromise>*>();
|
||||
if (mSubprocess->AsyncLaunch(std::move(extraArgs))) {
|
||||
RefPtr<GeckoChildProcessHost::HandlePromise> ready =
|
||||
RefPtr<ProcessHandlePromise> ready =
|
||||
mSubprocess->WhenProcessHandleReady();
|
||||
mLaunchYieldTS = TimeStamp::Now();
|
||||
*retptr = ready->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
std::move(resolve), std::move(reject));
|
||||
} else {
|
||||
*retptr = reject(GeckoChildProcessHost::LaunchError{});
|
||||
*retptr = reject(LaunchError{});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "mozilla/HalTypes.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/MemoryReportingProcess.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/Variant.h"
|
||||
@ -148,9 +149,9 @@ class ContentParent final : public PContentParent,
|
||||
#endif
|
||||
|
||||
public:
|
||||
using LaunchError = GeckoChildProcessHost::LaunchError;
|
||||
using LaunchError = mozilla::ipc::LaunchError;
|
||||
using LaunchPromise =
|
||||
GeckoChildProcessHost::LaunchPromise<RefPtr<ContentParent>>;
|
||||
mozilla::MozPromise<RefPtr<ContentParent>, LaunchError, false>;
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_CONTENTPARENT_IID)
|
||||
|
||||
|
@ -84,6 +84,8 @@ using mozilla::MonitorAutoLock;
|
||||
using mozilla::Preferences;
|
||||
using mozilla::StaticMutexAutoLock;
|
||||
using mozilla::ipc::GeckoChildProcessHost;
|
||||
using mozilla::ipc::LaunchError;
|
||||
using mozilla::ipc::ProcessHandlePromise;
|
||||
|
||||
namespace mozilla {
|
||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc, PRFileDesc,
|
||||
@ -192,14 +194,14 @@ void GeckoChildProcessHost::Destroy() {
|
||||
MOZ_RELEASE_ASSERT(!mDestroying);
|
||||
// We can remove from the list before it's really destroyed
|
||||
RemoveFromProcessList();
|
||||
RefPtr<HandlePromise> whenReady = mHandlePromise;
|
||||
RefPtr<ProcessHandlePromise> whenReady = mHandlePromise;
|
||||
|
||||
if (!whenReady) {
|
||||
// AsyncLaunch not called yet, so dispatch immediately.
|
||||
whenReady = HandlePromise::CreateAndReject(LaunchError{}, __func__);
|
||||
whenReady = ProcessHandlePromise::CreateAndReject(LaunchError{}, __func__);
|
||||
}
|
||||
|
||||
using Value = HandlePromise::ResolveOrRejectValue;
|
||||
using Value = ProcessHandlePromise::ResolveOrRejectValue;
|
||||
mDestroying = true;
|
||||
whenReady->Then(XRE_GetIOMessageLoop()->SerialEventTarget(), __func__,
|
||||
[this](const Value&) { delete this; });
|
||||
@ -401,7 +403,7 @@ bool GeckoChildProcessHost::AsyncLaunch(std::vector<std::string> aExtraOpts) {
|
||||
MessageLoop* ioLoop = XRE_GetIOMessageLoop();
|
||||
|
||||
MOZ_ASSERT(mHandlePromise == nullptr);
|
||||
mHandlePromise = new HandlePromise::Private(__func__);
|
||||
mHandlePromise = new ProcessHandlePromise::Private(__func__);
|
||||
|
||||
// Currently this can't fail (see the MOZ_ALWAYS_SUCCEEDS in
|
||||
// MessageLoop::PostTask_Helper), but in the future it possibly
|
||||
@ -1363,7 +1365,7 @@ void GeckoChildProcessHost::OnChannelError() {
|
||||
// FIXME/bug 773925: save up this error for the next listener.
|
||||
}
|
||||
|
||||
RefPtr<GeckoChildProcessHost::HandlePromise>
|
||||
RefPtr<ProcessHandlePromise>
|
||||
GeckoChildProcessHost::WhenProcessHandleReady() {
|
||||
MOZ_ASSERT(mHandlePromise != nullptr);
|
||||
return mHandlePromise;
|
||||
|
@ -38,6 +38,10 @@ typedef _MacSandboxInfo MacSandboxInfo;
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
struct LaunchError {};
|
||||
typedef mozilla::MozPromise<base::ProcessHandle, LaunchError, false>
|
||||
ProcessHandlePromise;
|
||||
|
||||
class GeckoChildProcessHost : public ChildProcessHost,
|
||||
public LinkedListElement<GeckoChildProcessHost> {
|
||||
protected:
|
||||
@ -94,14 +98,9 @@ class GeckoChildProcessHost : public ChildProcessHost,
|
||||
virtual void OnChannelError() override;
|
||||
virtual void GetQueuedMessages(std::queue<IPC::Message>& queue) override;
|
||||
|
||||
struct LaunchError {};
|
||||
template <typename T>
|
||||
using LaunchPromise = mozilla::MozPromise<T, LaunchError, /* excl: */ false>;
|
||||
using HandlePromise = LaunchPromise<base::ProcessHandle>;
|
||||
|
||||
// Resolves to the process handle when it's available (see
|
||||
// LaunchAndWaitForProcessHandle); use with AsyncLaunch.
|
||||
RefPtr<HandlePromise> WhenProcessHandleReady();
|
||||
RefPtr<ProcessHandlePromise> WhenProcessHandleReady();
|
||||
|
||||
virtual void InitializeChannel();
|
||||
|
||||
@ -211,7 +210,7 @@ class GeckoChildProcessHost : public ChildProcessHost,
|
||||
#if defined(OS_MACOSX)
|
||||
task_t mChildTask;
|
||||
#endif
|
||||
RefPtr<HandlePromise::Private> mHandlePromise;
|
||||
RefPtr<ProcessHandlePromise::Private> mHandlePromise;
|
||||
|
||||
bool OpenPrivilegedHandle(base::ProcessId aPid);
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <windows.h>
|
||||
|
||||
using mozilla::ipc::GeckoChildProcessHost;
|
||||
using mozilla::ipc::LaunchError;
|
||||
using mozilla::ipc::ProcessHandlePromise;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -21,11 +23,10 @@ RemoteSandboxBrokerProcessParent::~RemoteSandboxBrokerProcessParent() {
|
||||
MOZ_COUNT_DTOR(RemoteSandboxBrokerProcessParent);
|
||||
}
|
||||
|
||||
RefPtr<RemoteSandboxBrokerProcessParent::HandlePromise>
|
||||
RefPtr<ProcessHandlePromise>
|
||||
RemoteSandboxBrokerProcessParent::AsyncLaunch() {
|
||||
if (!GeckoChildProcessHost::AsyncLaunch()) {
|
||||
return HandlePromise::CreateAndReject(GeckoChildProcessHost::LaunchError{},
|
||||
__func__);
|
||||
return ProcessHandlePromise::CreateAndReject(LaunchError{}, __func__);
|
||||
}
|
||||
return WhenProcessHandleReady();
|
||||
}
|
||||
|
@ -21,14 +21,9 @@ namespace mozilla {
|
||||
class RemoteSandboxBrokerProcessParent final
|
||||
: public mozilla::ipc::GeckoChildProcessHost {
|
||||
public:
|
||||
using LaunchError = GeckoChildProcessHost::LaunchError;
|
||||
using LaunchPromise = GeckoChildProcessHost::LaunchPromise<bool>;
|
||||
|
||||
RemoteSandboxBrokerProcessParent();
|
||||
|
||||
using GeckoChildProcessHost::HandlePromise;
|
||||
|
||||
RefPtr<HandlePromise> AsyncLaunch();
|
||||
RefPtr<ipc::ProcessHandlePromise> AsyncLaunch();
|
||||
|
||||
bool CanShutdown() override { return true; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user