diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc index 7a82df43b0dcd1..5b6cb44762238c 100644 --- a/components/nacl/browser/nacl_process_host.cc +++ b/components/nacl/browser/nacl_process_host.cc @@ -180,7 +180,7 @@ class NaClSandboxedProcessLauncherDelegate } #elif defined(OS_POSIX) bool ShouldUseZygote() override { return true; } - base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } + base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } #endif // OS_WIN private: diff --git a/components/nacl/loader/nonsfi/nonsfi_sandbox.cc b/components/nacl/loader/nonsfi/nonsfi_sandbox.cc index 20ed046cf34e5c..cf880745950389 100644 --- a/components/nacl/loader/nonsfi/nonsfi_sandbox.cc +++ b/components/nacl/loader/nonsfi/nonsfi_sandbox.cc @@ -332,7 +332,7 @@ bool InitializeBPFSandbox(base::ScopedFD proc_fd) { bool sandbox_is_initialized = content::InitializeSandbox( scoped_ptr( new nacl::nonsfi::NaClNonSfiBPFSandboxPolicy()), - proc_fd.Pass()); + std::move(proc_fd)); if (!sandbox_is_initialized) return false; RunSandboxSanityChecks(); diff --git a/components/nacl/loader/sandbox_linux/nacl_sandbox_linux.cc b/components/nacl/loader/sandbox_linux/nacl_sandbox_linux.cc index 3b3cf9d6790b2e..e4d3c705614d3a 100644 --- a/components/nacl/loader/sandbox_linux/nacl_sandbox_linux.cc +++ b/components/nacl/loader/sandbox_linux/nacl_sandbox_linux.cc @@ -187,7 +187,7 @@ void NaClSandbox::InitializeLayerTwoSandbox(bool uses_nonsfi_mode) { // will prevent its usage. #if defined(OS_NACL_NONSFI) CHECK(uses_nonsfi_mode); - layer_two_enabled_ = nacl::nonsfi::InitializeBPFSandbox(proc_fd_.Pass()); + layer_two_enabled_ = nacl::nonsfi::InitializeBPFSandbox(std::move(proc_fd_)); layer_two_is_nonsfi_ = true; #else CHECK(!uses_nonsfi_mode); diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index 6b71c84bda6dc7..c705b7db4972e4 100644 --- a/content/browser/child_process_launcher.cc +++ b/content/browser/child_process_launcher.cc @@ -4,6 +4,8 @@ #include "content/browser/child_process_launcher.h" +#include + #include "base/bind.h" #include "base/command_line.h" #include "base/files/file_util.h" @@ -139,7 +141,7 @@ void LaunchOnLauncherThread(const NotifyCallback& callback, #if defined(OS_ANDROID) files_to_register->Share(kPrimaryIPCChannel, ipcfd.get()); #else - files_to_register->Transfer(kPrimaryIPCChannel, ipcfd.Pass()); + files_to_register->Transfer(kPrimaryIPCChannel, std::move(ipcfd)); #endif #endif @@ -188,7 +190,7 @@ void LaunchOnLauncherThread(const NotifyCallback& callback, CHECK(!cmd_line->HasSwitch(switches::kSingleProcess)); StartChildProcess( - cmd_line->argv(), child_process_id, files_to_register.Pass(), regions, + cmd_line->argv(), child_process_id, std::move(files_to_register), regions, base::Bind(&OnChildProcessStartedAndroid, callback, client_thread_id, begin_launch_time, base::Passed(&ipcfd))); @@ -199,7 +201,7 @@ void LaunchOnLauncherThread(const NotifyCallback& callback, #if !defined(OS_MACOSX) if (use_zygote) { base::ProcessHandle handle = ZygoteHostImpl::GetInstance()->ForkRequest( - cmd_line->argv(), files_to_register.Pass(), process_type); + cmd_line->argv(), std::move(files_to_register), process_type); process = base::Process(handle); } else // Fall through to the normal posix case below when we're not zygoting. @@ -305,7 +307,7 @@ void TerminateOnLauncherThread(bool zygote, base::Process process) { ZygoteHostImpl::GetInstance()->EnsureProcessTerminated(process.Handle()); } else #endif // !OS_MACOSX - base::EnsureProcessTerminated(process.Pass()); + base::EnsureProcessTerminated(std::move(process)); #endif // OS_POSIX #endif // defined(OS_ANDROID) } @@ -447,9 +449,9 @@ void ChildProcessLauncher::DidLaunch( if (instance.get()) { instance->Notify(zygote, #if defined(OS_ANDROID) - ipcfd.Pass(), + std::move(ipcfd), #endif - process.Pass()); + std::move(process)); } else { if (process.IsValid() && terminate_on_shutdown) { // On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So @@ -469,7 +471,7 @@ void ChildProcessLauncher::Notify( base::Process process) { DCHECK(CalledOnValidThread()); starting_ = false; - process_ = process.Pass(); + process_ = std::move(process); #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) zygote_ = zygote; diff --git a/content/browser/file_descriptor_info_impl.cc b/content/browser/file_descriptor_info_impl.cc index 45ce54246ec7e1..c6cf831e625833 100644 --- a/content/browser/file_descriptor_info_impl.cc +++ b/content/browser/file_descriptor_info_impl.cc @@ -4,6 +4,8 @@ #include "content/browser/file_descriptor_info_impl.h" +#include + namespace content { // static @@ -23,7 +25,7 @@ void FileDescriptorInfoImpl::Share(int id, base::PlatformFile fd) { void FileDescriptorInfoImpl::Transfer(int id, base::ScopedFD fd) { AddToMapping(id, fd.get()); - owned_descriptors_.push_back(new base::ScopedFD(fd.Pass())); + owned_descriptors_.push_back(new base::ScopedFD(std::move(fd))); } base::PlatformFile FileDescriptorInfoImpl::GetFDAt(size_t i) const { @@ -65,7 +67,7 @@ base::ScopedFD FileDescriptorInfoImpl::ReleaseFD(base::PlatformFile file) { (*found)->swap(fd); owned_descriptors_.erase(found); - return fd.Pass(); + return fd; } void FileDescriptorInfoImpl::AddToMapping(int id, base::PlatformFile fd) { diff --git a/content/browser/file_descriptor_info_impl_unittest.cc b/content/browser/file_descriptor_info_impl_unittest.cc index 9724a7cff64871..ccc061a3723ce9 100644 --- a/content/browser/file_descriptor_info_impl_unittest.cc +++ b/content/browser/file_descriptor_info_impl_unittest.cc @@ -6,6 +6,7 @@ #include #include +#include #include "base/basictypes.h" #include "base/posix/eintr_wrapper.h" @@ -43,7 +44,7 @@ TEST_F(FileDescriptorInfoTest, Transfer) { base::ScopedFD fd(GetSafeFd()); int raw_fd = fd.get(); - target->Transfer(testingId, fd.Pass()); + target->Transfer(testingId, std::move(fd)); ASSERT_EQ(1U, target->GetMappingSize()); ASSERT_EQ(target->GetFDAt(0), raw_fd); ASSERT_EQ(target->GetIDAt(0), testingId); diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index ced0ab6f688443..370da1225e7660 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -4,6 +4,8 @@ #include "content/browser/gpu/gpu_process_host.h" +#include + #include "base/base64.h" #include "base/base_switches.h" #include "base/basictypes.h" @@ -270,7 +272,7 @@ class GpuSandboxedProcessLauncherDelegate } #elif defined(OS_POSIX) - base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } + base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } #endif // OS_WIN SandboxType GetSandboxType() override { diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc index ae6c3aeb942261..8069d3548d228b 100644 --- a/content/browser/plugin_process_host.cc +++ b/content/browser/plugin_process_host.cc @@ -6,10 +6,9 @@ #if defined(OS_WIN) #include -#elif defined(OS_POSIX) -#include // for pair<> #endif +#include #include #include "base/base_switches.h" @@ -112,7 +111,7 @@ class PluginSandboxedProcessLauncherDelegate } #elif defined(OS_POSIX) - base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } + base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } #endif // OS_WIN private: diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc index 4d87474f5a5f64..23ce9d0f5ddcc8 100644 --- a/content/browser/ppapi_plugin_process_host.cc +++ b/content/browser/ppapi_plugin_process_host.cc @@ -5,6 +5,7 @@ #include "content/browser/ppapi_plugin_process_host.h" #include +#include #include "base/base_switches.h" #include "base/command_line.h" @@ -98,7 +99,7 @@ class PpapiPluginSandboxedProcessLauncherDelegate .GetSwitchValueNative(switches::kPpapiPluginLauncher); return !is_broker_ && plugin_launcher.empty(); } - base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } + base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } #endif // OS_WIN SandboxType GetSandboxType() override { diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index eff17bc166e400..4c2413e3d4a8a3 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -9,6 +9,7 @@ #include #include +#include #include #include "base/base_switches.h" @@ -394,7 +395,7 @@ class RendererSandboxedProcessLauncherDelegate browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); return renderer_prefix.empty(); } - base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } + base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } #endif // OS_WIN SandboxType GetSandboxType() override { return SANDBOX_TYPE_RENDERER; } diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc index 4e2b07c0ac048f..4cd0cd19e9318a 100644 --- a/content/browser/utility_process_host_impl.cc +++ b/content/browser/utility_process_host_impl.cc @@ -4,6 +4,8 @@ #include "content/browser/utility_process_host_impl.h" +#include + #include "base/base_switches.h" #include "base/bind.h" #include "base/bind_helpers.h" @@ -88,7 +90,7 @@ class UtilitySandboxedProcessLauncherDelegate return !no_sandbox_ && exposed_dir_.empty(); } base::EnvironmentMap GetEnvironment() override { return env_; } - base::ScopedFD TakeIpcFd() override { return ipc_fd_.Pass(); } + base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } #endif // OS_WIN SandboxType GetSandboxType() override { diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc index f8559b9ff9e716..575dce7896e503 100644 --- a/content/common/gpu/gpu_channel.cc +++ b/content/common/gpu/gpu_channel.cc @@ -613,7 +613,7 @@ IPC::ChannelHandle GpuChannel::Init(base::WaitableEvent* shutdown_event) { // that it gets closed after it has been sent. base::ScopedFD renderer_fd = channel_->TakeClientFileDescriptor(); DCHECK(renderer_fd.is_valid()); - channel_handle.socket = base::FileDescriptor(renderer_fd.Pass()); + channel_handle.socket = base::FileDescriptor(std::move(renderer_fd)); #endif channel_->AddFilter(filter_.get()); diff --git a/content/common/sandbox_linux/sandbox_init_linux.cc b/content/common/sandbox_linux/sandbox_init_linux.cc index 146b3528b697fb..9ffeb5da33c19c 100644 --- a/content/common/sandbox_linux/sandbox_init_linux.cc +++ b/content/common/sandbox_linux/sandbox_init_linux.cc @@ -4,6 +4,8 @@ #include "content/public/common/sandbox_init.h" +#include + #include "base/files/scoped_file.h" #include "base/memory/scoped_ptr.h" #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" @@ -14,7 +16,7 @@ namespace content { bool InitializeSandbox(scoped_ptr policy, base::ScopedFD proc_fd) { return SandboxSeccompBPF::StartSandboxWithExternalPolicy(policy.Pass(), - proc_fd.Pass()); + std::move(proc_fd)); } #if !defined(OS_NACL_NONSFI) diff --git a/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc b/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc index 79adbee4bba299..de2bcc00c978b2 100644 --- a/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc +++ b/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc @@ -70,7 +70,7 @@ void StartSandboxWithPolicy(sandbox::bpf_dsl::Policy* policy, // doing so does not stop the sandbox. SandboxBPF sandbox(policy); - sandbox.SetProcFd(proc_fd.Pass()); + sandbox.SetProcFd(std::move(proc_fd)); CHECK(sandbox.StartSandbox(SandboxBPF::SeccompLevel::SINGLE_THREADED)); } @@ -201,7 +201,7 @@ bool StartBPFSandbox(const base::CommandLine& command_line, } CHECK(policy->PreSandboxHook()); - StartSandboxWithPolicy(policy.release(), proc_fd.Pass()); + StartSandboxWithPolicy(policy.release(), std::move(proc_fd)); RunSandboxSanityChecks(process_type); return true; @@ -279,7 +279,7 @@ bool SandboxSeccompBPF::StartSandbox(const std::string& process_type, // If the kernel supports the sandbox, and if the command line says we // should enable it, enable it or die. bool started_sandbox = - StartBPFSandbox(command_line, process_type, proc_fd.Pass()); + StartBPFSandbox(command_line, process_type, std::move(proc_fd)); CHECK(started_sandbox); return true; } @@ -294,7 +294,7 @@ bool SandboxSeccompBPF::StartSandboxWithExternalPolicy( #if defined(USE_SECCOMP_BPF) if (IsSeccompBPFDesired() && SupportsSandbox()) { CHECK(policy); - StartSandboxWithPolicy(policy.release(), proc_fd.Pass()); + StartSandboxWithPolicy(policy.release(), std::move(proc_fd)); return true; } #endif // defined(USE_SECCOMP_BPF) diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc index 929527e45f2212..d582eb1334d506 100644 --- a/content/zygote/zygote_linux.cc +++ b/content/zygote/zygote_linux.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include "base/command_line.h" #include "base/files/file_util.h" @@ -589,7 +590,7 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter, // First FD is the PID oracle socket. if (fds.size() < 1) return -1; - base::ScopedFD pid_oracle(fds[0]->Pass()); + base::ScopedFD pid_oracle(std::move(*fds[0])); // Remaining FDs are for the global descriptor mapping. for (int i = 1; i < numfds; ++i) { @@ -603,13 +604,9 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter, static_cast(kSandboxIPCChannel), GetSandboxFD())); // Returns twice, once per process. - base::ProcessId child_pid = ForkWithRealPid(process_type, - mapping, - channel_id, - pid_oracle.Pass(), - uma_name, - uma_sample, - uma_boundary_value); + base::ProcessId child_pid = + ForkWithRealPid(process_type, mapping, channel_id, std::move(pid_oracle), + uma_name, uma_sample, uma_boundary_value); if (!child_pid) { // This is the child process. diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc index 1f73e781f42f3d..3023c05e580cce 100644 --- a/ipc/ipc_channel_posix.cc +++ b/ipc/ipc_channel_posix.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include "base/command_line.h" #include "base/files/file_path.h" @@ -544,7 +545,7 @@ base::ScopedFD ChannelPosix::TakeClientFileDescriptor() { if (!client_pipe_.is_valid()) return base::ScopedFD(); PipeMap::GetInstance()->Remove(pipe_name_); - return client_pipe_.Pass(); + return std::move(client_pipe_); } void ChannelPosix::CloseClientFileDescriptor() { diff --git a/ipc/ipc_platform_file_attachment_posix.cc b/ipc/ipc_platform_file_attachment_posix.cc index b704750c15625c..b130ab26eb7db6 100644 --- a/ipc/ipc_platform_file_attachment_posix.cc +++ b/ipc/ipc_platform_file_attachment_posix.cc @@ -4,6 +4,8 @@ #include "ipc/ipc_platform_file_attachment_posix.h" +#include + namespace IPC { namespace internal { @@ -12,8 +14,7 @@ PlatformFileAttachment::PlatformFileAttachment(base::PlatformFile file) } PlatformFileAttachment::PlatformFileAttachment(base::ScopedFD file) - : file_(file.get()), owning_(file.Pass()) { -} + : file_(file.get()), owning_(std::move(file)) {} PlatformFileAttachment::~PlatformFileAttachment() { } diff --git a/mojo/runner/host/linux_sandbox.cc b/mojo/runner/host/linux_sandbox.cc index 20f7ba8457918c..a8dcb8b0bb7260 100644 --- a/mojo/runner/host/linux_sandbox.cc +++ b/mojo/runner/host/linux_sandbox.cc @@ -6,6 +6,7 @@ #include #include +#include #include "base/bind.h" #include "base/debug/leak_annotations.h" @@ -139,7 +140,7 @@ void LinuxSandbox::EngageSeccompSandbox() { base::ScopedFD proc_fd(HANDLE_EINTR( openat(proc_fd_.get(), ".", O_RDONLY | O_DIRECTORY | O_CLOEXEC))); CHECK(proc_fd.is_valid()); - sandbox.SetProcFd(proc_fd.Pass()); + sandbox.SetProcFd(std::move(proc_fd)); CHECK( sandbox.StartSandbox(sandbox::SandboxBPF::SeccompLevel::SINGLE_THREADED)) << "Starting the process with a sandbox failed. Missing kernel support."; diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc index 580cad2525c8f9..2f66b40bc0d9c9 100644 --- a/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc +++ b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc @@ -8,6 +8,7 @@ #include #include +#include #include "base/files/scoped_file.h" #include "base/posix/eintr_wrapper.h" @@ -71,7 +72,7 @@ TEST(SandboxBPF, ProcTaskFdDescriptorGetsClosed) { { SandboxBPF sandbox(nullptr); - sandbox.SetProcFd(write_end.Pass()); + sandbox.SetProcFd(std::move(write_end)); } ASSERT_EQ(0, fcntl(read_end.get(), F_SETFL, O_NONBLOCK)); diff --git a/sandbox/linux/services/proc_util.cc b/sandbox/linux/services/proc_util.cc index 8341b4a87441e8..247c29c9127b50 100644 --- a/sandbox/linux/services/proc_util.cc +++ b/sandbox/linux/services/proc_util.cc @@ -33,7 +33,7 @@ base::ScopedFD OpenDirectory(const char* path) { base::ScopedFD directory_fd( HANDLE_EINTR(open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC))); PCHECK(directory_fd.is_valid()); - return directory_fd.Pass(); + return directory_fd; } } // namespace diff --git a/sandbox/linux/syscall_broker/broker_client.cc b/sandbox/linux/syscall_broker/broker_client.cc index 760cf59b3c1434..db8201ae3d88cc 100644 --- a/sandbox/linux/syscall_broker/broker_client.cc +++ b/sandbox/linux/syscall_broker/broker_client.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include "build/build_config.h" #include "base/logging.h" @@ -123,10 +124,9 @@ BrokerClient::BrokerClient(const BrokerPolicy& broker_policy, bool fast_check_in_client, bool quiet_failures_for_tests) : broker_policy_(broker_policy), - ipc_channel_(ipc_channel.Pass()), + ipc_channel_(std::move(ipc_channel)), fast_check_in_client_(fast_check_in_client), - quiet_failures_for_tests_(quiet_failures_for_tests) { -} + quiet_failures_for_tests_(quiet_failures_for_tests) {} BrokerClient::~BrokerClient() { } diff --git a/sandbox/linux/syscall_broker/broker_host.cc b/sandbox/linux/syscall_broker/broker_host.cc index 8b78b1baa65f4d..1a0568fb2f0458 100644 --- a/sandbox/linux/syscall_broker/broker_host.cc +++ b/sandbox/linux/syscall_broker/broker_host.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include "base/files/scoped_file.h" @@ -163,8 +164,7 @@ bool HandleRemoteCommand(const BrokerPolicy& policy, BrokerHost::BrokerHost(const BrokerPolicy& broker_policy, BrokerChannel::EndPoint ipc_channel) - : broker_policy_(broker_policy), ipc_channel_(ipc_channel.Pass()) { -} + : broker_policy_(broker_policy), ipc_channel_(std::move(ipc_channel)) {} BrokerHost::~BrokerHost() { } @@ -193,7 +193,7 @@ BrokerHost::RequestStatus BrokerHost::HandleRequest() const { return RequestStatus::FAILURE; } - base::ScopedFD temporary_ipc(fds[0]->Pass()); + base::ScopedFD temporary_ipc(std::move(*fds[0])); base::Pickle pickle(buf, msg_len); base::PickleIterator iter(pickle); diff --git a/sandbox/linux/syscall_broker/broker_process.cc b/sandbox/linux/syscall_broker/broker_process.cc index 81131cc4e0e7be..5ab8c6c64ecc4b 100644 --- a/sandbox/linux/syscall_broker/broker_process.cc +++ b/sandbox/linux/syscall_broker/broker_process.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include "base/callback.h" @@ -75,7 +76,7 @@ bool BrokerProcess::Init( // We are the parent and we have just forked our broker process. ipc_reader.reset(); broker_pid_ = child_pid; - broker_client_.reset(new BrokerClient(policy_, ipc_writer.Pass(), + broker_client_.reset(new BrokerClient(policy_, std::move(ipc_writer), fast_check_in_client_, quiet_failures_for_tests_)); initialized_ = true; @@ -85,7 +86,7 @@ bool BrokerProcess::Init( // we get notified if the client disappears. ipc_writer.reset(); CHECK(broker_process_init_callback.Run()); - BrokerHost broker_host(policy_, ipc_reader.Pass()); + BrokerHost broker_host(policy_, std::move(ipc_reader)); for (;;) { switch (broker_host.HandleRequest()) { case BrokerHost::RequestStatus::LOST_CLIENT: