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/signaling/iq_sender.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'remoting/signaling') diff --git a/remoting/signaling/iq_sender.cc b/remoting/signaling/iq_sender.cc index d3e7432..7fefc71 100644 --- a/remoting/signaling/iq_sender.cc +++ b/remoting/signaling/iq_sender.cc @@ -5,6 +5,7 @@ #include "remoting/signaling/iq_sender.h" #include "base/bind.h" +#include "base/callback_helpers.h" #include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" @@ -138,11 +139,8 @@ void IqRequest::SetTimeout(base::TimeDelta timeout) { } void IqRequest::CallCallback(const buzz::XmlElement* stanza) { - if (!callback_.is_null()) { - IqSender::ReplyCallback callback(callback_); - callback_.Reset(); - callback.Run(this, stanza); - } + if (!callback_.is_null()) + base::ResetAndReturn(&callback_).Run(this, stanza); } void IqRequest::OnTimeout() { -- cgit v1.1