Bug 1873812 - Remove Scoped.h usage in ipc/*. ipc-reviewers r=ipc-reviewers,nika

Differential Revision: https://phabricator.services.mozilla.com/D198118
This commit is contained in:
Kelsey Gilbert
2024-02-06 18:57:44 +00:00
parent 07d589f34b
commit 1456b448b4
5 changed files with 14 additions and 32 deletions

View File

@@ -58,12 +58,17 @@ class CrashReporterHost {
template <typename Toplevel>
bool GenerateMinidumpAndPair(Toplevel* aToplevelProtocol,
const nsACString& aPairName) {
ScopedProcessHandle childHandle;
auto childHandle = base::kInvalidProcessHandle;
const auto cleanup = MakeScopeExit([&]() {
if (childHandle && childHandle != base::kInvalidProcessHandle) {
base::CloseProcessHandle(childHandle);
}
});
#ifdef XP_MACOSX
childHandle = aToplevelProtocol->Process()->GetChildTask();
#else
if (!base::OpenPrivilegedProcessHandle(aToplevelProtocol->OtherPid(),
&childHandle.rwget())) {
&childHandle)) {
NS_WARNING("Failed to open child process handle.");
return false;
}

View File

@@ -47,17 +47,6 @@ using base::ProcessHandle;
using base::ProcessId;
namespace mozilla {
#if defined(XP_WIN)
// Generate RAII classes for LPTSTR and PSECURITY_DESCRIPTOR.
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedLPTStr,
std::remove_pointer_t<LPTSTR>,
::LocalFree)
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(
ScopedPSecurityDescriptor, std::remove_pointer_t<PSECURITY_DESCRIPTOR>,
::LocalFree)
#endif
namespace ipc {
/* static */

View File

@@ -22,7 +22,6 @@
#include "mozilla/Maybe.h"
#include "mozilla/Mutex.h"
#include "mozilla/RefPtr.h"
#include "mozilla/Scoped.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/ipc/MessageLink.h"
@@ -101,20 +100,6 @@ class NeckoParent;
namespace ipc {
// Scoped base::ProcessHandle to ensure base::CloseProcessHandle is called.
struct ScopedProcessHandleTraits {
typedef base::ProcessHandle type;
static type empty() { return base::kInvalidProcessHandle; }
static void release(type aProcessHandle) {
if (aProcessHandle && aProcessHandle != base::kInvalidProcessHandle) {
base::CloseProcessHandle(aProcessHandle);
}
}
};
typedef mozilla::Scoped<ScopedProcessHandleTraits> ScopedProcessHandle;
class ProtocolFdMapping;
class ProtocolCloneContext;

View File

@@ -51,13 +51,14 @@ mozilla::ipc::IPCResult RemoteSandboxBrokerChild::RecvLaunchApp(
// We need to add our parent as a target peer, so that the sandboxed child can
// duplicate handles to it for crash reporting. AddTargetPeer duplicates the
// handle, so we use a ScopedProcessHandle to automatically close ours.
ipc::ScopedProcessHandle parentProcHandle;
if (!base::OpenProcessHandle(OtherPid(), &parentProcHandle.rwget())) {
// handle, so we use UniqueFileHandle to automatically close ours.
UniqueFileHandle parentProcHandle;
if (!base::OpenProcessHandle(OtherPid(),
getter_Transfers(parentProcHandle))) {
*aOutOk = false;
return IPC_OK();
}
mSandboxBroker.AddTargetPeer(parentProcHandle);
mSandboxBroker.AddTargetPeer(parentProcHandle.get());
if (!mSandboxBroker.SetSecurityLevelForGMPlugin(
AbstractSandboxBroker::SandboxLevel(aParams.sandboxLevel()),

View File

@@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "HangDetails.h"
#include "nsIHangDetails.h"
#include "nsPrintfCString.h"
#include "js/Array.h" // JS::NewArrayObject
@@ -12,6 +13,7 @@
#include "mozilla/gfx/GPUParent.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ContentParent.h" // For RemoteTypePrefix
#include "mozilla/FileUtils.h"
#include "mozilla/SchedulerGroup.h"
#include "mozilla/Unused.h"
#include "mozilla/GfxMessageUtils.h" // For ParamTraits<GeckoProcessType>