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

Unified Diff: remoting/host/heartbeat_sender.cc

Issue 1064863004: Use base::ResetAndReturn() in remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months 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
Index: remoting/host/heartbeat_sender.cc
diff --git a/remoting/host/heartbeat_sender.cc b/remoting/host/heartbeat_sender.cc
index ae109554177f414230ce857e0bb48b1d659c51fe..1d1a77d1ba117fb2be9be3f7be7d364fb93b9f5e 100644
--- a/remoting/host/heartbeat_sender.cc
+++ b/remoting/host/heartbeat_sender.cc
@@ -7,6 +7,7 @@
#include <math.h>
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringize_macros.h"
@@ -105,9 +106,7 @@ bool HeartbeatSender::OnSignalStrategyIncomingStanza(
void HeartbeatSender::OnHostOfflineReasonTimeout() {
DCHECK(!host_offline_reason_ack_callback_.is_null());
- base::Callback<void(bool)> local_callback = host_offline_reason_ack_callback_;
- host_offline_reason_ack_callback_.Reset();
- local_callback.Run(false);
+ base::ResetAndReturn(&host_offline_reason_ack_callback_).Run(false);
}
void HeartbeatSender::OnHostOfflineReasonAck() {
@@ -122,11 +121,10 @@ void HeartbeatSender::OnHostOfflineReasonAck() {
// Run the ACK callback under a clean stack via PostTask() (because the
// callback can end up deleting |this| HeartbeatSender [i.e. when used from
// HostSignalingManager]).
- base::Closure fully_bound_ack_callback =
- base::Bind(host_offline_reason_ack_callback_, true);
- host_offline_reason_ack_callback_.Reset();
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
- fully_bound_ack_callback);
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(base::ResetAndReturn(&host_offline_reason_ack_callback_),
+ true));
}
void HeartbeatSender::SetHostOfflineReason(

Powered by Google App Engine
This is Rietveld 408576698