Bug 1264811 - Use a const reference and a default constructor to simplify the macOS sandbox code; r?haik draft
authorAlex Gaynor <agaynor@mozilla.com>
Fri, 28 Jul 2017 15:00:22 -0400
changeset 617630 578b51c6613611acc5ba9d331200ffd963bffa20
parent 617496 16ffc1d05422a81099ce8b9b59de66dde4c8b2f0
child 639860 6a5910be82e6eaae6afe5afeff5e74fef1f3c89f
push id71100
push userbmo:agaynor@mozilla.com
push dateFri, 28 Jul 2017 19:00:35 +0000
reviewershaik
bugs1264811
milestone56.0a1
Bug 1264811 - Use a const reference and a default constructor to simplify the macOS sandbox code; r?haik MozReview-Commit-ID: Dtspj7fL9t7
security/sandbox/mac/Sandbox.h
security/sandbox/mac/Sandbox.mm
--- 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");