Bug 1264811 - Use a const reference and a default constructor to simplify the macOS sandbox code; r?haik
MozReview-Commit-ID: Dtspj7fL9t7
--- a/security/sandbox/mac/Sandbox.h
+++ b/security/sandbox/mac/Sandbox.h
@@ -36,28 +36,18 @@ typedef struct _MacSandboxPluginInfo {
std::string pluginPath;
std::string pluginBinaryPath;
} MacSandboxPluginInfo;
typedef struct _MacSandboxInfo {
_MacSandboxInfo()
: type(MacSandboxType_Default), level(0), hasFilePrivileges(false),
shouldLog(true) {}
- _MacSandboxInfo(const struct _MacSandboxInfo& other)
- : type(other.type), level(other.level),
- hasFilePrivileges(other.hasFilePrivileges),
- hasSandboxedProfile(other.hasSandboxedProfile),
- pluginInfo(other.pluginInfo),
- appPath(other.appPath), appBinaryPath(other.appBinaryPath),
- appDir(other.appDir), appTempDir(other.appTempDir),
- profileDir(other.profileDir), debugWriteDir(other.debugWriteDir),
- testingReadPath1(other.testingReadPath1),
- testingReadPath2(other.testingReadPath2),
- testingReadPath3(other.testingReadPath3),
- testingReadPath4(other.testingReadPath4), shouldLog(other.shouldLog) {}
+ _MacSandboxInfo(const struct _MacSandboxInfo& other) = default;
+
MacSandboxType type;
int32_t level;
bool hasFilePrivileges;
bool hasSandboxedProfile;
MacSandboxPluginInfo pluginInfo;
std::string appPath;
std::string appBinaryPath;
std::string appDir;
@@ -70,13 +60,13 @@ typedef struct _MacSandboxInfo {
std::string testingReadPath3;
std::string testingReadPath4;
bool shouldLog;
} MacSandboxInfo;
namespace mozilla {
-bool StartMacSandbox(MacSandboxInfo aInfo, std::string &aErrorMessage);
+bool StartMacSandbox(MacSandboxInfo const &aInfo, std::string &aErrorMessage);
} // namespace mozilla
#endif // mozilla_Sandbox_h
--- a/security/sandbox/mac/Sandbox.mm
+++ b/security/sandbox/mac/Sandbox.mm
@@ -119,17 +119,17 @@ OSXVersion::GetVersionNumber()
GetSystemVersion(major, minor, bugfix);
mOSXVersion = MAC_OS_X_VERSION_10_0_HEX + (minor << 4) + bugfix;
}
return mOSXVersion;
}
namespace mozilla {
-bool StartMacSandbox(MacSandboxInfo aInfo, std::string &aErrorMessage)
+bool StartMacSandbox(MacSandboxInfo const &aInfo, std::string &aErrorMessage)
{
std::vector<const char *> params;
char *profile = NULL;
bool profile_needs_free = false;
if (aInfo.type == MacSandboxType_Plugin) {
profile = const_cast<char *>(pluginSandboxRules);
params.push_back("SHOULD_LOG");
params.push_back(aInfo.shouldLog ? "TRUE" : "FALSE");