forked from mirrors/gecko-dev
Bug 1647759 - P3: Send init attributes to socket process r=dragana
Depends on D82352 Differential Revision: https://phabricator.services.mozilla.com/D82353
This commit is contained in:
parent
6cb09fb6f3
commit
9c8f0c8d00
4 changed files with 59 additions and 38 deletions
|
|
@ -69,6 +69,12 @@ struct SocketDataArgs
|
||||||
SocketInfo[] info;
|
SocketInfo[] info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SocketPorcessInitAttributes {
|
||||||
|
bool mOffline;
|
||||||
|
bool mConnectivity;
|
||||||
|
FileDescriptor? mSandboxBroker;
|
||||||
|
};
|
||||||
|
|
||||||
sync protocol PSocketProcess
|
sync protocol PSocketProcess
|
||||||
{
|
{
|
||||||
manages PDNSRequest;
|
manages PDNSRequest;
|
||||||
|
|
@ -125,6 +131,7 @@ parent:
|
||||||
returns (bool aAccepted);
|
returns (bool aAccepted);
|
||||||
|
|
||||||
child:
|
child:
|
||||||
|
async Init(SocketPorcessInitAttributes aAttributes);
|
||||||
async PreferenceUpdate(Pref pref);
|
async PreferenceUpdate(Pref pref);
|
||||||
async RequestMemoryReport(uint32_t generation,
|
async RequestMemoryReport(uint32_t generation,
|
||||||
bool anonymize,
|
bool anonymize,
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,14 @@ void SocketProcessChild::CleanUp() {
|
||||||
NS_ShutdownXPCOM(nullptr);
|
NS_ShutdownXPCOM(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mozilla::ipc::IPCResult SocketProcessChild::RecvInit(
|
||||||
|
const SocketPorcessInitAttributes& aAttributes) {
|
||||||
|
Unused << RecvSetOffline(aAttributes.mOffline());
|
||||||
|
Unused << RecvSetConnectivity(aAttributes.mConnectivity());
|
||||||
|
Unused << RecvInitLinuxSandbox(aAttributes.mSandboxBroker());
|
||||||
|
return IPC_OK();
|
||||||
|
}
|
||||||
|
|
||||||
IPCResult SocketProcessChild::RecvPreferenceUpdate(const Pref& aPref) {
|
IPCResult SocketProcessChild::RecvPreferenceUpdate(const Pref& aPref) {
|
||||||
Preferences::SetPreference(aPref);
|
Preferences::SetPreference(aPref);
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ class SocketProcessChild final
|
||||||
|
|
||||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||||
|
|
||||||
|
mozilla::ipc::IPCResult RecvInit(
|
||||||
|
const SocketPorcessInitAttributes& aAttributes);
|
||||||
mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& aPref);
|
mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& aPref);
|
||||||
mozilla::ipc::IPCResult RecvRequestMemoryReport(
|
mozilla::ipc::IPCResult RecvRequestMemoryReport(
|
||||||
const uint32_t& generation, const bool& anonymize,
|
const uint32_t& generation, const bool& anonymize,
|
||||||
|
|
|
||||||
|
|
@ -134,48 +134,52 @@ void SocketProcessHost::InitAfterConnect(bool aSucceeded) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
mLaunchPhase = LaunchPhase::Complete;
|
mLaunchPhase = LaunchPhase::Complete;
|
||||||
|
if (!aSucceeded) {
|
||||||
|
if (mListener) {
|
||||||
|
mListener->OnProcessLaunchComplete(this, false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (aSucceeded) {
|
|
||||||
mSocketProcessParent = MakeUnique<SocketProcessParent>(this);
|
mSocketProcessParent = MakeUnique<SocketProcessParent>(this);
|
||||||
DebugOnly<bool> rv = mSocketProcessParent->Open(
|
DebugOnly<bool> rv = mSocketProcessParent->Open(
|
||||||
TakeChannel(), base::GetProcId(GetChildProcessHandle()));
|
TakeChannel(), base::GetProcId(GetChildProcessHandle()));
|
||||||
MOZ_ASSERT(rv);
|
MOZ_ASSERT(rv);
|
||||||
|
|
||||||
|
SocketPorcessInitAttributes attributes;
|
||||||
nsCOMPtr<nsIIOService> ioService(do_GetIOService());
|
nsCOMPtr<nsIIOService> ioService(do_GetIOService());
|
||||||
MOZ_ASSERT(ioService, "No IO service?");
|
MOZ_ASSERT(ioService, "No IO service?");
|
||||||
bool offline = false;
|
DebugOnly<nsresult> result = ioService->GetOffline(&attributes.mOffline());
|
||||||
DebugOnly<nsresult> result = ioService->GetOffline(&offline);
|
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(result), "Failed getting offline?");
|
MOZ_ASSERT(NS_SUCCEEDED(result), "Failed getting offline?");
|
||||||
|
result = ioService->GetConnectivity(&attributes.mConnectivity());
|
||||||
Maybe<FileDescriptor> brokerFd;
|
MOZ_ASSERT(NS_SUCCEEDED(result), "Failed getting connectivity?");
|
||||||
|
|
||||||
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
|
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
|
||||||
if (GetEffectiveSocketProcessSandboxLevel() > 0) {
|
if (GetEffectiveSocketProcessSandboxLevel() > 0) {
|
||||||
auto policy = SandboxBrokerPolicyFactory::GetSocketProcessPolicy(
|
auto policy = SandboxBrokerPolicyFactory::GetSocketProcessPolicy(
|
||||||
GetActor()->OtherPid());
|
GetActor()->OtherPid());
|
||||||
if (policy != nullptr) {
|
if (policy != nullptr) {
|
||||||
brokerFd = Some(FileDescriptor());
|
attributes.mSandboxBroker() = Some(FileDescriptor());
|
||||||
mSandboxBroker = SandboxBroker::Create(
|
mSandboxBroker =
|
||||||
std::move(policy), GetActor()->OtherPid(), brokerFd.ref());
|
SandboxBroker::Create(std::move(policy), GetActor()->OtherPid(),
|
||||||
|
attributes.mSandboxBroker().ref());
|
||||||
// This is unlikely to fail and probably indicates OS resource
|
// This is unlikely to fail and probably indicates OS resource
|
||||||
// exhaustion.
|
// exhaustion.
|
||||||
Unused << NS_WARN_IF(mSandboxBroker == nullptr);
|
Unused << NS_WARN_IF(mSandboxBroker == nullptr);
|
||||||
MOZ_ASSERT(brokerFd.ref().IsValid());
|
MOZ_ASSERT(attributes.mSandboxBroker().ref().IsValid());
|
||||||
}
|
}
|
||||||
Unused << GetActor()->SendInitLinuxSandbox(brokerFd);
|
|
||||||
}
|
}
|
||||||
#endif // XP_LINUX && MOZ_SANDBOX
|
#endif // XP_LINUX && MOZ_SANDBOX
|
||||||
|
|
||||||
|
Unused << GetActor()->SendInit(attributes);
|
||||||
|
|
||||||
#ifdef MOZ_GECKO_PROFILER
|
#ifdef MOZ_GECKO_PROFILER
|
||||||
Unused << GetActor()->SendInitProfiler(
|
Unused << GetActor()->SendInitProfiler(
|
||||||
ProfilerParent::CreateForProcess(GetActor()->OtherPid()));
|
ProfilerParent::CreateForProcess(GetActor()->OtherPid()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Unused << GetActor()->SendSetOffline(offline);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mListener) {
|
if (mListener) {
|
||||||
mListener->OnProcessLaunchComplete(this, aSucceeded);
|
mListener->OnProcessLaunchComplete(this, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue