Convert //sandbox to use std::unique_ptr
BUG=554298
Review URL: https://codereview.chromium.org/1849323003
Cr-Commit-Position: refs/heads/master@{#385445}
diff --git a/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc b/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
index c6ba01d..998cd3b 100644
--- a/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
+++ b/components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc
@@ -25,6 +25,8 @@
#include <time.h>
#include <unistd.h>
+#include <memory>
+
#include "base/at_exit.h"
#include "base/bind.h"
#include "base/callback.h"
@@ -607,14 +609,14 @@
TgkillDelegate() {}
~TgkillDelegate() override {}
- scoped_ptr<sandbox::bpf_dsl::Policy> GetSandboxBPFPolicy() override {
+ std::unique_ptr<sandbox::bpf_dsl::Policy> GetSandboxBPFPolicy() override {
// These two values must be obtained when running in the sandboxed process.
// They cannot be set in the constructor and are also not available from
// within |RunTestFunction|.
pid_ = getpid();
tid_ = syscall(__NR_gettid);
- return scoped_ptr<sandbox::bpf_dsl::Policy>(
+ return std::unique_ptr<sandbox::bpf_dsl::Policy>(
new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy());
}
diff --git a/mojo/shell/runner/host/linux_sandbox.h b/mojo/shell/runner/host/linux_sandbox.h
index 9cf5e7d..df81cf4 100644
--- a/mojo/shell/runner/host/linux_sandbox.h
+++ b/mojo/shell/runner/host/linux_sandbox.h
@@ -5,6 +5,8 @@
#ifndef MOJO_SHELL_RUNNER_HOST_LINUX_SANDBOX_H_
#define MOJO_SHELL_RUNNER_HOST_LINUX_SANDBOX_H_
+#include <memory>
+
#include "base/files/scoped_file.h"
#include "base/macros.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
@@ -39,8 +41,8 @@
private:
bool warmed_up_;
base::ScopedFD proc_fd_;
- scoped_ptr<sandbox::syscall_broker::BrokerProcess> broker_;
- scoped_ptr<sandbox::bpf_dsl::Policy> policy_;
+ std::unique_ptr<sandbox::syscall_broker::BrokerProcess> broker_;
+ std::unique_ptr<sandbox::bpf_dsl::Policy> policy_;
DISALLOW_COPY_AND_ASSIGN(LinuxSandbox);
};
diff --git a/sandbox/linux/integration_tests/bpf_dsl_seccomp_unittest.cc b/sandbox/linux/integration_tests/bpf_dsl_seccomp_unittest.cc
index 3b0d6ac46..0a3dadb 100644
--- a/sandbox/linux/integration_tests/bpf_dsl_seccomp_unittest.cc
+++ b/sandbox/linux/integration_tests/bpf_dsl_seccomp_unittest.cc
@@ -27,7 +27,6 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/synchronization/waitable_event.h"
#include "base/sys_info.h"
diff --git a/sandbox/linux/integration_tests/seccomp_broker_process_unittest.cc b/sandbox/linux/integration_tests/seccomp_broker_process_unittest.cc
index c46b808..73dc58c9 100644
--- a/sandbox/linux/integration_tests/seccomp_broker_process_unittest.cc
+++ b/sandbox/linux/integration_tests/seccomp_broker_process_unittest.cc
@@ -8,11 +8,11 @@
#include <sys/types.h>
#include <unistd.h>
+#include <memory>
#include <vector>
#include "base/bind.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "build/build_config.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
@@ -63,7 +63,7 @@
private:
bool initialized_;
- scoped_ptr<class syscall_broker::BrokerProcess> broker_process_;
+ std::unique_ptr<class syscall_broker::BrokerProcess> broker_process_;
DISALLOW_COPY_AND_ASSIGN(InitializedOpenBroker);
};
diff --git a/sandbox/linux/seccomp-bpf/bpf_tester_compatibility_delegate.h b/sandbox/linux/seccomp-bpf/bpf_tester_compatibility_delegate.h
index 00d415c3..a4315ba 100644
--- a/sandbox/linux/seccomp-bpf/bpf_tester_compatibility_delegate.h
+++ b/sandbox/linux/seccomp-bpf/bpf_tester_compatibility_delegate.h
@@ -5,8 +5,9 @@
#ifndef SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTER_COMPATIBILITY_DELEGATE_H_
#define SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTER_COMPATIBILITY_DELEGATE_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.h"
namespace sandbox {
@@ -28,12 +29,12 @@
~BPFTesterCompatibilityDelegate() override {}
- scoped_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override {
+ std::unique_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override {
// The current method is guaranteed to only run in the child process
// running the test. In this process, the current object is guaranteed
// to live forever. So it's ok to pass aux_pointer_for_policy_ to
// the policy, which could in turn pass it to the kernel via Trap().
- return scoped_ptr<bpf_dsl::Policy>(new Policy(&aux_));
+ return std::unique_ptr<bpf_dsl::Policy>(new Policy(&aux_));
}
void RunTestFunction() override {
diff --git a/sandbox/linux/seccomp-bpf/bpf_tests.h b/sandbox/linux/seccomp-bpf/bpf_tests.h
index cc4debd..8b2b12a 100644
--- a/sandbox/linux/seccomp-bpf/bpf_tests.h
+++ b/sandbox/linux/seccomp-bpf/bpf_tests.h
@@ -5,6 +5,8 @@
#ifndef SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__
#define SANDBOX_LINUX_SECCOMP_BPF_BPF_TESTS_H__
+#include <memory>
+
#include "base/logging.h"
#include "base/macros.h"
#include "build/build_config.h"
@@ -104,8 +106,8 @@
: test_function_(test_function) {}
~BPFTesterSimpleDelegate() override {}
- scoped_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override {
- return scoped_ptr<bpf_dsl::Policy>(new PolicyClass());
+ std::unique_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override {
+ return std::unique_ptr<bpf_dsl::Policy>(new PolicyClass());
}
void RunTestFunction() override {
DCHECK(test_function_);
diff --git a/sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc b/sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc
index e300baf..c16cd72 100644
--- a/sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc
+++ b/sandbox/linux/seccomp-bpf/bpf_tests_unittest.cc
@@ -10,9 +10,10 @@
#include <sys/types.h>
#include <unistd.h>
+#include <memory>
+
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/linux/bpf_dsl/policy.h"
@@ -76,7 +77,7 @@
}
{
// Test polymorphism.
- scoped_ptr<BPFTesterDelegate> simple_delegate(
+ std::unique_ptr<BPFTesterDelegate> simple_delegate(
new BPFTesterCompatibilityDelegate<EmptyClassTakingPolicy, FourtyTwo>(
DummyTestFunction));
}
@@ -113,8 +114,8 @@
BasicBPFTesterDelegate() {}
~BasicBPFTesterDelegate() override {}
- scoped_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override {
- return scoped_ptr<bpf_dsl::Policy>(new EnosysPtracePolicy());
+ std::unique_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() override {
+ return std::unique_ptr<bpf_dsl::Policy>(new EnosysPtracePolicy());
}
void RunTestFunction() override {
errno = 0;
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
index b48682b..4d8d436 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
@@ -14,7 +14,6 @@
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/third_party/valgrind/valgrind.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.h b/sandbox/linux/seccomp-bpf/sandbox_bpf.h
index e758e031..1637b26 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.h
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.h
@@ -7,9 +7,10 @@
#include <stdint.h>
+#include <memory>
+
#include "base/files/scoped_file.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/linux/bpf_dsl/codegen.h"
#include "sandbox/sandbox_export.h"
@@ -104,7 +105,7 @@
base::ScopedFD proc_fd_;
bool sandbox_has_started_;
- scoped_ptr<bpf_dsl::Policy> policy_;
+ std::unique_ptr<bpf_dsl::Policy> policy_;
DISALLOW_COPY_AND_ASSIGN(SandboxBPF);
};
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.cc
index c0193f9..7a675db3 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.cc
@@ -6,8 +6,9 @@
#include <fcntl.h>
+#include <memory>
+
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/linux/bpf_dsl/policy.h"
#include "sandbox/linux/seccomp-bpf/die.h"
#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
@@ -28,7 +29,7 @@
DCHECK(bpf_tester_delegate_);
sandbox::Die::EnableSimpleExit();
- scoped_ptr<bpf_dsl::Policy> policy =
+ std::unique_ptr<bpf_dsl::Policy> policy =
bpf_tester_delegate_->GetSandboxBPFPolicy();
if (sandbox::SandboxBPF::SupportsSeccompSandbox(
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.h b/sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.h
index fef6240d..1cf1c2f 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.h
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.h
@@ -5,8 +5,9 @@
#ifndef SANDBOX_LINUX_SECCOMP_BPF_SANDBOX_BPF_TEST_RUNNER_H_
#define SANDBOX_LINUX_SECCOMP_BPF_SANDBOX_BPF_TEST_RUNNER_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/linux/tests/sandbox_test_runner.h"
namespace sandbox {
@@ -26,7 +27,7 @@
// This will instanciate a policy suitable for the test we want to run. It is
// guaranteed to only be called from the child process that will run the
// test.
- virtual scoped_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() = 0;
+ virtual std::unique_ptr<bpf_dsl::Policy> GetSandboxBPFPolicy() = 0;
// This will be called from a child process with the BPF sandbox turned on.
virtual void RunTestFunction() = 0;
@@ -43,7 +44,7 @@
class SandboxBPFTestRunner : public SandboxTestRunner {
public:
// This constructor takes ownership of the |bpf_tester_delegate| object.
- // (It doesn't take a scoped_ptr since they make polymorphism verbose).
+ // (It doesn't take a std::unique_ptr since they make polymorphism verbose).
explicit SandboxBPFTestRunner(BPFTesterDelegate* bpf_tester_delegate);
~SandboxBPFTestRunner() override;
@@ -52,7 +53,7 @@
bool ShouldCheckForLeaks() const override;
private:
- scoped_ptr<BPFTesterDelegate> bpf_tester_delegate_;
+ std::unique_ptr<BPFTesterDelegate> bpf_tester_delegate_;
DISALLOW_COPY_AND_ASSIGN(SandboxBPFTestRunner);
};
diff --git a/sandbox/linux/services/credentials.h b/sandbox/linux/services/credentials.h
index 095d636..b89a6aa 100644
--- a/sandbox/linux/services/credentials.h
+++ b/sandbox/linux/services/credentials.h
@@ -16,7 +16,6 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/linux/system_headers/capability.h"
#include "sandbox/sandbox_export.h"
diff --git a/sandbox/linux/services/credentials_unittest.cc b/sandbox/linux/services/credentials_unittest.cc
index d666a0c..b95ba0ba 100644
--- a/sandbox/linux/services/credentials_unittest.cc
+++ b/sandbox/linux/services/credentials_unittest.cc
@@ -15,13 +15,13 @@
#include <sys/types.h>
#include <unistd.h>
+#include <memory>
#include <vector>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/linux/services/proc_util.h"
#include "sandbox/linux/services/syscall_wrappers.h"
#include "sandbox/linux/system_headers/capability.h"
@@ -40,7 +40,7 @@
};
// Wrapper to manage libcap2's cap_t type.
-typedef scoped_ptr<typeof(*((cap_t)0)), CapFreeDeleter> ScopedCap;
+typedef std::unique_ptr<typeof(*((cap_t)0)), CapFreeDeleter> ScopedCap;
bool WorkingDirectoryIsRoot() {
char current_dir[PATH_MAX];
diff --git a/sandbox/linux/services/namespace_sandbox_unittest.cc b/sandbox/linux/services/namespace_sandbox_unittest.cc
index 43e0ae5..c1acca6 100644
--- a/sandbox/linux/services/namespace_sandbox_unittest.cc
+++ b/sandbox/linux/services/namespace_sandbox_unittest.cc
@@ -16,7 +16,6 @@
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/process/launch.h"
#include "base/process/process.h"
#include "base/test/multiprocess_test.h"
diff --git a/sandbox/linux/services/proc_util.cc b/sandbox/linux/services/proc_util.cc
index 247c29c..b6d58de5 100644
--- a/sandbox/linux/services/proc_util.cc
+++ b/sandbox/linux/services/proc_util.cc
@@ -11,8 +11,9 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include <memory>
+
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/string_number_conversions.h"
@@ -26,7 +27,7 @@
}
};
-typedef scoped_ptr<DIR, DIRCloser> ScopedDIR;
+typedef std::unique_ptr<DIR, DIRCloser> ScopedDIR;
base::ScopedFD OpenDirectory(const char* path) {
DCHECK(path);
diff --git a/sandbox/linux/services/thread_helpers_unittests.cc b/sandbox/linux/services/thread_helpers_unittests.cc
index 6dcae0f..fe1080b 100644
--- a/sandbox/linux/services/thread_helpers_unittests.cc
+++ b/sandbox/linux/services/thread_helpers_unittests.cc
@@ -12,7 +12,6 @@
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/process_metrics.h"
#include "base/threading/platform_thread.h"
diff --git a/sandbox/linux/suid/client/setuid_sandbox_client.h b/sandbox/linux/suid/client/setuid_sandbox_client.h
index 026894fc..d1cff42 100644
--- a/sandbox/linux/suid/client/setuid_sandbox_client.h
+++ b/sandbox/linux/suid/client/setuid_sandbox_client.h
@@ -5,9 +5,10 @@
#ifndef SANDBOX_LINUX_SUID_SETUID_SANDBOX_CLIENT_H_
#define SANDBOX_LINUX_SUID_SETUID_SANDBOX_CLIENT_H_
+#include <memory>
+
#include "base/environment.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/sandbox_export.h"
namespace sandbox {
@@ -60,7 +61,7 @@
explicit SetuidSandboxClient(base::Environment* env);
// Holds the environment. Will never be NULL.
- scoped_ptr<base::Environment> env_;
+ std::unique_ptr<base::Environment> env_;
bool sandboxed_;
DISALLOW_COPY_AND_ASSIGN(SetuidSandboxClient);
diff --git a/sandbox/linux/suid/client/setuid_sandbox_client_unittest.cc b/sandbox/linux/suid/client/setuid_sandbox_client_unittest.cc
index 2acd8fb..a5f96bef 100644
--- a/sandbox/linux/suid/client/setuid_sandbox_client_unittest.cc
+++ b/sandbox/linux/suid/client/setuid_sandbox_client_unittest.cc
@@ -4,8 +4,9 @@
#include "sandbox/linux/suid/client/setuid_sandbox_client.h"
+#include <memory>
+
#include "base/environment.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "sandbox/linux/suid/common/sandbox.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -13,11 +14,11 @@
namespace sandbox {
TEST(SetuidSandboxClient, SandboxedClientAPI) {
- scoped_ptr<base::Environment> env(base::Environment::Create());
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
EXPECT_TRUE(env != NULL);
- scoped_ptr<SetuidSandboxClient>
- sandbox_client(SetuidSandboxClient::Create());
+ std::unique_ptr<SetuidSandboxClient> sandbox_client(
+ SetuidSandboxClient::Create());
EXPECT_TRUE(sandbox_client != NULL);
// Set-up a fake environment as if we went through the setuid sandbox.
diff --git a/sandbox/linux/suid/client/setuid_sandbox_host.cc b/sandbox/linux/suid/client/setuid_sandbox_host.cc
index 24ef4b39..278f1d2 100644
--- a/sandbox/linux/suid/client/setuid_sandbox_host.cc
+++ b/sandbox/linux/suid/client/setuid_sandbox_host.cc
@@ -10,6 +10,7 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <memory>
#include <string>
#include <utility>
@@ -20,7 +21,6 @@
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/launch.h"
@@ -79,7 +79,8 @@
for (unsigned i = 0; kSUIDUnsafeEnvironmentVariables[i]; ++i) {
const char* env_var = kSUIDUnsafeEnvironmentVariables[i];
// Get the saved environment variable corresponding to envvar.
- scoped_ptr<std::string> saved_env_var(CreateSavedVariableName(env_var));
+ std::unique_ptr<std::string> saved_env_var(
+ CreateSavedVariableName(env_var));
if (saved_env_var == NULL)
continue;
diff --git a/sandbox/linux/suid/client/setuid_sandbox_host.h b/sandbox/linux/suid/client/setuid_sandbox_host.h
index 6788892..c69c2c0c 100644
--- a/sandbox/linux/suid/client/setuid_sandbox_host.h
+++ b/sandbox/linux/suid/client/setuid_sandbox_host.h
@@ -5,10 +5,11 @@
#ifndef SANDBOX_LINUX_SUID_SETUID_SANDBOX_HOST_H_
#define SANDBOX_LINUX_SUID_SETUID_SANDBOX_HOST_H_
+#include <memory>
+
#include "base/files/file_path.h"
#include "base/files/scoped_file.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/process/launch.h"
#include "sandbox/sandbox_export.h"
@@ -60,7 +61,7 @@
explicit SetuidSandboxHost(base::Environment* env);
// Holds the environment. Will never be NULL.
- scoped_ptr<base::Environment> env_;
+ std::unique_ptr<base::Environment> env_;
DISALLOW_COPY_AND_ASSIGN(SetuidSandboxHost);
};
diff --git a/sandbox/linux/suid/client/setuid_sandbox_host_unittest.cc b/sandbox/linux/suid/client/setuid_sandbox_host_unittest.cc
index 8415abb..efbd931 100644
--- a/sandbox/linux/suid/client/setuid_sandbox_host_unittest.cc
+++ b/sandbox/linux/suid/client/setuid_sandbox_host_unittest.cc
@@ -4,11 +4,11 @@
#include "sandbox/linux/suid/client/setuid_sandbox_host.h"
+#include <memory>
#include <string>
#include "base/environment.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "sandbox/linux/suid/common/sandbox.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -17,7 +17,7 @@
TEST(SetuidSandboxHost, SetupLaunchEnvironment) {
const char kTestValue[] = "This is a test";
- scoped_ptr<base::Environment> env(base::Environment::Create());
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
EXPECT_TRUE(env != NULL);
std::string saved_ld_preload;
@@ -28,7 +28,7 @@
EXPECT_TRUE(env->SetVar("LD_PRELOAD", kTestValue));
EXPECT_TRUE(env->UnSetVar("LD_ORIGIN_PATH"));
- scoped_ptr<SetuidSandboxHost> sandbox_host(SetuidSandboxHost::Create());
+ std::unique_ptr<SetuidSandboxHost> sandbox_host(SetuidSandboxHost::Create());
EXPECT_TRUE(sandbox_host != NULL);
// Make sure the environment is clean.
@@ -64,7 +64,7 @@
// This test doesn't accomplish much, but will make sure that analysis tools
// will run this codepath.
TEST(SetuidSandboxHost, GetSandboxBinaryPath) {
- scoped_ptr<SetuidSandboxHost> setuid_sandbox_host(
+ std::unique_ptr<SetuidSandboxHost> setuid_sandbox_host(
SetuidSandboxHost::Create());
ignore_result(setuid_sandbox_host->GetSandboxBinaryPath());
}
diff --git a/sandbox/linux/syscall_broker/broker_process.cc b/sandbox/linux/syscall_broker/broker_process.cc
index 5ab8c6c..30713ce 100644
--- a/sandbox/linux/syscall_broker/broker_process.cc
+++ b/sandbox/linux/syscall_broker/broker_process.cc
@@ -19,7 +19,6 @@
#include "base/callback.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/process_metrics.h"
#include "build/build_config.h"
diff --git a/sandbox/linux/syscall_broker/broker_process.h b/sandbox/linux/syscall_broker/broker_process.h
index 8a512a0c..3c0c809 100644
--- a/sandbox/linux/syscall_broker/broker_process.h
+++ b/sandbox/linux/syscall_broker/broker_process.h
@@ -5,12 +5,12 @@
#ifndef SANDBOX_LINUX_SERVICES_BROKER_PROCESS_H_
#define SANDBOX_LINUX_SERVICES_BROKER_PROCESS_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/callback_forward.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/pickle.h"
#include "base/process/process.h"
#include "sandbox/linux/syscall_broker/broker_policy.h"
@@ -82,7 +82,7 @@
const bool quiet_failures_for_tests_;
pid_t broker_pid_; // The PID of the broker (child).
syscall_broker::BrokerPolicy policy_; // The sandboxing policy.
- scoped_ptr<syscall_broker::BrokerClient> broker_client_;
+ std::unique_ptr<syscall_broker::BrokerClient> broker_client_;
DISALLOW_COPY_AND_ASSIGN(BrokerProcess);
};
diff --git a/sandbox/linux/syscall_broker/broker_process_unittest.cc b/sandbox/linux/syscall_broker/broker_process_unittest.cc
index c760084e..229764a 100644
--- a/sandbox/linux/syscall_broker/broker_process_unittest.cc
+++ b/sandbox/linux/syscall_broker/broker_process_unittest.cc
@@ -15,6 +15,7 @@
#include <unistd.h>
#include <algorithm>
+#include <memory>
#include <string>
#include <vector>
@@ -23,7 +24,6 @@
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "base/posix/unix_domain_socket_linux.h"
#include "sandbox/linux/syscall_broker/broker_client.h"
@@ -58,7 +58,8 @@
std::vector<BrokerFilePermission> permissions;
permissions.push_back(BrokerFilePermission::ReadOnly("/proc/cpuinfo"));
- scoped_ptr<BrokerProcess> open_broker(new BrokerProcess(EPERM, permissions));
+ std::unique_ptr<BrokerProcess> open_broker(
+ new BrokerProcess(EPERM, permissions));
ASSERT_TRUE(open_broker->Init(base::Bind(&NoOpCallback)));
ASSERT_TRUE(TestUtils::CurrentProcessHasChildren());
@@ -251,7 +252,7 @@
std::vector<BrokerFilePermission> permissions;
permissions.push_back(BrokerFilePermission::ReadOnlyRecursive("/proc/"));
- scoped_ptr<BrokerProcess> open_broker(
+ std::unique_ptr<BrokerProcess> open_broker(
new BrokerProcess(EPERM, permissions, fast_check_in_client));
ASSERT_TRUE(open_broker->Init(base::Bind(&NoOpCallback)));
// Open cpuinfo via the broker.
@@ -310,7 +311,7 @@
else
permissions.push_back(BrokerFilePermission::ReadOnly(kFileCpuInfo));
- scoped_ptr<BrokerProcess> open_broker(
+ std::unique_ptr<BrokerProcess> open_broker(
new BrokerProcess(EPERM, permissions, fast_check_in_client));
ASSERT_TRUE(open_broker->Init(base::Bind(&NoOpCallback)));
diff --git a/sandbox/mac/bootstrap_sandbox.cc b/sandbox/mac/bootstrap_sandbox.cc
index dee7903c..4b3a1c6c 100644
--- a/sandbox/mac/bootstrap_sandbox.cc
+++ b/sandbox/mac/bootstrap_sandbox.cc
@@ -12,6 +12,7 @@
#include "base/mac/foundation_util.h"
#include "base/mac/mach_logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "sandbox/mac/launchd_interception_server.h"
@@ -55,9 +56,9 @@
} // namespace
// static
-scoped_ptr<BootstrapSandbox> BootstrapSandbox::Create() {
- scoped_ptr<BootstrapSandbox> null; // Used for early returns.
- scoped_ptr<BootstrapSandbox> sandbox(new BootstrapSandbox());
+std::unique_ptr<BootstrapSandbox> BootstrapSandbox::Create() {
+ std::unique_ptr<BootstrapSandbox> null; // Used for early returns.
+ std::unique_ptr<BootstrapSandbox> sandbox(new BootstrapSandbox());
sandbox->launchd_server_.reset(new LaunchdInterceptionServer(sandbox.get()));
// Check in with launchd to get the receive right for the server that is
@@ -143,7 +144,8 @@
policies_.insert(std::make_pair(sandbox_policy_id, policy));
}
-scoped_ptr<PreExecDelegate> BootstrapSandbox::NewClient(int sandbox_policy_id) {
+std::unique_ptr<PreExecDelegate> BootstrapSandbox::NewClient(
+ int sandbox_policy_id) {
base::AutoLock lock(lock_);
DCHECK(policies_.find(sandbox_policy_id) != policies_.end());
@@ -156,7 +158,7 @@
}
awaiting_processes_[token] = sandbox_policy_id;
- return make_scoped_ptr(new PreExecDelegate(server_bootstrap_name_, token));
+ return base::WrapUnique(new PreExecDelegate(server_bootstrap_name_, token));
}
void BootstrapSandbox::RevokeToken(uint64_t token) {
diff --git a/sandbox/mac/bootstrap_sandbox.h b/sandbox/mac/bootstrap_sandbox.h
index 2ae4513..793649ea 100644
--- a/sandbox/mac/bootstrap_sandbox.h
+++ b/sandbox/mac/bootstrap_sandbox.h
@@ -9,11 +9,11 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include <string>
#include "base/mac/dispatch_source_mach.h"
#include "base/mac/scoped_mach_port.h"
-#include "base/memory/scoped_ptr.h"
#include "base/process/process_handle.h"
#include "base/synchronization/lock.h"
#include "sandbox/mac/policy.h"
@@ -48,7 +48,7 @@
class SANDBOX_EXPORT BootstrapSandbox {
public:
// Creates a new sandbox manager. Returns NULL on failure.
- static scoped_ptr<BootstrapSandbox> Create();
+ static std::unique_ptr<BootstrapSandbox> Create();
// For use in newly created child processes. Checks in with the bootstrap
// sandbox manager running in the parent process. |sandbox_server_port| is
@@ -69,7 +69,7 @@
// Creates a new PreExecDelegate to pass to base::LaunchOptions. This will
// enforce the policy with |sandbox_policy_id| on the new process.
- scoped_ptr<PreExecDelegate> NewClient(int sandbox_policy_id);
+ std::unique_ptr<PreExecDelegate> NewClient(int sandbox_policy_id);
// If a client did not launch properly, the sandbox provided to the
// PreExecDelegate should be invalidated using this method.
@@ -118,12 +118,12 @@
// A Mach IPC message server that is used to intercept and filter bootstrap
// requests.
- scoped_ptr<LaunchdInterceptionServer> launchd_server_;
+ std::unique_ptr<LaunchdInterceptionServer> launchd_server_;
// The port and dispatch source for receiving client check in messages sent
// via ClientCheckIn().
base::mac::ScopedMachReceiveRight check_in_port_;
- scoped_ptr<base::DispatchSourceMach> check_in_server_;
+ std::unique_ptr<base::DispatchSourceMach> check_in_server_;
};
} // namespace sandbox
diff --git a/sandbox/mac/bootstrap_sandbox_unittest.mm b/sandbox/mac/bootstrap_sandbox_unittest.mm
index e4c13e5..f81cd114 100644
--- a/sandbox/mac/bootstrap_sandbox_unittest.mm
+++ b/sandbox/mac/bootstrap_sandbox_unittest.mm
@@ -98,7 +98,7 @@
void RunChildWithPolicy(int policy_id,
const char* child_name,
base::ProcessHandle* out_pid) {
- scoped_ptr<PreExecDelegate> pre_exec_delegate(
+ std::unique_ptr<PreExecDelegate> pre_exec_delegate(
sandbox_->NewClient(policy_id));
base::LaunchOptions options;
@@ -114,7 +114,7 @@
}
protected:
- scoped_ptr<BootstrapSandbox> sandbox_;
+ std::unique_ptr<BootstrapSandbox> sandbox_;
};
const char kNotificationTestMain[] = "PostNotification";
@@ -434,7 +434,7 @@
sandbox_->RegisterSandboxPolicy(kTestPolicyId, policy);
// Launch the child.
- scoped_ptr<PreExecDelegate> pre_exec_delegate(
+ std::unique_ptr<PreExecDelegate> pre_exec_delegate(
sandbox_->NewClient(kTestPolicyId));
base::LaunchOptions options;
options.pre_exec_delegate = pre_exec_delegate.get();
diff --git a/sandbox/mac/launchd_interception_server.h b/sandbox/mac/launchd_interception_server.h
index 0375ca2..9ed38f1 100644
--- a/sandbox/mac/launchd_interception_server.h
+++ b/sandbox/mac/launchd_interception_server.h
@@ -5,10 +5,11 @@
#ifndef SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_
#define SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_
+#include <memory>
+
#include <dispatch/dispatch.h>
#include "base/mac/scoped_mach_port.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/mac/message_server.h"
namespace sandbox {
@@ -54,7 +55,7 @@
const BootstrapSandbox* sandbox_;
// The Mach IPC server.
- scoped_ptr<MessageServer> message_server_;
+ std::unique_ptr<MessageServer> message_server_;
// Whether or not the system is using an XPC-based launchd.
bool xpc_launchd_;
@@ -68,7 +69,7 @@
// The compatibility shim that handles differences in message header IDs and
// request/reply structures between different OS X versions.
- scoped_ptr<OSCompatibility> compat_shim_;
+ std::unique_ptr<OSCompatibility> compat_shim_;
};
} // namespace sandbox
diff --git a/sandbox/mac/mach_message_server.h b/sandbox/mac/mach_message_server.h
index 515d565..ace30ec 100644
--- a/sandbox/mac/mach_message_server.h
+++ b/sandbox/mac/mach_message_server.h
@@ -8,10 +8,11 @@
#include <mach/mach.h>
#include <stddef.h>
+#include <memory>
+
#include "base/mac/dispatch_source_mach.h"
#include "base/mac/scoped_mach_port.h"
#include "base/mac/scoped_mach_vm.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/mac/message_server.h"
namespace sandbox {
@@ -63,7 +64,7 @@
base::mac::ScopedMachVM reply_buffer_;
// MACH_RECV dispatch source that handles the |server_port_|.
- scoped_ptr<base::DispatchSourceMach> dispatch_source_;
+ std::unique_ptr<base::DispatchSourceMach> dispatch_source_;
// Whether or not ForwardMessage() was called during ReceiveMessage().
bool did_forward_message_;
diff --git a/sandbox/mac/os_compatibility.cc b/sandbox/mac/os_compatibility.cc
index 1ec0e3a..538efef 100644
--- a/sandbox/mac/os_compatibility.cc
+++ b/sandbox/mac/os_compatibility.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/mac/mac_util.h"
+#include "base/memory/ptr_util.h"
#include "sandbox/mac/xpc.h"
namespace sandbox {
@@ -179,11 +180,11 @@
} // namespace
// static
-scoped_ptr<OSCompatibility> OSCompatibility::CreateForPlatform() {
+std::unique_ptr<OSCompatibility> OSCompatibility::CreateForPlatform() {
if (base::mac::IsOSLionOrLater() && base::mac::IsOSMavericksOrEarlier())
- return make_scoped_ptr(new OSCompatibility_10_7());
+ return base::WrapUnique(new OSCompatibility_10_7());
else
- return make_scoped_ptr(new OSCompatibility_10_10());
+ return base::WrapUnique(new OSCompatibility_10_10());
}
OSCompatibility::~OSCompatibility() {}
diff --git a/sandbox/mac/os_compatibility.h b/sandbox/mac/os_compatibility.h
index 4f18c34..c341888 100644
--- a/sandbox/mac/os_compatibility.h
+++ b/sandbox/mac/os_compatibility.h
@@ -15,9 +15,9 @@
#include <mach/mach.h>
#include <stdint.h>
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "sandbox/mac/message_server.h"
namespace sandbox {
@@ -25,7 +25,7 @@
class OSCompatibility {
public:
// Creates an OSCompatibility instance for the current OS X version.
- static scoped_ptr<OSCompatibility> CreateForPlatform();
+ static std::unique_ptr<OSCompatibility> CreateForPlatform();
virtual ~OSCompatibility();
diff --git a/sandbox/mac/xpc_message_server.h b/sandbox/mac/xpc_message_server.h
index c509bab..9342ef06 100644
--- a/sandbox/mac/xpc_message_server.h
+++ b/sandbox/mac/xpc_message_server.h
@@ -7,10 +7,11 @@
#include <AvailabilityMacros.h>
+#include <memory>
+
#include "base/mac/dispatch_source_mach.h"
#include "base/mac/scoped_mach_port.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/mac/message_server.h"
#include "sandbox/mac/xpc.h"
#include "sandbox/sandbox_export.h"
@@ -51,7 +52,7 @@
base::mac::ScopedMachReceiveRight server_port_;
// MACH_RECV dispatch source that handles the |server_port_|.
- scoped_ptr<base::DispatchSourceMach> dispatch_source_;
+ std::unique_ptr<base::DispatchSourceMach> dispatch_source_;
// The reply message, if one has been created.
xpc_object_t reply_message_;
diff --git a/sandbox/win/src/acl.cc b/sandbox/win/src/acl.cc
index f5de098..539c180 100644
--- a/sandbox/win/src/acl.cc
+++ b/sandbox/win/src/acl.cc
@@ -14,7 +14,7 @@
bool GetDefaultDacl(
HANDLE token,
- scoped_ptr<TOKEN_DEFAULT_DACL, base::FreeDeleter>* default_dacl) {
+ std::unique_ptr<TOKEN_DEFAULT_DACL, base::FreeDeleter>* default_dacl) {
if (token == NULL)
return false;
@@ -64,7 +64,7 @@
if (token == NULL)
return false;
- scoped_ptr<TOKEN_DEFAULT_DACL, base::FreeDeleter> default_dacl;
+ std::unique_ptr<TOKEN_DEFAULT_DACL, base::FreeDeleter> default_dacl;
if (!GetDefaultDacl(token, &default_dacl))
return false;
@@ -86,7 +86,7 @@
DWORD size = sizeof(TOKEN_GROUPS) + SECURITY_MAX_SID_SIZE;
TOKEN_GROUPS* logon_sid = reinterpret_cast<TOKEN_GROUPS*>(malloc(size));
- scoped_ptr<TOKEN_GROUPS, base::FreeDeleter> logon_sid_ptr(logon_sid);
+ std::unique_ptr<TOKEN_GROUPS, base::FreeDeleter> logon_sid_ptr(logon_sid);
if (!::GetTokenInformation(token, TokenLogonSid, logon_sid, size, &size))
return false;
@@ -103,7 +103,7 @@
DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE;
TOKEN_USER* token_user = reinterpret_cast<TOKEN_USER*>(malloc(size));
- scoped_ptr<TOKEN_USER, base::FreeDeleter> token_user_ptr(token_user);
+ std::unique_ptr<TOKEN_USER, base::FreeDeleter> token_user_ptr(token_user);
if (!::GetTokenInformation(token, TokenUser, token_user, size, &size))
return false;
diff --git a/sandbox/win/src/acl.h b/sandbox/win/src/acl.h
index 0749367..7104155 100644
--- a/sandbox/win/src/acl.h
+++ b/sandbox/win/src/acl.h
@@ -8,8 +8,9 @@
#include <AccCtrl.h>
#include <windows.h>
+#include <memory>
+
#include "base/memory/free_deleter.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/win/src/sid.h"
namespace sandbox {
@@ -17,7 +18,7 @@
// Returns the default dacl from the token passed in.
bool GetDefaultDacl(
HANDLE token,
- scoped_ptr<TOKEN_DEFAULT_DACL, base::FreeDeleter>* default_dacl);
+ std::unique_ptr<TOKEN_DEFAULT_DACL, base::FreeDeleter>* default_dacl);
// Appends an ACE represented by |sid|, |access_mode|, and |access| to
// |old_dacl|. If the function succeeds, new_dacl contains the new dacl and
diff --git a/sandbox/win/src/address_sanitizer_test.cc b/sandbox/win/src/address_sanitizer_test.cc
index db39d6b9..d7e5e46 100644
--- a/sandbox/win/src/address_sanitizer_test.cc
+++ b/sandbox/win/src/address_sanitizer_test.cc
@@ -4,6 +4,8 @@
#include <stdio.h>
+#include <memory>
+
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -32,7 +34,7 @@
}
protected:
- scoped_ptr<base::Environment> env_;
+ std::unique_ptr<base::Environment> env_;
bool had_asan_options_;
std::string old_asan_options_;
};
diff --git a/sandbox/win/src/app_container.cc b/sandbox/win/src/app_container.cc
index da8fa88..78d949c 100644
--- a/sandbox/win/src/app_container.cc
+++ b/sandbox/win/src/app_container.cc
@@ -9,7 +9,6 @@
#include <vector>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/win/startup_information.h"
#include "sandbox/win/src/internal_types.h"
diff --git a/sandbox/win/src/app_container.h b/sandbox/win/src/app_container.h
index fe2b189..e61cba6 100644
--- a/sandbox/win/src/app_container.h
+++ b/sandbox/win/src/app_container.h
@@ -10,7 +10,6 @@
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "sandbox/win/src/sandbox_types.h"
diff --git a/sandbox/win/src/app_container_unittest.cc b/sandbox/win/src/app_container_unittest.cc
index 4bce16a..5aa8b5d 100644
--- a/sandbox/win/src/app_container_unittest.cc
+++ b/sandbox/win/src/app_container_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "base/win/windows_version.h"
#include "sandbox/win/src/app_container.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -36,7 +38,8 @@
if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8)
return;
- scoped_ptr<AppContainerAttributes> attributes(new AppContainerAttributes);
+ std::unique_ptr<AppContainerAttributes> attributes(
+ new AppContainerAttributes);
std::vector<base::string16> capabilities;
EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER,
attributes->SetAppContainer(L"S-1-foo", capabilities));
diff --git a/sandbox/win/src/broker_services.cc b/sandbox/win/src/broker_services.cc
index 26b2561..838d49468 100644
--- a/sandbox/win/src/broker_services.cc
+++ b/sandbox/win/src/broker_services.cc
@@ -6,11 +6,12 @@
#include <AclAPI.h>
#include <stddef.h>
+
+#include <memory>
#include <utility>
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "base/threading/platform_thread.h"
#include "base/win/scoped_handle.h"
@@ -474,7 +475,8 @@
// the job object generates notifications using the completion port.
policy_base->AddRef();
if (job.IsValid()) {
- scoped_ptr<JobTracker> tracker(new JobTracker(std::move(job), policy_base));
+ std::unique_ptr<JobTracker> tracker(
+ new JobTracker(std::move(job), policy_base));
// There is no obvious recovery after failure here. Previous version with
// SpawnCleanup() caused deletion of TargetProcess twice. crbug.com/480639
@@ -524,8 +526,8 @@
}
ResultCode BrokerServicesBase::AddTargetPeer(HANDLE peer_process) {
- scoped_ptr<PeerTracker> peer(new PeerTracker(::GetProcessId(peer_process),
- job_port_.Get()));
+ std::unique_ptr<PeerTracker> peer(
+ new PeerTracker(::GetProcessId(peer_process), job_port_.Get()));
if (!peer->id)
return SBOX_ERROR_GENERIC;
diff --git a/sandbox/win/src/handle_closer.cc b/sandbox/win/src/handle_closer.cc
index 962e441..038cae98 100644
--- a/sandbox/win/src/handle_closer.cc
+++ b/sandbox/win/src/handle_closer.cc
@@ -6,9 +6,10 @@
#include <stddef.h>
+#include <memory>
+
#include "base/logging.h"
#include "base/memory/free_deleter.h"
-#include "base/memory/scoped_ptr.h"
#include "base/win/windows_version.h"
#include "sandbox/win/src/interceptors.h"
#include "sandbox/win/src/internal_types.h"
@@ -96,7 +97,7 @@
return true;
size_t bytes_needed = GetBufferSize();
- scoped_ptr<size_t[]> local_buffer(
+ std::unique_ptr<size_t[]> local_buffer(
new size_t[bytes_needed / sizeof(size_t)]);
if (!SetupHandleList(local_buffer.get(), bytes_needed))
@@ -175,7 +176,7 @@
ResolveNTFunctionPtr("NtQueryObject", &QueryObject);
ULONG size = MAX_PATH;
- scoped_ptr<UNICODE_STRING, base::FreeDeleter> name;
+ std::unique_ptr<UNICODE_STRING, base::FreeDeleter> name;
NTSTATUS result;
do {
diff --git a/sandbox/win/src/interception.cc b/sandbox/win/src/interception.cc
index 0243c24..feb5d896 100644
--- a/sandbox/win/src/interception.cc
+++ b/sandbox/win/src/interception.cc
@@ -7,12 +7,12 @@
#include <stddef.h>
+#include <memory>
#include <set>
#include "sandbox/win/src/interception.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/win/pe_image.h"
#include "base/win/windows_version.h"
@@ -129,7 +129,7 @@
return true; // Nothing to do here
size_t buffer_bytes = GetBufferSize();
- scoped_ptr<char[]> local_buffer(new char[buffer_bytes]);
+ std::unique_ptr<char[]> local_buffer(new char[buffer_bytes]);
if (!SetupConfigBuffer(local_buffer.get(), buffer_bytes))
return false;
diff --git a/sandbox/win/src/interception_unittest.cc b/sandbox/win/src/interception_unittest.cc
index 7b7932af..a34f574 100644
--- a/sandbox/win/src/interception_unittest.cc
+++ b/sandbox/win/src/interception_unittest.cc
@@ -10,10 +10,10 @@
#include <stddef.h>
#include <algorithm>
+#include <memory>
#include <set>
#include "base/bits.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/win/src/interception.h"
#include "sandbox/win/src/interception_internal.h"
#include "sandbox/win/src/interceptors.h"
@@ -183,7 +183,7 @@
ASSERT_EQ(18u, interceptions.interceptions_.size());
size_t buffer_size = interceptions.GetBufferSize();
- scoped_ptr<BYTE[]> local_buffer(new BYTE[buffer_size]);
+ std::unique_ptr<BYTE[]> local_buffer(new BYTE[buffer_size]);
ASSERT_TRUE(interceptions.SetupConfigBuffer(local_buffer.get(),
buffer_size));
@@ -236,7 +236,7 @@
ASSERT_EQ(5u, interceptions.interceptions_.size());
size_t buffer_size = interceptions.GetBufferSize();
- scoped_ptr<BYTE[]> local_buffer(new BYTE[buffer_size]);
+ std::unique_ptr<BYTE[]> local_buffer(new BYTE[buffer_size]);
ASSERT_TRUE(interceptions.SetupConfigBuffer(local_buffer.get(),
buffer_size));
diff --git a/sandbox/win/src/process_mitigations_test.cc b/sandbox/win/src/process_mitigations_test.cc
index 783cc68e..cac31fa 100644
--- a/sandbox/win/src/process_mitigations_test.cc
+++ b/sandbox/win/src/process_mitigations_test.cc
@@ -4,7 +4,6 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/strings/stringprintf.h"
diff --git a/sandbox/win/src/process_policy_test.cc b/sandbox/win/src/process_policy_test.cc
index 5876781..2794595 100644
--- a/sandbox/win/src/process_policy_test.cc
+++ b/sandbox/win/src/process_policy_test.cc
@@ -6,7 +6,6 @@
#include <string>
#include "base/memory/free_deleter.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/sys_string_conversions.h"
#include "base/win/scoped_handle.h"
@@ -31,7 +30,7 @@
if (!exe.empty())
exe_name = exe.c_str();
- scoped_ptr<wchar_t, base::FreeDeleter> writable_command(
+ std::unique_ptr<wchar_t, base::FreeDeleter> writable_command(
_wcsdup(command.c_str()));
// Create the process with the unicode version of the API.
diff --git a/sandbox/win/src/process_thread_policy.cc b/sandbox/win/src/process_thread_policy.cc
index 514e7d6..40b2453 100644
--- a/sandbox/win/src/process_thread_policy.cc
+++ b/sandbox/win/src/process_thread_policy.cc
@@ -6,10 +6,10 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/memory/free_deleter.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/win/src/ipc_tags.h"
#include "sandbox/win/src/nt_internals.h"
#include "sandbox/win/src/policy_engine_opcodes.h"
@@ -79,7 +79,7 @@
bool ProcessPolicy::GenerateRules(const wchar_t* name,
TargetPolicy::Semantics semantics,
LowLevelPolicy* policy) {
- scoped_ptr<PolicyRule> process;
+ std::unique_ptr<PolicyRule> process;
switch (semantics) {
case TargetPolicy::PROCESS_MIN_EXEC: {
process.reset(new PolicyRule(GIVE_READONLY));
@@ -226,8 +226,8 @@
STARTUPINFO startup_info = {0};
startup_info.cb = sizeof(startup_info);
- scoped_ptr<wchar_t, base::FreeDeleter>
- cmd_line(_wcsdup(command_line.c_str()));
+ std::unique_ptr<wchar_t, base::FreeDeleter> cmd_line(
+ _wcsdup(command_line.c_str()));
BOOL should_give_full_access = (GIVE_ALLACCESS == eval_result);
if (!CreateProcessExWHelper(client_info.process, should_give_full_access,
diff --git a/sandbox/win/src/restricted_token.cc b/sandbox/win/src/restricted_token.cc
index ea84d86..b696a24b 100644
--- a/sandbox/win/src/restricted_token.cc
+++ b/sandbox/win/src/restricted_token.cc
@@ -6,10 +6,10 @@
#include <stddef.h>
+#include <memory>
#include <vector>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/win/src/acl.h"
#include "sandbox/win/src/win_utils.h"
@@ -17,9 +17,9 @@
// Calls GetTokenInformation with the desired |info_class| and returns a buffer
// with the result.
-scoped_ptr<BYTE[]> GetTokenInfo(const base::win::ScopedHandle& token,
- TOKEN_INFORMATION_CLASS info_class,
- DWORD* error) {
+std::unique_ptr<BYTE[]> GetTokenInfo(const base::win::ScopedHandle& token,
+ TOKEN_INFORMATION_CLASS info_class,
+ DWORD* error) {
// Get the required buffer size.
DWORD size = 0;
::GetTokenInformation(token.Get(), info_class, NULL, 0, &size);
@@ -28,7 +28,7 @@
return nullptr;
}
- scoped_ptr<BYTE[]> buffer(new BYTE[size]);
+ std::unique_ptr<BYTE[]> buffer(new BYTE[size]);
if (!::GetTokenInformation(token.Get(), info_class, buffer.get(), size,
&size)) {
*error = ::GetLastError();
@@ -227,7 +227,7 @@
return ERROR_NO_TOKEN;
DWORD error;
- scoped_ptr<BYTE[]> buffer =
+ std::unique_ptr<BYTE[]> buffer =
GetTokenInfo(effective_token_, TokenGroups, &error);
if (!buffer)
@@ -274,7 +274,7 @@
return ERROR_NO_TOKEN;
DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE;
- scoped_ptr<BYTE[]> buffer(new BYTE[size]);
+ std::unique_ptr<BYTE[]> buffer(new BYTE[size]);
TOKEN_USER* token_user = reinterpret_cast<TOKEN_USER*>(buffer.get());
BOOL result = ::GetTokenInformation(effective_token_.Get(), TokenUser,
@@ -296,7 +296,7 @@
return ERROR_NO_TOKEN;
DWORD error;
- scoped_ptr<BYTE[]> buffer =
+ std::unique_ptr<BYTE[]> buffer =
GetTokenInfo(effective_token_, TokenPrivileges, &error);
if (!buffer)
@@ -356,7 +356,7 @@
return ERROR_NO_TOKEN;
DWORD error;
- scoped_ptr<BYTE[]> buffer =
+ std::unique_ptr<BYTE[]> buffer =
GetTokenInfo(effective_token_, TokenGroups, &error);
if (!buffer)
@@ -384,7 +384,7 @@
return ERROR_NO_TOKEN;
DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE;
- scoped_ptr<BYTE[]> buffer(new BYTE[size]);
+ std::unique_ptr<BYTE[]> buffer(new BYTE[size]);
TOKEN_USER* token_user = reinterpret_cast<TOKEN_USER*>(buffer.get());
BOOL result = ::GetTokenInformation(effective_token_.Get(), TokenUser,
@@ -409,7 +409,7 @@
if (ERROR_SUCCESS != error)
return error;
- scoped_ptr<BYTE[]> buffer =
+ std::unique_ptr<BYTE[]> buffer =
GetTokenInfo(effective_token_, TokenGroups, &error);
if (!buffer)
diff --git a/sandbox/win/src/sandbox_policy_base.h b/sandbox/win/src/sandbox_policy_base.h
index 31f0d9c..a2704a0 100644
--- a/sandbox/win/src/sandbox_policy_base.h
+++ b/sandbox/win/src/sandbox_policy_base.h
@@ -10,11 +10,11 @@
#include <stdint.h>
#include <list>
+#include <memory>
#include <vector>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/process/launch.h"
#include "base/strings/string16.h"
#include "base/win/scoped_handle.h"
@@ -155,10 +155,10 @@
// given type.
HandleCloser handle_closer_;
std::vector<base::string16> capabilities_;
- scoped_ptr<AppContainerAttributes> appcontainer_list_;
+ std::unique_ptr<AppContainerAttributes> appcontainer_list_;
PSID lowbox_sid_;
base::win::ScopedHandle lowbox_directory_;
- scoped_ptr<Dispatcher> dispatcher_;
+ std::unique_ptr<Dispatcher> dispatcher_;
bool lockdown_default_dacl_;
static HDESK alternate_desktop_handle_;
diff --git a/sandbox/win/src/service_resolver_32.cc b/sandbox/win/src/service_resolver_32.cc
index f809227e9..2fe99b90 100644
--- a/sandbox/win/src/service_resolver_32.cc
+++ b/sandbox/win/src/service_resolver_32.cc
@@ -6,8 +6,9 @@
#include <stddef.h>
+#include <memory>
+
#include "base/bit_cast.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/win/src/win_utils.h"
namespace {
@@ -175,7 +176,7 @@
relative_jump_ = 0;
size_t thunk_bytes = GetThunkSize();
- scoped_ptr<char[]> thunk_buffer(new char[thunk_bytes]);
+ std::unique_ptr<char[]> thunk_buffer(new char[thunk_bytes]);
ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>(
thunk_buffer.get());
diff --git a/sandbox/win/src/service_resolver_64.cc b/sandbox/win/src/service_resolver_64.cc
index 25ee9db..7846ee3 100644
--- a/sandbox/win/src/service_resolver_64.cc
+++ b/sandbox/win/src/service_resolver_64.cc
@@ -6,7 +6,8 @@
#include <stddef.h>
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "sandbox/win/src/sandbox_nt_util.h"
#include "sandbox/win/src/win_utils.h"
@@ -148,7 +149,7 @@
return ret;
size_t thunk_bytes = GetThunkSize();
- scoped_ptr<char[]> thunk_buffer(new char[thunk_bytes]);
+ std::unique_ptr<char[]> thunk_buffer(new char[thunk_bytes]);
ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>(
thunk_buffer.get());
diff --git a/sandbox/win/src/service_resolver_unittest.cc b/sandbox/win/src/service_resolver_unittest.cc
index 25d0875..ff59629 100644
--- a/sandbox/win/src/service_resolver_unittest.cc
+++ b/sandbox/win/src/service_resolver_unittest.cc
@@ -6,9 +6,10 @@
#include <stddef.h>
+#include <memory>
+
#include "base/bit_cast.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/win/windows_version.h"
#include "sandbox/win/src/resolver.h"
#include "sandbox/win/src/sandbox_utils.h"
@@ -108,7 +109,7 @@
// Any pointer will do as an interception_entry_point
void* function_entry = resolver;
size_t thunk_size = resolver->GetThunkSize();
- scoped_ptr<char[]> thunk(new char[thunk_size]);
+ std::unique_ptr<char[]> thunk(new char[thunk_size]);
size_t used;
resolver->AllowLocalPatches();
@@ -246,7 +247,7 @@
// Any pointer will do as an interception_entry_point
void* function_entry = resolver;
size_t thunk_size = resolver->GetThunkSize();
- scoped_ptr<char[]> thunk(new char[thunk_size]);
+ std::unique_ptr<char[]> thunk(new char[thunk_size]);
size_t used;
NTSTATUS ret = STATUS_UNSUCCESSFUL;
diff --git a/sandbox/win/src/sharedmem_ipc_server.cc b/sandbox/win/src/sharedmem_ipc_server.cc
index cf2d800..672abfac 100644
--- a/sandbox/win/src/sharedmem_ipc_server.cc
+++ b/sandbox/win/src/sharedmem_ipc_server.cc
@@ -5,9 +5,10 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
+
#include "base/callback.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "sandbox/win/src/crosscall_params.h"
#include "sandbox/win/src/crosscall_server.h"
@@ -175,7 +176,7 @@
ipc_params->args[i] = type;
switch (type) {
case WCHAR_TYPE: {
- scoped_ptr<base::string16> data(new base::string16);
+ std::unique_ptr<base::string16> data(new base::string16);
if (!params->GetParameterStr(i, data.get())) {
args[i] = 0;
ReleaseArgs(ipc_params, args);
@@ -228,10 +229,8 @@
// Parse, verify and copy the message. The handler operates on a copy
// of the message so the client cannot play dirty tricks by changing the
// data in the channel while the IPC is being processed.
- scoped_ptr<CrossCallParamsEx> params(
- CrossCallParamsEx::CreateFromBuffer(ipc_buffer,
- service_context->channel_size,
- &output_size));
+ std::unique_ptr<CrossCallParamsEx> params(CrossCallParamsEx::CreateFromBuffer(
+ ipc_buffer, service_context->channel_size, &output_size));
if (!params.get())
return false;
diff --git a/sandbox/win/src/target_process.cc b/sandbox/win/src/target_process.cc
index 2e0376f..495d35c 100644
--- a/sandbox/win/src/target_process.cc
+++ b/sandbox/win/src/target_process.cc
@@ -7,11 +7,11 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <utility>
#include "base/macros.h"
#include "base/memory/free_deleter.h"
-#include "base/memory/scoped_ptr.h"
#include "base/win/pe_image.h"
#include "base/win/startup_information.h"
#include "base/win/windows_version.h"
@@ -133,7 +133,7 @@
exe_name_.reset(_wcsdup(exe_path));
// the command line needs to be writable by CreateProcess().
- scoped_ptr<wchar_t, base::FreeDeleter> cmd_line(_wcsdup(command_line));
+ std::unique_ptr<wchar_t, base::FreeDeleter> cmd_line(_wcsdup(command_line));
// Start the target process suspended.
DWORD flags =
diff --git a/sandbox/win/src/target_process.h b/sandbox/win/src/target_process.h
index 547d414..90a4aa9 100644
--- a/sandbox/win/src/target_process.h
+++ b/sandbox/win/src/target_process.h
@@ -9,9 +9,10 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
+
#include "base/macros.h"
#include "base/memory/free_deleter.h"
-#include "base/memory/scoped_ptr.h"
#include "base/win/scoped_handle.h"
#include "base/win/scoped_process_information.h"
#include "sandbox/win/src/crosscall_server.h"
@@ -119,13 +120,13 @@
// Job object containing the target process.
HANDLE job_;
// Reference to the IPC subsystem.
- scoped_ptr<SharedMemIPCServer> ipc_server_;
+ std::unique_ptr<SharedMemIPCServer> ipc_server_;
// Provides the threads used by the IPC. This class does not own this pointer.
ThreadProvider* thread_pool_;
// Base address of the main executable
void* base_address_;
// Full name of the target executable.
- scoped_ptr<wchar_t, base::FreeDeleter> exe_name_;
+ std::unique_ptr<wchar_t, base::FreeDeleter> exe_name_;
// Function used for testing.
friend TargetProcess* MakeTestTargetProcess(HANDLE process,
diff --git a/sandbox/win/src/top_level_dispatcher.cc b/sandbox/win/src/top_level_dispatcher.cc
index 1880c62..f09ca4e 100644
--- a/sandbox/win/src/top_level_dispatcher.cc
+++ b/sandbox/win/src/top_level_dispatcher.cc
@@ -8,7 +8,6 @@
#include <string.h>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/win/src/crosscall_server.h"
#include "sandbox/win/src/filesystem_dispatcher.h"
#include "sandbox/win/src/handle_dispatcher.h"
diff --git a/sandbox/win/src/top_level_dispatcher.h b/sandbox/win/src/top_level_dispatcher.h
index c9306de..c1cf8f6 100644
--- a/sandbox/win/src/top_level_dispatcher.h
+++ b/sandbox/win/src/top_level_dispatcher.h
@@ -5,8 +5,9 @@
#ifndef SANDBOX_SRC_TOP_LEVEL_DISPATCHER_H__
#define SANDBOX_SRC_TOP_LEVEL_DISPATCHER_H__
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/win/src/crosscall_server.h"
#include "sandbox/win/src/interception.h"
#include "sandbox/win/src/ipc_tags.h"
@@ -34,13 +35,13 @@
Dispatcher* GetDispatcher(int ipc_tag);
PolicyBase* policy_;
- scoped_ptr<Dispatcher> filesystem_dispatcher_;
- scoped_ptr<Dispatcher> named_pipe_dispatcher_;
- scoped_ptr<Dispatcher> thread_process_dispatcher_;
- scoped_ptr<Dispatcher> sync_dispatcher_;
- scoped_ptr<Dispatcher> registry_dispatcher_;
- scoped_ptr<Dispatcher> handle_dispatcher_;
- scoped_ptr<Dispatcher> process_mitigations_win32k_dispatcher_;
+ std::unique_ptr<Dispatcher> filesystem_dispatcher_;
+ std::unique_ptr<Dispatcher> named_pipe_dispatcher_;
+ std::unique_ptr<Dispatcher> thread_process_dispatcher_;
+ std::unique_ptr<Dispatcher> sync_dispatcher_;
+ std::unique_ptr<Dispatcher> registry_dispatcher_;
+ std::unique_ptr<Dispatcher> handle_dispatcher_;
+ std::unique_ptr<Dispatcher> process_mitigations_win32k_dispatcher_;
Dispatcher* ipc_targets_[IPC_LAST_TAG];
DISALLOW_COPY_AND_ASSIGN(TopLevelDispatcher);
diff --git a/sandbox/win/src/win_utils.cc b/sandbox/win/src/win_utils.cc
index ef4d803..178fd91 100644
--- a/sandbox/win/src/win_utils.cc
+++ b/sandbox/win/src/win_utils.cc
@@ -7,9 +7,9 @@
#include <stddef.h>
#include <map>
+#include <memory>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h"
#include "base/win/pe_image.h"
#include "sandbox/win/src/internal_types.h"
@@ -294,7 +294,7 @@
}
DWORD size = MAX_PATH;
- scoped_ptr<wchar_t[]> long_path_buf(new wchar_t[size]);
+ std::unique_ptr<wchar_t[]> long_path_buf(new wchar_t[size]);
DWORD return_value = ::GetLongPathName(temp_path.c_str(), long_path_buf.get(),
size);
@@ -355,7 +355,7 @@
NTSTATUS status = NtQueryObject(handle, ObjectNameInformation, name, size,
&size);
- scoped_ptr<BYTE[]> name_ptr;
+ std::unique_ptr<BYTE[]> name_ptr;
if (size) {
name_ptr.reset(new BYTE[size]);
name = reinterpret_cast<OBJECT_NAME_INFORMATION*>(name_ptr.get());
diff --git a/sandbox/win/src/window.cc b/sandbox/win/src/window.cc
index cfbf280..6a873028 100644
--- a/sandbox/win/src/window.cc
+++ b/sandbox/win/src/window.cc
@@ -6,8 +6,9 @@
#include <aclapi.h>
+#include <memory>
+
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/win/src/acl.h"
#include "sandbox/win/src/sid.h"
@@ -130,7 +131,7 @@
}
// Create the buffer that will hold the name.
- scoped_ptr<wchar_t[]> name_buffer(new wchar_t[size]);
+ std::unique_ptr<wchar_t[]> name_buffer(new wchar_t[size]);
// Query the name of the object.
if (!::GetUserObjectInformation(handle, UOI_NAME, name_buffer.get(), size,
diff --git a/sandbox/win/wow_helper/service64_resolver.cc b/sandbox/win/wow_helper/service64_resolver.cc
index 0424d9fd..1e71b50 100644
--- a/sandbox/win/wow_helper/service64_resolver.cc
+++ b/sandbox/win/wow_helper/service64_resolver.cc
@@ -7,8 +7,9 @@
#include <limits.h>
#include <stddef.h>
+#include <memory>
+
#include "base/bit_cast.h"
-#include "base/memory/scoped_ptr.h"
#include "sandbox/win/wow_helper/target_code.h"
namespace {
@@ -214,7 +215,7 @@
return ret;
size_t thunk_bytes = GetThunkSize();
- scoped_ptr<char[]> thunk_buffer(new char[thunk_bytes]);
+ std::unique_ptr<char[]> thunk_buffer(new char[thunk_bytes]);
ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>(
thunk_buffer.get());
diff --git a/sandbox/win/wow_helper/wow_helper.vcproj b/sandbox/win/wow_helper/wow_helper.vcproj
index 5482fbd..c8e7c9e 100644
--- a/sandbox/win/wow_helper/wow_helper.vcproj
+++ b/sandbox/win/wow_helper/wow_helper.vcproj
@@ -178,14 +178,6 @@
</References>
<Files>
<Filter
- Name="base"
- >
- <File
- RelativePath="..\..\base\scoped_ptr.h"
- >
- </File>
- </Filter>
- <Filter
Name="sandbox"
>
<File