From d9bdcb6c95619e6cb3a4281156573c58f7626a26 Mon Sep 17 00:00:00 2001 From: sergeyu Date: Fri, 24 Apr 2015 17:18:08 -0700 Subject: Use base::ResetAndReturn() in remoting. base::ResetAndReturn() makes code shorter and simpler. Also in several places callbacks were Reset() after Run(), which is dangerous for callback that are allowed to delete the caller. base::ResetAndReturn() helps to avoid this issue. Review URL: https://codereview.chromium.org/1064863004 Cr-Commit-Position: refs/heads/master@{#326940} --- remoting/host/daemon_process.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'remoting/host/daemon_process.cc') diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc index 8c9ebbb..e08677a 100644 --- a/remoting/host/daemon_process.cc +++ b/remoting/host/daemon_process.cc @@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/command_line.h" #include "base/files/file_path.h" #include "base/files/file_util.h" @@ -285,9 +286,7 @@ void DaemonProcess::Stop() { DCHECK(caller_task_runner()->BelongsToCurrentThread()); if (!stopped_callback_.is_null()) { - base::Closure stopped_callback = stopped_callback_; - stopped_callback_.Reset(); - stopped_callback.Run(); + base::ResetAndReturn(&stopped_callback_).Run(); } } -- cgit v1.1