Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Unified Diff: remoting/host/win/wts_session_process_delegate.cc

Issue 1549493004: Use std::move() instead of .Pass() in remoting/host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass
Patch Set: include <utility> Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/win/worker_process_launcher_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/win/wts_session_process_delegate.cc
diff --git a/remoting/host/win/wts_session_process_delegate.cc b/remoting/host/win/wts_session_process_delegate.cc
index 4a2a30de6b6dfa0e5b6232b4c881c09bf60048a8..c2ba5d67eb91d52b33997a585fc95dc65bac426f 100644
--- a/remoting/host/win/wts_session_process_delegate.cc
+++ b/remoting/host/win/wts_session_process_delegate.cc
@@ -7,6 +7,8 @@
#include "remoting/host/win/wts_session_process_delegate.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
@@ -89,10 +91,10 @@ class WtsSessionProcessDelegate::Core
// Creates and initializes the job object that will sandbox the launched child
// processes.
- void InitializeJob(scoped_ptr<base::win::ScopedHandle> job);
+ void InitializeJob(ScopedHandle job);
// Notified that the job object initialization is complete.
- void InitializeJobCompleted(scoped_ptr<base::win::ScopedHandle> job);
+ void InitializeJobCompleted(ScopedHandle job);
// Called when the number of processes running in the job reaches zero.
void OnActiveProcessZero();
@@ -155,8 +157,7 @@ WtsSessionProcessDelegate::Core::Core(
get_named_pipe_client_pid_(nullptr),
launch_elevated_(launch_elevated),
launch_pending_(false),
- target_command_(target_command.Pass()) {
-}
+ target_command_(std::move(target_command)) {}
bool WtsSessionProcessDelegate::Core::Initialize(uint32_t session_id) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
@@ -198,19 +199,13 @@ bool WtsSessionProcessDelegate::Core::Initialize(uint32_t session_id) {
return false;
}
- // ScopedHandle is not compatible with base::Passed, so we wrap it to
- // a scoped pointer.
- scoped_ptr<ScopedHandle> job_wrapper(new ScopedHandle());
- *job_wrapper = job.Pass();
-
// To receive job object notifications the job object is registered with
// the completion port represented by |io_task_runner|. The registration has
// to be done on the I/O thread because
// MessageLoopForIO::RegisterJobObject() can only be called via
// MessageLoopForIO::current().
io_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&Core::InitializeJob, this, base::Passed(&job_wrapper)));
+ FROM_HERE, base::Bind(&Core::InitializeJob, this, base::Passed(&job)));
}
// Create a session token for the launched process.
@@ -331,7 +326,7 @@ void WtsSessionProcessDelegate::Core::OnChannelConnected(int32_t peer_pid) {
return;
}
- ReportProcessLaunched(worker_process.Pass());
+ ReportProcessLaunched(std::move(worker_process));
}
if (event_handler_)
@@ -422,14 +417,14 @@ void WtsSessionProcessDelegate::Core::DoLaunchProcess() {
return;
}
- channel_ = channel.Pass();
- pipe_ = pipe.Pass();
+ channel_ = std::move(channel);
+ pipe_ = std::move(pipe);
// Report success if the worker process is lauched directly. Otherwise, PID of
// the client connected to the pipe will be used later. See
// OnChannelConnected().
if (!launch_elevated_)
- ReportProcessLaunched(worker_process.Pass());
+ ReportProcessLaunched(std::move(worker_process));
}
void WtsSessionProcessDelegate::Core::DrainJobNotifications() {
@@ -455,12 +450,11 @@ void WtsSessionProcessDelegate::Core::DrainJobNotificationsCompleted() {
}
}
-void WtsSessionProcessDelegate::Core::InitializeJob(
- scoped_ptr<base::win::ScopedHandle> job) {
+void WtsSessionProcessDelegate::Core::InitializeJob(ScopedHandle job) {
DCHECK(io_task_runner_->BelongsToCurrentThread());
// Register to receive job notifications via the I/O thread's completion port.
- if (!base::MessageLoopForIO::current()->RegisterJobObject(job->Get(), this)) {
+ if (!base::MessageLoopForIO::current()->RegisterJobObject(job.Get(), this)) {
PLOG(ERROR) << "Failed to associate the job object with a completion port";
return;
}
@@ -470,12 +464,11 @@ void WtsSessionProcessDelegate::Core::InitializeJob(
&Core::InitializeJobCompleted, this, base::Passed(&job)));
}
-void WtsSessionProcessDelegate::Core::InitializeJobCompleted(
- scoped_ptr<ScopedHandle> job) {
+void WtsSessionProcessDelegate::Core::InitializeJobCompleted(ScopedHandle job) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
DCHECK(!job_.IsValid());
- job_ = job->Pass();
+ job_ = std::move(job);
if (launch_pending_)
DoLaunchProcess();
@@ -507,19 +500,15 @@ void WtsSessionProcessDelegate::Core::ReportProcessLaunched(
DCHECK(caller_task_runner_->BelongsToCurrentThread());
DCHECK(!worker_process_.IsValid());
- worker_process_ = worker_process.Pass();
+ worker_process_ = std::move(worker_process);
// Report a handle that can be used to wait for the worker process completion,
// query information about the process and duplicate handles.
DWORD desired_access =
SYNCHRONIZE | PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION;
HANDLE temp_handle;
- if (!DuplicateHandle(GetCurrentProcess(),
- worker_process_.Get(),
- GetCurrentProcess(),
- &temp_handle,
- desired_access,
- FALSE,
+ if (!DuplicateHandle(GetCurrentProcess(), worker_process_.Get(),
+ GetCurrentProcess(), &temp_handle, desired_access, FALSE,
0)) {
PLOG(ERROR) << "Failed to duplicate a handle";
ReportFatalError();
@@ -527,7 +516,7 @@ void WtsSessionProcessDelegate::Core::ReportProcessLaunched(
}
ScopedHandle limited_handle(temp_handle);
- event_handler_->OnProcessLaunched(limited_handle.Pass());
+ event_handler_->OnProcessLaunched(std::move(limited_handle));
}
WtsSessionProcessDelegate::WtsSessionProcessDelegate(
@@ -535,9 +524,7 @@ WtsSessionProcessDelegate::WtsSessionProcessDelegate(
scoped_ptr<base::CommandLine> target_command,
bool launch_elevated,
const std::string& channel_security) {
- core_ = new Core(io_task_runner,
- target_command.Pass(),
- launch_elevated,
+ core_ = new Core(io_task_runner, std::move(target_command), launch_elevated,
channel_security);
}
« no previous file with comments | « remoting/host/win/worker_process_launcher_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698